OpenVPN
tests
unit_tests
example_test
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
10
static
int
11
setup
(
void
**state)
12
{
13
int
*answer = malloc(
sizeof
(
int
));
14
15
*answer = 42;
16
*state = answer;
17
18
return
0;
19
}
20
21
static
int
22
teardown
(
void
**state)
23
{
24
free(*state);
25
26
return
0;
27
}
28
29
static
void
30
null_test_success
(
void
**state)
31
{
32
(void)state;
33
}
34
35
static
void
36
int_test_success
(
void
**state)
37
{
38
int
*answer = *state;
39
assert_int_equal(*answer, 42);
40
}
41
42
__attribute__
((unused))
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:22
__attribute__
__attribute__((unused))
Definition
test.c:42
int_test_success
static void int_test_success(void **state)
Definition
test.c:36
null_test_success
static void null_test_success(void **state)
Definition
test.c:30
main
int main(void)
Definition
test.c:50
setup
static int setup(void **state)
Definition
test.c:11
Generated by
1.9.8