@@ -93,6 +93,7 @@
<&gpio_b 9 0xc 3 2 1>;
int-value = <1234>;
uint-value = <(-1234)>;
+ int64-value = /bits/ 64 <0x1111222233334444>;
interrupts-extended = <&irq 3 0>;
};
@@ -104,6 +104,22 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
} \
}
+/* Assert that two 64 int expressions are equal */
+#define ut_asserteq_64(expr1, expr2) { \
+ u64 _val1 = (expr1), _val2 = (expr2); \
+ \
+ if (_val1 != _val2) { \
+ ut_failf(uts, __FILE__, __LINE__, __func__, \
+ #expr1 " == " #expr2, \
+ "Expected %#llx (%lld), got %#llx (%lld)", \
+ (unsigned long long)_val1, \
+ (unsigned long long)_val1, \
+ (unsigned long long)_val2, \
+ (unsigned long long)_val2); \
+ return CMD_RET_FAILURE; \
+ } \
+}
+
/* Assert that two string expressions are equal */
#define ut_asserteq_str(expr1, expr2) { \
const char *_val1 = (expr1), *_val2 = (expr2); \
@@ -867,6 +867,7 @@ static int dm_test_read_int(struct unit_test_state *uts)
u32 val32;
s32 sval;
uint val;
+ u64 val64;
ut_assertok(uclass_first_device_err(UCLASS_TEST_FDT, &dev));
ut_asserteq_str("a-test", dev->name);
@@ -891,6 +892,15 @@ static int dm_test_read_int(struct unit_test_state *uts)
ut_assertok(dev_read_u32u(dev, "uint-value", &val));
ut_asserteq(-1234, val);
+ ut_assertok(dev_read_u64(dev, "int64-value", &val64));
+ ut_asserteq_64(0x1111222233334444, val64);
+
+ ut_asserteq_64(-EINVAL, dev_read_u64(dev, "missing", &val64));
+ ut_asserteq_64(6, dev_read_u64_default(dev, "missing", 6));
+
+ ut_asserteq_64(0x1111222233334444,
+ dev_read_u64_default(dev, "int64-value", 6));
+
return 0;
}
DM_TEST(dm_test_read_int, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
Add test case to cover dev_read_u64 and dev_read_u64_default functions. Signed-off-by: Dario Binacchi <dariobin at libero.it> --- arch/sandbox/dts/test.dts | 1 + include/test/ut.h | 16 ++++++++++++++++ test/dm/test-fdt.c | 10 ++++++++++ 3 files changed, 27 insertions(+)