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