1 // SPDX-License-Identifier: GPL-2.0+
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
13 static int dm_test_misc(struct unit_test_state *uts)
21 ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "misc-test", &dev));
23 /* Read / write tests */
24 ut_asserteq(4, misc_write(dev, 0, "TEST", 4));
25 ut_asserteq(5, misc_write(dev, 4, "WRITE", 5));
26 ut_asserteq(9, misc_read(dev, 0, buf, 9));
28 ut_assertok(memcmp(buf, "TESTWRITE", 9));
33 ut_assertok(misc_call(dev, 0, &id, 4, buf, 16));
34 ut_assertok(memcmp(buf, "Zero", 4));
37 ut_assertok(misc_call(dev, 0, &id, 4, buf, 16));
38 ut_assertok(memcmp(buf, "Two", 3));
40 ut_assertok(misc_call(dev, 1, &id, 4, buf, 16));
41 ut_assertok(memcmp(buf, "Forty-two", 9));
44 ut_assertok(misc_call(dev, 1, &id, 4, buf, 16));
45 ut_assertok(memcmp(buf, "Forty-one", 9));
49 ut_assertok(misc_ioctl(dev, 6, NULL));
50 /* Read back last issued ioctl */
51 ut_assertok(misc_call(dev, 2, NULL, 0, &last_ioctl,
53 ut_asserteq(6, last_ioctl)
55 ut_assertok(misc_ioctl(dev, 23, NULL));
56 /* Read back last issued ioctl */
57 ut_assertok(misc_call(dev, 2, NULL, 0, &last_ioctl,
59 ut_asserteq(23, last_ioctl)
61 /* Enable / disable tests */
63 /* Read back enable/disable status */
64 ut_assertok(misc_call(dev, 3, NULL, 0, &enabled,
66 ut_asserteq(true, enabled);
68 ut_assertok(misc_set_enabled(dev, false));
69 /* Read back enable/disable status */
70 ut_assertok(misc_call(dev, 3, NULL, 0, &enabled,
72 ut_asserteq(false, enabled);
74 ut_assertok(misc_set_enabled(dev, true));
75 /* Read back enable/disable status */
76 ut_assertok(misc_call(dev, 3, NULL, 0, &enabled,
78 ut_asserteq(true, enabled);
83 DM_TEST(dm_test_misc, DM_TESTF_SCAN_FDT);