diff options
| author | Tom Rini <[email protected]> | 2024-11-22 14:43:17 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2024-11-22 15:04:54 -0600 |
| commit | 52c0e5f8a39ef022ee5ab2dfd67661d1d34941c7 (patch) | |
| tree | ecb418b0233d67abb0e946128fc5f383c3caac5f /test | |
| parent | 35d5ad6cf25f8c0ac39f90a8a51eb77e6e002d0d (diff) | |
| parent | 0e3cd1313f031acd7e2e29b5742e625f842b52fa (diff) | |
Merge branch '2024-11-22-assorted-fixes'
- Assorted additional lwIP fixes
- Assorted test fixes
- Assorted other localized fixes
Diffstat (limited to 'test')
| -rw-r--r-- | test/boot/bootflow.c | 4 | ||||
| -rw-r--r-- | test/lib/str.c | 18 | ||||
| -rw-r--r-- | test/lib/time.c | 31 |
3 files changed, 44 insertions, 9 deletions
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 9397328609d..da713d8ed72 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1197,7 +1197,7 @@ static int bootflow_cros(struct unit_test_state *uts) return 0; } -BOOTSTD_TEST(bootflow_cros, UTF_CONSOLE); +BOOTSTD_TEST(bootflow_cros, UTF_CONSOLE | UTF_DM | UTF_SCAN_FDT); /* Test Android bootmeth */ static int bootflow_android(struct unit_test_state *uts) @@ -1220,7 +1220,7 @@ static int bootflow_android(struct unit_test_state *uts) return 0; } -BOOTSTD_TEST(bootflow_android, UTF_CONSOLE); +BOOTSTD_TEST(bootflow_android, UTF_CONSOLE | UTF_DM | UTF_SCAN_FDT); /* Test EFI bootmeth */ static int bootflow_efi(struct unit_test_state *uts) diff --git a/test/lib/str.c b/test/lib/str.c index 3cc9dfea6aa..e62045318c0 100644 --- a/test/lib/str.c +++ b/test/lib/str.c @@ -18,6 +18,8 @@ static const char str4[] = "1234567890123 I lost closer friends"; static const char str5[] = "0x9876543210the last time I was deloused"; static const char str6[] = "0778octal is seldom used"; static const char str7[] = "707it is a piece of computing history"; +static const char str8[] = "0x887e2561352d80fa"; +static const char str9[] = "614FF7EAA63009DA"; static int str_upper(struct unit_test_state *uts) { @@ -186,6 +188,22 @@ static int str_hextoul(struct unit_test_state *uts) } LIB_TEST(str_hextoul, 0); +static int str_hextoull(struct unit_test_state *uts) +{ + char *endp; + + /* Just a simple test, since we know this uses simple_strtoull() */ + ut_asserteq_64(0x887e2561352d80faULL, hextoull(str8, &endp)); + ut_asserteq_64(0x12, endp - str8); + ut_asserteq_64(0x614ff7eaa63009daULL, hextoull(str9, &endp)); + ut_asserteq_64(0x10, endp - str9); + ut_asserteq_64(0x887e2561352d80faULL, hextoull(str8, NULL)); + ut_asserteq_64(0x614ff7eaa63009daULL, hextoull(str9, NULL)); + + return 0; +} +LIB_TEST(str_hextoull, 0); + static int str_dectoul(struct unit_test_state *uts) { char *endp; diff --git a/test/lib/time.c b/test/lib/time.c index b99e738c500..2095bef7589 100644 --- a/test/lib/time.c +++ b/test/lib/time.c @@ -22,7 +22,11 @@ static int test_get_timer(struct unit_test_state *uts) next = get_timer(0); } while (start == next); - ut_asserteq(start + 1, next); + if (start + 1 != next) { + printf("%s: iter=%d, start=%lu, next=%lu, expected a difference of 1\n", + __func__, iter, start, next); + return -EINVAL; + } start++; } @@ -31,7 +35,11 @@ static int test_get_timer(struct unit_test_state *uts) * an extra millisecond may have passed. */ diff = get_timer(base); - ut_assert(diff == iter || diff == iter + 1); + if (diff != iter && diff != iter + 1) { + printf("%s: expected get_timer(base) to match elapsed time: diff=%lu, expected=%d\n", + __func__, diff, iter); + return -EINVAL; + } return 0; } @@ -49,8 +57,11 @@ static int test_timer_get_us(struct unit_test_state *uts) next = timer_get_us(); if (next != prev) { delta = next - prev; - ut_assert(delta >= 0); - if (delta) { + if (delta < 0) { + printf("%s: timer_get_us() went backwards from %lu to %lu\n", + __func__, prev, next); + return -EINVAL; + } else if (delta != 0) { if (delta < min) min = delta; prev = next; @@ -59,7 +70,11 @@ static int test_timer_get_us(struct unit_test_state *uts) } } - ut_asserteq(1, min); + if (min != 1) { + printf("%s: Minimum microsecond delta should be 1 but is %lu\n", + __func__, min); + return -EINVAL; + } return 0; } @@ -80,7 +95,8 @@ static int test_time_comparison(struct unit_test_state *uts) error = delta_us - 1000000; printf("%s: Microsecond time for 1 second: %lu, error = %ld\n", __func__, delta_us, error); - ut_assert(abs(error) <= 1000); + if (abs(error) > 1000) + return -EINVAL; return 0; } @@ -99,7 +115,8 @@ static int test_udelay(struct unit_test_state *uts) error = delta - 1000; printf("%s: Delay time for 1000 udelay(1000): %lu ms, error = %ld\n", __func__, delta, error); - ut_assert(abs(error) <= 100); + if (abs(error) > 100) + return -EINVAL; return 0; } |
