diff options
author | Simon Glass <sjg@chromium.org> | 2020-11-01 14:15:37 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-12-01 10:33:38 -0500 |
commit | 25a43ac84a9509b8ccd093808bb39b71e4438cf5 (patch) | |
tree | 491181cd84bae451bafd6215014cbf722745e28f /test/cmd | |
parent | 7526deec7e52da92dee25aaf3a47514e639c2bb0 (diff) | |
download | u-boot-25a43ac84a9509b8ccd093808bb39b71e4438cf5.tar.gz |
setexpr: Add explicit support for 32- and 64-bit ints
At present this function assumes that a size of 4 refers to a ulong. This
is true on 32-bit machines but not commonly on 64-bit machines.
This means that the 'l' specify does not work correctly with setexpr.
Add an explicit case for 32-bit values so that 64-bit machines can still
use the 'l' specifier. On 32-bit machines, 64-bit is still not supported.
This corrects the operation of the default size (which is 4 for setexpr),
so update the tests accordingly.
The original code for reading from memory was included in 47ab5ad1457
("cmd_setexpr: allow memory addresses in expressions") but I am not adding
a Fixes: tag since that code was not written with 64-bit machines in mind.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/cmd')
-rw-r--r-- | test/cmd/setexpr.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index cab6fdf4b83..e950c380ce0 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -45,7 +45,7 @@ static int setexpr_test_int(struct unit_test_state *uts) ut_assertok(run_command("setexpr.l fred 0", 0)); ut_asserteq_str("0", env_get("fred")); ut_assertok(run_command("setexpr.l fred *0", 0)); - ut_asserteq_str("ffffffff3456789a", env_get("fred")); + ut_asserteq_str("3456789a", env_get("fred")); /* 64-bit */ *(u64 *)buf = 0x456789abcdef0123; @@ -58,7 +58,7 @@ static int setexpr_test_int(struct unit_test_state *uts) ut_assertok(run_command("setexpr fred 0", 0)); ut_asserteq_str("0", env_get("fred")); ut_assertok(run_command("setexpr fred *0", 0)); - ut_asserteq_str("456789abcdef0123", env_get("fred")); + ut_asserteq_str("cdef0123", env_get("fred")); unmap_sysmem(buf); @@ -90,7 +90,7 @@ static int setexpr_test_plus(struct unit_test_state *uts) *(u32 *)buf = 0x3456789a; *(u32 *)(buf + 0x10) = 0xc3384235; ut_assertok(run_command("setexpr.l fred *0 + *10", 0)); - ut_asserteq_str("fffffffef78ebacf", env_get("fred")); + ut_asserteq_str("f78ebacf", env_get("fred")); /* 64-bit */ *(u64 *)buf = 0x456789abcdef0123; @@ -100,7 +100,7 @@ static int setexpr_test_plus(struct unit_test_state *uts) /* default */ ut_assertok(run_command("setexpr fred *0 + *10", 0)); - ut_asserteq_str("8eeebc2f407393a6", env_get("fred")); + ut_asserteq_str("1407393a6", env_get("fred")); unmap_sysmem(buf); @@ -121,14 +121,14 @@ static int setexpr_test_oper(struct unit_test_state *uts) /* Quote | to avoid confusing hush */ ut_assertok(run_command("setexpr fred *0 \"|\" *10", 0)); - ut_asserteq_str("ffffffff00561234", env_get("fred")); + ut_asserteq_str("561234", env_get("fred")); *(u32 *)buf = 0x561200; *(u32 *)(buf + 0x10) = 0x1234; /* Quote & to avoid confusing hush */ ut_assertok(run_command("setexpr.l fred *0 \"&\" *10", 0)); - ut_asserteq_str("ffffffff00001200", env_get("fred")); + ut_asserteq_str("1200", env_get("fred")); ut_assertok(run_command("setexpr.l fred *0 ^ *10", 0)); ut_asserteq_str("560034", env_get("fred")); @@ -137,13 +137,13 @@ static int setexpr_test_oper(struct unit_test_state *uts) ut_asserteq_str("55ffcc", env_get("fred")); ut_assertok(run_command("setexpr.l fred *0 * *10", 0)); - ut_asserteq_str("ffa9dbd21ebfa800", env_get("fred")); + ut_asserteq_str("61ebfa800", env_get("fred")); ut_assertok(run_command("setexpr.l fred *0 / *10", 0)); - ut_asserteq_str("1", env_get("fred")); + ut_asserteq_str("4ba", env_get("fred")); ut_assertok(run_command("setexpr.l fred *0 % *10", 0)); - ut_asserteq_str("55ffcc", env_get("fred")); + ut_asserteq_str("838", env_get("fred")); unmap_sysmem(buf); |