tests: Use new cmocka test runner in our tests and examples
[platform/upstream/cmocka.git] / tests / test_assert_macros_fail.c
1 #include <stdarg.h>
2 #include <stddef.h>
3 #include <setjmp.h>
4 #include <cmocka.h>
5
6 #include <errno.h>
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <unistd.h>
10 #include <fcntl.h>
11
12 /**************************************
13  *** assert_return_code
14  **************************************/
15 static void test_assert_return_code_fail(void **state)
16 {
17     int fd;
18
19     (void)state; /* unused */
20
21     fd = open("this_file_doesnt_exist.cmocka", 0);
22     assert_return_code(fd, errno);
23
24     if (fd >= 0) {
25         close(fd);
26     }
27 }
28
29 int main(void) {
30     const struct CMUnitTest tests[] = {
31         cmocka_unit_test(test_assert_return_code_fail),
32     };
33
34     return cmocka_run_group_tests(tests, NULL, NULL);
35 }