Skip to content

Commit dd594d5

Browse files
JarmouniAdanieldegrasse
authored andcommitted
tests: kernel: device: expand device api coverage
Enhance device z_device_get_all_static API test Signed-off-by: Abderrahmane JARMOUNI <git@jarmouni.me>
1 parent ddbc7ef commit dd594d5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/kernel/device/src/main.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,19 @@ ZTEST(device, test_device_list)
258258
{
259259
struct device const *devices;
260260
size_t devcount = z_device_get_all_static(&devices);
261+
bool found = false;
261262

262-
zassert_false((devcount == 0));
263+
zassert_true(devcount > 0, "Should have at least one static device");
264+
zassert_not_null(devices);
265+
for (size_t i = 0; i < devcount; i++) {
266+
struct device const *dev = devices + i;
267+
268+
if (strcmp(dev->name, DUMMY_NOINIT) == 0) {
269+
found = true;
270+
break;
271+
}
272+
}
273+
zassert_true(found, "%s should be present in static device list", DUMMY_NOINIT);
263274
}
264275

265276
static int sys_init_counter;

0 commit comments

Comments
 (0)