summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSean Anderson <sean.anderson@seco.com>2021-04-20 10:50:56 -0400
committerTom Rini <trini@konsulko.com>2021-05-04 07:57:18 -0400
commit4d65c6bcd71ab2a03a5b7fff0ecf22d068597b25 (patch)
treec316ea01cce93a65522e5a08bef090cb01a16e74 /test
parenteed0a7a3e6087d038fccea18676e285d9807b644 (diff)
downloadu-boot-4d65c6bcd71ab2a03a5b7fff0ecf22d068597b25.tar.gz
u-boot-4d65c6bcd71ab2a03a5b7fff0ecf22d068597b25.tar.xz
u-boot-4d65c6bcd71ab2a03a5b7fff0ecf22d068597b25.zip
sysinfo: Require that sysinfo_detect be called before other methods
This has the uclass enforce calling detect() before other methods. This allows drivers to cache information in detect() and perform (cheaper) retrieval in the other accessors. This also modifies the only instance where this sequencing was not followed. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/sysinfo.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/test/dm/sysinfo.c b/test/dm/sysinfo.c
index 4aaa9e85bc..96b3a8ebab 100644
--- a/test/dm/sysinfo.c
+++ b/test/dm/sysinfo.c
@@ -17,40 +17,45 @@
static int dm_test_sysinfo(struct unit_test_state *uts)
{
struct udevice *sysinfo;
- bool called_detect;
+ bool called_detect = false;
char str[64];
int i;
ut_assertok(sysinfo_get(&sysinfo));
ut_assert(sysinfo);
- sysinfo_get_bool(sysinfo, BOOL_CALLED_DETECT, &called_detect);
+ ut_asserteq(-EPERM, sysinfo_get_bool(sysinfo, BOOL_CALLED_DETECT,
+ &called_detect));
ut_assert(!called_detect);
sysinfo_detect(sysinfo);
- sysinfo_get_bool(sysinfo, BOOL_CALLED_DETECT, &called_detect);
+ ut_assertok(sysinfo_get_bool(sysinfo, BOOL_CALLED_DETECT,
+ &called_detect));
ut_assert(called_detect);
- sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str), str);
+ ut_assertok(sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str),
+ str));
ut_assertok(strcmp(str, "R'lyeh"));
- sysinfo_get_int(sysinfo, INT_TEST1, &i);
+ ut_assertok(sysinfo_get_int(sysinfo, INT_TEST1, &i));
ut_asserteq(0, i);
- sysinfo_get_int(sysinfo, INT_TEST2, &i);
+ ut_assertok(sysinfo_get_int(sysinfo, INT_TEST2, &i));
ut_asserteq(100, i);
- sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str), str);
+ ut_assertok(sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str),
+ str));
ut_assertok(strcmp(str, "Carcosa"));
- sysinfo_get_int(sysinfo, INT_TEST1, &i);
+ ut_assertok(sysinfo_get_int(sysinfo, INT_TEST1, &i));
ut_asserteq(1, i);
- sysinfo_get_int(sysinfo, INT_TEST2, &i);
+ ut_assertok(sysinfo_get_int(sysinfo, INT_TEST2, &i));
ut_asserteq(99, i);
- sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str), str);
+ ut_assertok(sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str),
+ str));
ut_assertok(strcmp(str, "Yuggoth"));
return 0;