From 03f169d15fad9c8090024d81bb00374b9b0c39dd Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 3 Jan 2023 14:47:46 -0600 Subject: [PATCH] Bugfix: The f_signal unit tests after significant change. The bugfix from commit 4dfc152aad390be408cb9a20578b337b2a13d993 didn't include checking and updating the unit tests. --- level_0/f_signal/tests/unit/c/test-signal-close.c | 17 ++++++++++++++++- level_0/f_signal/tests/unit/c/test-signal-close.h | 7 +++++++ level_0/f_signal/tests/unit/c/test-signal.c | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/level_0/f_signal/tests/unit/c/test-signal-close.c b/level_0/f_signal/tests/unit/c/test-signal-close.c index 910b457..4ce6745 100644 --- a/level_0/f_signal/tests/unit/c/test-signal-close.c +++ b/level_0/f_signal/tests/unit/c/test-signal-close.c @@ -27,6 +27,8 @@ void test__f_signal_close__fails(void **state) { F_failure, }; + signal.id = 0; + for (int i = 0; i < 6; ++i) { will_return(__wrap_close, true); @@ -47,12 +49,25 @@ void test__f_signal_close__parameter_checking(void **state) { } } +void test__f_signal_close__returns_data_not(void **state) { + + f_signal_t signal = f_signal_t_initialize; + + { + const f_status_t status = f_signal_close(&signal); + + assert_int_equal(status, F_data_not); + } +} + void test__f_signal_close__works(void **state) { f_signal_t signal = f_signal_t_initialize; + signal.id = 0; + { - will_return(__wrap_close, false); + will_return(__wrap_close, 0); const f_status_t status = f_signal_close(&signal); diff --git a/level_0/f_signal/tests/unit/c/test-signal-close.h b/level_0/f_signal/tests/unit/c/test-signal-close.h index 0dcf1c7..68acfce 100644 --- a/level_0/f_signal/tests/unit/c/test-signal-close.h +++ b/level_0/f_signal/tests/unit/c/test-signal-close.h @@ -25,6 +25,13 @@ extern void test__f_signal_close__fails(void **state); extern void test__f_signal_close__parameter_checking(void **state); /** + * Test that function works but returns F_data_not when file descriptor is -1. + * + * @see f_signal_close() + */ +extern void test__f_signal_close__returns_data_not(void **state); + +/** * Test that function works. * * @see f_signal_close() diff --git a/level_0/f_signal/tests/unit/c/test-signal.c b/level_0/f_signal/tests/unit/c/test-signal.c index 6e61a62..dd7dc8d 100644 --- a/level_0/f_signal/tests/unit/c/test-signal.c +++ b/level_0/f_signal/tests/unit/c/test-signal.c @@ -23,6 +23,7 @@ int main(void) { cmocka_unit_test(test__f_signal_action__works), cmocka_unit_test(test__f_signal_close__fails), + cmocka_unit_test(test__f_signal_close__returns_data_not), cmocka_unit_test(test__f_signal_close__works), cmocka_unit_test(test__f_signal_mask__fails), -- 1.8.3.1