parent
5004fed4aa
commit
f3eb5df644
@ -0,0 +1,62 @@ |
||||
#include <stdarg.h> |
||||
#include <stddef.h> |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
#include <setjmp.h> |
||||
|
||||
#include <cmocka.h> |
||||
|
||||
#include <bitops.h> |
||||
#include <flash.h> |
||||
#include <ftl.h> |
||||
#include <macros.h> |
||||
|
||||
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); |
||||
} |
Loading…
Reference in new issue