Skip to content

Commit 5c422a9

Browse files
kartbenhenrikbrixandersen
authored andcommitted
tests: drivers: comparator: increase test coverage for await_trigger
Test user-provided timeout value Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
1 parent e564bab commit 5c422a9

File tree

1 file changed

+12
-0
lines changed
  • tests/drivers/comparator/shell/src

1 file changed

+12
-0
lines changed

tests/drivers/comparator/shell/src/test.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,25 @@ ZTEST(comparator_shell, test_await_trigger_timeout)
270270

271271
shell_backend_dummy_clear_output(test_sh);
272272
comp_fake_comp_set_trigger_callback_fake.custom_fake = test_set_trigger_callback_stub_0;
273+
/* Test default timeout (no timeout argument) */
273274
ret = shell_execute_cmd(test_sh, "comp await_trigger " FAKE_COMP_NAME);
274275
zassert_ok(ret);
275276
zassert_equal(comp_fake_comp_set_trigger_callback_fake.call_count, 2);
276277
zassert_equal(comp_fake_comp_set_trigger_callback_fake.return_val_history[0], 0);
277278
zassert_equal(comp_fake_comp_set_trigger_callback_fake.return_val_history[1], 0);
278279
out = shell_backend_dummy_get_output(test_sh, &out_size);
279280
zassert_str_equal(out, "\r\ntimed out\r\n");
281+
282+
shell_backend_dummy_clear_output(test_sh);
283+
comp_fake_comp_set_trigger_callback_fake.custom_fake = test_set_trigger_callback_stub_0;
284+
/* Test with provided timeout argument (2 seconds) */
285+
ret = shell_execute_cmd(test_sh, "comp await_trigger " FAKE_COMP_NAME " 2");
286+
zassert_ok(ret);
287+
zassert_equal(comp_fake_comp_set_trigger_callback_fake.call_count, 4);
288+
zassert_equal(comp_fake_comp_set_trigger_callback_fake.return_val_history[2], 0);
289+
zassert_equal(comp_fake_comp_set_trigger_callback_fake.return_val_history[3], 0);
290+
out = shell_backend_dummy_get_output(test_sh, &out_size);
291+
zassert_str_equal(out, "\r\ntimed out\r\n");
280292
}
281293

282294
ZTEST(comparator_shell, test_await_trigger_invalid_timeout_arg)

0 commit comments

Comments
 (0)