OpenVPN
test_assert_macros_fail.c
Go to the documentation of this file.
1 #include "config.h"
2 
3 #include <stdarg.h>
4 #include <stddef.h>
5 #include <setjmp.h>
6 #include <cmocka.h>
7 #include <cmocka_private.h>
8 
9 #include <errno.h>
10 #include <sys/types.h>
11 #include <sys/stat.h>
12 #ifdef HAVE_UNISTD_H
13 #include <unistd.h>
14 #endif
15 #ifdef HAVE_IO_H
16 #include <io.h>
17 #endif
18 #include <fcntl.h>
19 
20 /**************************************
21  *** assert_return_code
22  **************************************/
23 static void test_assert_return_code_fail(void **state)
24 {
25  int fd;
26 
27  (void)state; /* unused */
28 
29  fd = open("this_file_doesnt_exist.cmocka", 0);
30  assert_return_code(fd, errno);
31 
32  if (fd >= 0) {
33  close(fd);
34  }
35 }
36 
37 int main(void) {
38  const struct CMUnitTest tests[] = {
40  };
41 
42  return cmocka_run_group_tests(tests, NULL, NULL);
43 }
#define cmocka_unit_test(f)
Initializes a CMUnitTest structure.
Definition: cmocka.h:1653
#define assert_return_code(rc, error)
Definition: cmocka.h:1082
static void test_assert_return_code_fail(void **state)
#define cmocka_run_group_tests(group_tests, group_setup, group_teardown)
Definition: cmocka.h:1749
int main(void)