2020-11-05 13:32:05 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* (C) Copyright 2018
|
|
|
|
* Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <log.h>
|
|
|
|
#include <dm/test.h>
|
|
|
|
#include <sysinfo.h>
|
|
|
|
#include <test/test.h>
|
|
|
|
#include <test/ut.h>
|
|
|
|
|
|
|
|
#include "../../drivers/sysinfo/sandbox.h"
|
|
|
|
|
|
|
|
static int dm_test_sysinfo(struct unit_test_state *uts)
|
|
|
|
{
|
|
|
|
struct udevice *sysinfo;
|
2021-04-20 14:50:56 +00:00
|
|
|
bool called_detect = false;
|
2020-11-05 13:32:05 +00:00
|
|
|
char str[64];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
ut_assertok(sysinfo_get(&sysinfo));
|
|
|
|
ut_assert(sysinfo);
|
|
|
|
|
2021-04-20 14:50:56 +00:00
|
|
|
ut_asserteq(-EPERM, sysinfo_get_bool(sysinfo, BOOL_CALLED_DETECT,
|
|
|
|
&called_detect));
|
2020-11-05 13:32:05 +00:00
|
|
|
ut_assert(!called_detect);
|
|
|
|
|
|
|
|
sysinfo_detect(sysinfo);
|
|
|
|
|
2021-04-20 14:50:56 +00:00
|
|
|
ut_assertok(sysinfo_get_bool(sysinfo, BOOL_CALLED_DETECT,
|
|
|
|
&called_detect));
|
2020-11-05 13:32:05 +00:00
|
|
|
ut_assert(called_detect);
|
|
|
|
|
2021-04-20 14:50:56 +00:00
|
|
|
ut_assertok(sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str),
|
|
|
|
str));
|
2020-11-05 13:32:05 +00:00
|
|
|
ut_assertok(strcmp(str, "R'lyeh"));
|
|
|
|
|
2021-04-20 14:50:56 +00:00
|
|
|
ut_assertok(sysinfo_get_int(sysinfo, INT_TEST1, &i));
|
2020-11-05 13:32:05 +00:00
|
|
|
ut_asserteq(0, i);
|
|
|
|
|
2021-04-20 14:50:56 +00:00
|
|
|
ut_assertok(sysinfo_get_int(sysinfo, INT_TEST2, &i));
|
2020-11-05 13:32:05 +00:00
|
|
|
ut_asserteq(100, i);
|
|
|
|
|
2021-04-20 14:50:56 +00:00
|
|
|
ut_assertok(sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str),
|
|
|
|
str));
|
2020-11-05 13:32:05 +00:00
|
|
|
ut_assertok(strcmp(str, "Carcosa"));
|
|
|
|
|
2021-04-20 14:50:56 +00:00
|
|
|
ut_assertok(sysinfo_get_int(sysinfo, INT_TEST1, &i));
|
2020-11-05 13:32:05 +00:00
|
|
|
ut_asserteq(1, i);
|
|
|
|
|
2021-04-20 14:50:56 +00:00
|
|
|
ut_assertok(sysinfo_get_int(sysinfo, INT_TEST2, &i));
|
2020-11-05 13:32:05 +00:00
|
|
|
ut_asserteq(99, i);
|
|
|
|
|
2021-04-20 14:50:56 +00:00
|
|
|
ut_assertok(sysinfo_get_str(sysinfo, STR_VACATIONSPOT, sizeof(str),
|
|
|
|
str));
|
2020-11-05 13:32:05 +00:00
|
|
|
ut_assertok(strcmp(str, "Yuggoth"));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DM_TEST(dm_test_sysinfo, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
|