Source code for the Trusted Boot Module.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
tbm-mcu/source/tests/ftl/ftl_is_mapped.c

62 lines
1.3 KiB

#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);
}