]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /* |
2 | * <tested_file_path>src/utils/utils_refcnt.c</tested_file_path> | |
3 | * <tested_function>ocf_refcnt_inc</tested_function> | |
4 | * <functions_to_leave> | |
5 | * ocf_refcnt_init | |
6 | * ocf_refcnt_dec | |
7 | * </functions_to_leave> | |
8 | */ | |
9 | ||
10 | #undef static | |
11 | ||
12 | #undef inline | |
13 | ||
14 | ||
15 | #include <stdarg.h> | |
16 | #include <stddef.h> | |
17 | #include <setjmp.h> | |
18 | #include <cmocka.h> | |
19 | #include "print_desc.h" | |
20 | ||
21 | #include "../utils/utils_refcnt.h" | |
22 | ||
23 | #include "utils/utils_refcnt.c/utils_refcnt_inc_generated_wraps.c" | |
24 | ||
25 | static void ocf_refcnt_inc_test(void **state) | |
26 | { | |
27 | struct ocf_refcnt rc; | |
28 | int val; | |
29 | ||
30 | print_test_description("Increment adds 1 and returns proper value"); | |
31 | ||
32 | ocf_refcnt_init(&rc); | |
33 | ||
34 | val = ocf_refcnt_inc(&rc); | |
35 | assert_int_equal(1, val); | |
36 | assert_int_equal(1, env_atomic_read(&rc.counter)); | |
37 | ||
38 | val = ocf_refcnt_inc(&rc); | |
39 | assert_int_equal(2, val); | |
40 | assert_int_equal(2, env_atomic_read(&rc.counter)); | |
41 | } | |
42 | ||
43 | int main(void) | |
44 | { | |
45 | const struct CMUnitTest tests[] = { | |
46 | cmocka_unit_test(ocf_refcnt_inc_test) | |
47 | }; | |
48 | ||
49 | print_message("Unit test of src/utils/utils_refcnt.c"); | |
50 | ||
51 | return cmocka_run_group_tests(tests, NULL, NULL); | |
52 | } |