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  int *answer = malloc(sizeof(int));
12 
13  *answer = 42;
14  *state = answer;
15 
16  return 0;
17 }
18 
19 static int
20 teardown(void **state) {
21  free(*state);
22 
23  return 0;
24 }
25 
26 static void
27 null_test_success(void **state) {
28  (void) state;
29 }
30 
31 static void
32 int_test_success(void **state) {
33  int *answer = *state;
34  assert_int_equal(*answer, 42);
35 }
36 
37 static void
38 failing_test(void **state) {
39  /* This tests fails to test that make check fails */
40  assert_int_equal(0, 42);
41 }
42 
43 int
44 main(void) {
45  const struct CMUnitTest tests[] = {
48 /* cmocka_unit_test(failing_test), */
49  };
50 
51  return cmocka_run_group_tests_name("success_test", tests, NULL, NULL);
52 }
#define cmocka_unit_test(f)
Initializes a CMUnitTest structure.
Definition: cmocka.h:1653
static int teardown(void **state)
Definition: test.c:20
static void null_test_success(void **state)
Definition: test.c:27
static int setup(void **state)
Definition: test.c:10
#define cmocka_run_group_tests_name(group_name, group_tests, group_setup, group_teardown)
Definition: cmocka.h:1818
int main(void)
Definition: test.c:44
#define malloc
Definition: cmocka.c:1795
static void int_test_success(void **state)
Definition: test.c:32
#define cmocka_unit_test_setup_teardown(f, setup, teardown)
Initialize an array of CMUnitTest structures with a setup function for a test and a teardown function...
Definition: cmocka.h:1665
#define free
Definition: cmocka.c:1850
static void failing_test(void **state)
Definition: test.c:38
#define assert_int_equal(a, b)
Definition: cmocka.h:1174