diff options
| author | Heinrich Schuchardt <[email protected]> | 2025-02-03 16:10:29 +0100 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-02-07 13:35:23 -0600 |
| commit | af7eca24a78b1419656d618463f1eabe297fdb2f (patch) | |
| tree | 7b12ea285a455fdbd417c1fa1aea062a65fde2f4 /test/cmd | |
| parent | d4265cdcd57c1975d4e756ab1778c837acc9776c (diff) | |
cmd/setexpr: support concatenation of direct strings
The setexpr.s command allows to concatenate two strings.
According to the description in doc/usage/cmd/setexpr.rst the parameters
value1 and value2 can be either direct values or pointers to a
memory location holding the values.
Unfortunately `setexpr.s <value1> + <value2>` fails if any of the values
is a direct value. $? is set to false.
* Add support for direct values in setexpr.s.
* Correct the unit test for "setexpr.s fred 0".
* Add a new unit test for "setexpr.s fred '1' + '3'" giving '13'.
Signed-off-by: Heinrich Schuchardt <[email protected]>
Diffstat (limited to 'test/cmd')
| -rw-r--r-- | test/cmd/setexpr.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index 650fbc8ebee..5e9b577fe36 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -303,7 +303,8 @@ static int setexpr_test_str(struct unit_test_state *uts) memset(buf, '\xff', BUF_SIZE); ut_assertok(env_set("fred", "x")); - ut_asserteq(1, run_command("setexpr.s fred 0", 0)); + ut_asserteq(0, run_command("setexpr.s fred 0", 0)); + ut_asserteq_str("0", env_get("fred")); strcpy(buf, "hello"); ut_assertok(env_set("fred", "12345")); @@ -321,6 +322,10 @@ static int setexpr_test_str_oper(struct unit_test_state *uts) { char *buf; + /* Test concatenation of strings */ + ut_assertok(run_command("setexpr.s fred '1' + '3'", 0)); + ut_asserteq_str("13", env_get("fred")); + buf = map_sysmem(0, BUF_SIZE); memset(buf, '\xff', BUF_SIZE); strcpy(buf, "hello"); |
