From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: "Tom Rini" <trini@konsulko.com>, "Simon Glass" <sjg@chromium.org>,
"Patrick Delaunay" <patrick.delaunay@foss.st.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Joe Hershberger" <joe.hershberger@ni.com>,
"Marek Behún" <marek.behun@nic.cz>, "Wolfgang Denk" <wd@denx.de>
Subject: [PATCH] env: Allow text-env tests to run with awk
Date: Sat, 12 Mar 2022 22:47:49 -0700 [thread overview]
Message-ID: <20220313054749.599896-1-sjg@chromium.org> (raw)
At present the tests assume that gawk is being used. Adjust the tests so
that the names are inserted in alphabetical order, so that awk is happy.
Also use PROCINFO to make gawk output in alphabetical order. This is not
ideal, since it changes the env-car ordering from what the user provided,
but it may be acceptable.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Fixes: https://source.denx.de/u-boot/u-boot/-/issues/10
---
scripts/env2string.awk | 5 ++++-
test/py/tests/test_env.py | 28 ++++++++++++++--------------
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/scripts/env2string.awk b/scripts/env2string.awk
index 1bfe9ed07a4..de470a49941 100644
--- a/scripts/env2string.awk
+++ b/scripts/env2string.awk
@@ -81,7 +81,10 @@ END {
if (do_output) {
printf("%s", "#define CONFIG_EXTRA_ENV_TEXT \"")
- # Print out all the variables
+ # Print out all the variables by alphabetic order, if using
+ # gawk. This allows test_env_test.py to work on both awk (where
+ # this next line does nothing)
+ PROCINFO["sorted_in"] = "@ind_str_asc"
for (var in vars) {
env = vars[var]
print var "=" vars[var] "\\0"
diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index b2f3470de94..6d08565f0b5 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -554,42 +554,42 @@ def test_env_text(u_boot_console):
# two vars
check_script('''fred=123
-ernie=456''', 'fred=123\\0ernie=456\\0')
+mary=456''', 'fred=123\\0mary=456\\0')
# blank lines
check_script('''fred=123
-ernie=456
+mary=456
-''', 'fred=123\\0ernie=456\\0')
+''', 'fred=123\\0mary=456\\0')
# append
check_script('''fred=123
-ernie=456
-fred+= 456''', 'fred=123 456\\0ernie=456\\0')
+mary=456
+fred+= 456''', 'fred=123 456\\0mary=456\\0')
# append from empty
check_script('''fred=
-ernie=456
-fred+= 456''', 'fred= 456\\0ernie=456\\0')
+mary=456
+fred+= 456''', 'fred= 456\\0mary=456\\0')
# variable with + in it
- check_script('fred+ernie=123', 'fred+ernie=123\\0')
+ check_script('fred+mary=123', 'fred+mary=123\\0')
# ignores variables that are empty
check_script('''fred=
fred+=
-ernie=456''', 'ernie=456\\0')
+mary=456''', 'mary=456\\0')
# single-character env name
- check_script('''f=123
+ check_script('''m=123
e=456
-f+= 456''', 'e=456\\0f=123 456\\0')
+m+= 456''', 'e=456\\0m=123 456\\0')
# contains quotes
check_script('''fred="my var"
-ernie=another"''', 'fred=\\"my var\\"\\0ernie=another\\"\\0')
+mary=another"''', 'fred=\\"my var\\"\\0mary=another\\"\\0')
# variable name ending in +
check_script('''fred\\+=my var
@@ -598,7 +598,7 @@ fred++= again''', 'fred+=my var again\\0')
# variable name containing +
check_script('''fred+jane=both
fred+jane+=again
-ernie=456''', 'fred+jane=bothagain\\0ernie=456\\0')
+mary=456''', 'fred+jane=bothagain\\0mary=456\\0')
# multi-line vars - new vars always start at column 1
check_script('''fred=first
@@ -607,7 +607,7 @@ ernie=456''', 'fred+jane=bothagain\\0ernie=456\\0')
after blank
confusing=oops
-ernie=another"''', 'fred=first second third with tab after blank confusing=oops\\0ernie=another\\"\\0')
+mary=another"''', 'fred=first second third with tab after blank confusing=oops\\0mary=another\\"\\0')
# real-world example
check_script('''ubifs_boot=
--
2.35.1.723.g4982287a31-goog
next reply other threads:[~2022-03-13 5:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-13 5:47 Simon Glass [this message]
2022-04-08 12:30 ` [PATCH] env: Allow text-env tests to run with awk Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220313054749.599896-1-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=joe.hershberger@ni.com \
--cc=marek.behun@nic.cz \
--cc=patrick.delaunay@foss.st.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=wd@denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox