#include #include #include #include #include #include #include #include #include #include static void test_unmapped(void **state) { struct ftl_map map; int ret; (void)state; expect_value(__wrap_trace_path, map, &map); expect_value(__wrap_trace_path, new_page_desc, NULL); expect_value(__wrap_trace_path, page, NULL); expect_value(__wrap_trace_path, va, 42); will_return(__wrap_trace_path, NULL); will_return(__wrap_trace_path, 0); will_return(__wrap_trace_path, -1); ret = ftl_is_mapped(&map, 42); assert_int_equal(ret, 0); } static void test_mapped(void **state) { struct ftl_map map; int ret; (void)state; expect_value(__wrap_trace_path, map, &map); expect_value(__wrap_trace_path, new_page_desc, NULL); expect_value(__wrap_trace_path, page, NULL); expect_value(__wrap_trace_path, va, 42); will_return(__wrap_trace_path, NULL); will_return(__wrap_trace_path, 0); will_return(__wrap_trace_path, 0); ret = ftl_is_mapped(&map, 42); assert_int_equal(ret, 1); } int test_ftl_is_mapped(void) { const struct CMUnitTest tests[] = { { "ftl_is_mapped: unmapped", test_unmapped, NULL, NULL, NULL }, { "ftl_is_mapped: mapped", test_mapped, NULL, NULL, NULL }, }; return cmocka_run_group_tests_name("ftl_is_unmapped", tests, NULL, NULL); }