OpenVPN
test.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <stdlib.h>
4 #include <stdarg.h>
5 #include <string.h>
6 #include <setjmp.h>
7 #include <cmocka.h>
8 
9 static int
10 setup(void **state)
11 {
12  int *answer = malloc(sizeof(int));
13 
14  *answer = 42;
15  *state = answer;
16 
17  return 0;
18 }
19 
20 static int
21 teardown(void **state)
22 {
23  free(*state);
24 
25  return 0;
26 }
27 
28 static void
29 null_test_success(void **state)
30 {
31  (void) state;
32 }
33 
34 static void
35 int_test_success(void **state)
36 {
37  int *answer = *state;
38  assert_int_equal(*answer, 42);
39 }
40 
41 __attribute__((unused))
42 static void
43 failing_test(void **state)
44 {
45  /* This tests fails to test that make check fails */
46  assert_int_equal(0, 42);
47 }
48 
49 int
50 main(void)
51 {
52  const struct CMUnitTest tests[] = {
53  cmocka_unit_test(null_test_success),
54  cmocka_unit_test_setup_teardown(int_test_success, setup, teardown),
55 /* cmocka_unit_test(failing_test), */
56  };
57 
58  return cmocka_run_group_tests_name("success_test", tests, NULL, NULL);
59 }
teardown
static int teardown(void **state)
Definition: test.c:21
main
int main(void)
Definition: test.c:50
int_test_success
static void int_test_success(void **state)
Definition: test.c:35
setup
static int setup(void **state)
Definition: test.c:10
__attribute__
__attribute__((unused))
Definition: test.c:41
null_test_success
static void null_test_success(void **state)
Definition: test.c:29