public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v1] test: env: add test for u-boot-initial-env creation
@ 2022-12-09 12:09 Max Krummenacher
  2022-12-09 19:51 ` Simon Glass
  2023-01-12 15:18 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Max Krummenacher @ 2022-12-09 12:09 UTC (permalink / raw)
  To: u-boot; +Cc: Max Krummenacher, Heinrich Schuchardt, Simon Glass

From: Max Krummenacher <max.krummenacher@toradex.com>

Checks that `make u-boot-initial-env` creates the text file
u-boot-initial-env and checks that it at least contains
`board=<something>`.

Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>

---

Changes in v1:
I assume every board has a board environment variable but I don't
test its value. I.e. the test succseeds even if a board sets it
to some arbitrary string at build time.
-
Tested only with 'sandbox'.
-
As proposed by Simon, see
https://lore.kernel.org/all/CAPnjgZ0V_Fdj9EvzD1hOYa7VqeptsueAuPj5ktYa7owO1qr_CQ@mail.gmail.com/
Thanks for the pointers tn where to add and where to look
for a host test example. This was very helpful.

 test/py/tests/test_env.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index 6d08565f0b5..ea1e4c76e09 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -8,6 +8,7 @@ Test operation of shell commands relating to environment variables.
 
 import os
 import os.path
+import re
 from subprocess import call, CalledProcessError
 import tempfile
 
@@ -173,6 +174,28 @@ def validate_set(state_test_env, var, value):
     response = state_test_env.u_boot_console.run_command('printenv %s' % var)
     assert response == ('%s=%s' % (var, value))
 
+def test_env_initial_env_file(u_boot_console):
+    """Test that the u-boot-initial-env make target works"""
+    cons = u_boot_console
+    builddir = 'O=' + cons.config.build_dir
+    envfile = cons.config.build_dir + '/u-boot-initial-env'
+
+    # remove if already exists from an older run
+    try:
+        os.remove(envfile)
+    except:
+        pass
+
+    u_boot_utils.run_and_log(cons, ['make', builddir, 'u-boot-initial-env'])
+
+    assert os.path.exists(envfile)
+
+    # assume that every environment has a board variable, e.g. board=sandbox
+    with open(envfile, 'r') as file:
+        env = file.read()
+    regex = re.compile('board=.+\\n')
+    assert re.search(regex, env)
+
 def test_env_echo_exists(state_test_env):
     """Test echoing a variable that exists."""
 
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] test: env: add test for u-boot-initial-env creation
  2022-12-09 12:09 [PATCH v1] test: env: add test for u-boot-initial-env creation Max Krummenacher
@ 2022-12-09 19:51 ` Simon Glass
  2023-01-12 15:18 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2022-12-09 19:51 UTC (permalink / raw)
  To: Max Krummenacher; +Cc: u-boot, Max Krummenacher, Heinrich Schuchardt

On Sat, 10 Dec 2022 at 01:10, Max Krummenacher <max.oss.09@gmail.com> wrote:
>
> From: Max Krummenacher <max.krummenacher@toradex.com>
>
> Checks that `make u-boot-initial-env` creates the text file
> u-boot-initial-env and checks that it at least contains
> `board=<something>`.
>
> Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
>
> ---
>
> Changes in v1:
> I assume every board has a board environment variable but I don't
> test its value. I.e. the test succseeds even if a board sets it
> to some arbitrary string at build time.
> -
> Tested only with 'sandbox'.
> -
> As proposed by Simon, see
> https://lore.kernel.org/all/CAPnjgZ0V_Fdj9EvzD1hOYa7VqeptsueAuPj5ktYa7owO1qr_CQ@mail.gmail.com/
> Thanks for the pointers tn where to add and where to look
> for a host test example. This was very helpful.
>
>  test/py/tests/test_env.py | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
>

Nice

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] test: env: add test for u-boot-initial-env creation
  2022-12-09 12:09 [PATCH v1] test: env: add test for u-boot-initial-env creation Max Krummenacher
  2022-12-09 19:51 ` Simon Glass
@ 2023-01-12 15:18 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2023-01-12 15:18 UTC (permalink / raw)
  To: Max Krummenacher
  Cc: u-boot, Max Krummenacher, Heinrich Schuchardt, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

On Fri, Dec 09, 2022 at 01:09:56PM +0100, Max Krummenacher wrote:

> From: Max Krummenacher <max.krummenacher@toradex.com>
> 
> Checks that `make u-boot-initial-env` creates the text file
> u-boot-initial-env and checks that it at least contains
> `board=<something>`.
> 
> Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-12 15:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-09 12:09 [PATCH v1] test: env: add test for u-boot-initial-env creation Max Krummenacher
2022-12-09 19:51 ` Simon Glass
2023-01-12 15:18 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox