]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/tests/unit/tests/ocf_freelist.c/ocf_freelist_init.c
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / ocf / tests / unit / tests / ocf_freelist.c / ocf_freelist_init.c
1 /*
2 * <tested_file_path>src/ocf_freelist.c</tested_file_path>
3 * <tested_function>ocf_freelist_populate</tested_function>
4 * <functions_to_leave>
5 * ocf_freelist_init
6 * ocf_freelist_deinit
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 "ocf/ocf.h"
22 #include "metadata/metadata.h"
23
24 #include "ocf_freelist.c/ocf_freelist_init_generated_wraps.c"
25
26 ocf_cache_line_t __wrap_ocf_metadata_collision_table_entries(ocf_cache_t cache)
27 {
28 function_called();
29 return mock();
30 }
31
32 ocf_cache_line_t __wrap_env_get_execution_context_count(ocf_cache_t cache)
33 {
34 function_called();
35 return mock();
36 }
37
38 static void ocf_freelist_init_test01(void **state)
39 {
40 unsigned num_cls = 9;
41 unsigned num_ctxts = 3;
42 ocf_freelist_t freelist;
43 ocf_cache_t cache = 0x1234;
44
45 print_test_description("Freelist initialization test");
46
47 expect_function_call(__wrap_ocf_metadata_collision_table_entries);
48 will_return(__wrap_ocf_metadata_collision_table_entries, num_cls);
49
50 expect_function_call(__wrap_env_get_execution_context_count);
51 will_return(__wrap_env_get_execution_context_count, num_ctxts);
52
53 freelist = ocf_freelist_init(cache);
54 assert(freelist != NULL);
55
56 ocf_freelist_deinit(freelist);
57 }
58
59 int main(void)
60 {
61 const struct CMUnitTest tests[] = {
62 cmocka_unit_test(ocf_freelist_init_test01)
63 };
64
65 print_message("Unit test of ocf_freelist_init\n");
66
67 return cmocka_run_group_tests(tests, NULL, NULL);
68 }