tests: drivers: counter: fix skip tests check

When running this test with multiple counter instances enabled that
support different capabilities, if one of the instances does not
support the test required capabilities, the test will be
immediately skipped not giving the chance to run to the subsequent
instances.

Fix this by marking the test as skipped, only of all counter instances
under test were skipped.

Fixes #74358

Signed-off-by: Manuel Argüelles <marguelles.dev@gmail.com>
This commit is contained in:
Manuel Argüelles 2024-06-17 08:41:39 +07:00 committed by Anas Nashif
parent e491f220d8
commit 123f99c87b

View file

@ -183,6 +183,8 @@ static void counter_tear_down_instance(const struct device *dev)
static void test_all_instances(counter_test_func_t func,
counter_capability_func_t capability_check)
{
int devices_skipped = 0;
zassert_true(ARRAY_SIZE(devices) > 0, "No device found");
for (int i = 0; i < ARRAY_SIZE(devices); i++) {
counter_setup_instance(devices[i]);
@ -192,12 +194,15 @@ static void test_all_instances(counter_test_func_t func,
func(devices[i]);
} else {
TC_PRINT("Skipped for %s\n", devices[i]->name);
ztest_test_skip();
devices_skipped++;
}
counter_tear_down_instance(devices[i]);
/* Allow logs to be printed. */
k_sleep(K_MSEC(100));
}
if (devices_skipped == ARRAY_SIZE(devices)) {
ztest_test_skip();
}
}
static bool set_top_value_capable(const struct device *dev)