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
42__attribute__((unused)) static void
43failing_test(void **state)
44{
45 /* This tests fails to test that make check fails */
46 assert_int_equal(0, 42);
47}
48
49int
50main(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}
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:50
static int setup(void **state)
Definition test.c:11