From: Artem Lapkin <email2tema@gmail.com>
To: sjg@chromium.org
Cc: trini@konsulko.com, marek.behun@nic.cz, narmstrong@baylibre.com,
twarren@nvidia.com, andre.przywara@arm.com, u-boot@lists.denx.de,
u-boot-amlogic@groups.io, christianshewitt@gmail.com,
art@khadas.com, nick@khadas.com, gouwa@khadas.com
Subject: [PATCH v2 2/2] test: env: deep resolve value testing
Date: Fri, 19 Nov 2021 12:36:47 +0800 [thread overview]
Message-ID: <20211119043647.1251416-3-art@khadas.com> (raw)
In-Reply-To: <20211119043647.1251416-1-art@khadas.com>
Add new tests for `setenv -r` options (setup env variable with additional
resolving vars inside value).
test.py -k test_env
Signed-off-by: Artem Lapkin <art@khadas.com>
---
test/py/tests/test_env.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index 9bed2f48d7..a2f02f6f67 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -201,6 +201,30 @@ def test_env_unset_non_existent(state_test_env):
unset_var(state_test_env, var)
validate_empty(state_test_env, var)
+def test_env_resovle(state_test_env):
+ """Test deep resolve variable."""
+ c = state_test_env.u_boot_console
+ c.run_command("setenv a hello; setenv b world; setenv c '${a} ${b}'")
+ assert c.run_command('printenv a') == 'a=hello'
+ assert c.run_command('printenv b') == 'b=world'
+ assert c.run_command('printenv c') == 'c=${a} ${b}'
+ c.run_command("setenv d '${c}'")
+ assert c.run_command('printenv d') == 'd=${c}'
+ c.run_command("setenv -r e '${a} ${b} ${c}'")
+ assert c.run_command('printenv e') == 'e=hello world hello world'
+ c.run_command("setenv not_exist; setenv -r e '${not_exist}OK'")
+ assert c.run_command('printenv e') == 'e=OK'
+ c.run_command("setenv a 'A${b}'; setenv b 'B${a}'")
+ assert c.run_command('printenv a') == 'a=A${b}'
+ c.run_command("setenv e ''")
+ assert c.run_command('printenv e') == 'e='
+ c.run_command("setenv -r e '${b}'")
+ #assert c.run_command('printenv e') == 'e=BABABABABABABABABABABABABABABABAB${a}'
+ assert c.run_command('printenv e') != 'e='
+ c.run_command("setenv -r e")
+ with c.disable_check('error_notification'):
+ assert c.run_command('printenv e') == '## Error: "e" not defined'
+
def test_env_set_non_existent(state_test_env):
"""Test set a non-existant variable."""
--
2.25.1
next prev parent reply other threads:[~2021-11-19 4:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-19 4:36 [PATCH v2 0/2] env: setenv add resolve value option Artem Lapkin
2021-11-19 4:36 ` [PATCH v2 1/2] " Artem Lapkin
2021-11-25 0:13 ` Simon Glass
2022-04-07 18:05 ` Tom Rini
2022-04-08 13:09 ` Sean Anderson
2022-04-08 13:11 ` Tom Rini
2021-11-19 4:36 ` Artem Lapkin [this message]
2021-11-25 0:13 ` [PATCH v2 2/2] test: env: deep resolve value testing Simon Glass
2021-11-19 7:48 ` [PATCH v2 0/2] env: setenv add resolve value option Wolfgang Denk
2021-11-19 9:06 ` Art Nikpal
2021-11-20 12:36 ` Wolfgang Denk
2021-11-22 8:25 ` Art Nikpal
[not found] ` <6198ebca.1c69fb81.fc50c.bf0bSMTPIN_ADDED_BROKEN@mx.google.com>
2021-11-22 8:09 ` Art Nikpal
2021-11-22 8:51 ` Wolfgang Denk
2021-11-22 10:06 ` Art Nikpal
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=20211119043647.1251416-3-art@khadas.com \
--to=email2tema@gmail.com \
--cc=andre.przywara@arm.com \
--cc=art@khadas.com \
--cc=christianshewitt@gmail.com \
--cc=gouwa@khadas.com \
--cc=marek.behun@nic.cz \
--cc=narmstrong@baylibre.com \
--cc=nick@khadas.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=twarren@nvidia.com \
--cc=u-boot-amlogic@groups.io \
--cc=u-boot@lists.denx.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