diff options
author | Jakub Hrozek <jakub.hrozek@posteo.se> | 2015-02-07 15:18:25 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2015-02-08 10:29:16 +0100 |
commit | 5ebe0830a1d025a148c25d474215dd6124524723 (patch) | |
tree | a793e2947a7cab1c156a5c654f00d9af9e663d3c /tests | |
parent | 5e8c5d90db2c55e203c11dbbec91c3e44bcb2023 (diff) | |
download | cmocka-5ebe0830a1d025a148c25d474215dd6124524723.tar.gz cmocka-5ebe0830a1d025a148c25d474215dd6124524723.tar.bz2 cmocka-5ebe0830a1d025a148c25d474215dd6124524723.zip |
tests: Add a test for failing group setup
Signed-off-by: Jakub Hrozek <jakub.hrozek@posteo.se>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 8 | ||||
-rw-r--r-- | tests/test_group_setup_fail.c | 34 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b95c96a..2525fe9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,6 +8,7 @@ include_directories( set(CMOCKA_TESTS test_alloc + test_group_setup_fail test_fixtures test_group_fixtures test_assert_macros @@ -45,6 +46,13 @@ set_tests_properties( 1 ) +set_tests_properties( + test_group_setup_fail + PROPERTIES + WILL_FAIL + 1 +) + add_test (test_setup_fail_1_failed test_setup_fail) set_tests_properties( test_setup_fail_1_failed diff --git a/tests/test_group_setup_fail.c b/tests/test_group_setup_fail.c new file mode 100644 index 0000000..7815c03 --- /dev/null +++ b/tests/test_group_setup_fail.c @@ -0,0 +1,34 @@ +/* Use the unit test allocators */ +#define UNIT_TESTING 1 + +#include <stdarg.h> +#include <stddef.h> +#include <setjmp.h> +#include <cmocka.h> + +static int group_setup_failing(void **state) +{ + (void) state; /* unused */ + return 1; /* To indicate the failure */ +} + +static void test_true(void **state) +{ + (void) state; /* unused */ + assert_true(1); +} + +static void test_false(void **state) +{ + (void) state; /* unused */ + assert_false(0); +} + +int main(void) { + const struct CMUnitTest tests[] = { + cmocka_unit_test(test_true), + cmocka_unit_test(test_false), + }; + + return cmocka_run_group_tests(tests, group_setup_failing, NULL); +} |