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/find_block_div.c

70 lines
1.4 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>
int find_block_div(struct ftl_map *map);
static void test_find_block_div1(void **state)
{
struct ftl_map map;
(void)state;
map.log2_block_size = ilog2(64 * KIB);
map.log2_page_size = ilog2(4 * KIB);
find_block_div(&map);
assert_int_equal(1 << map.log2_pages_per_group, 16);
assert_int_equal(1 << map.log2_groups_per_block, 1);
}
static void test_find_block_div2(void **state)
{
struct ftl_map map;
(void)state;
map.log2_block_size = ilog2(16 * KIB);
map.log2_page_size = ilog2(4 * KIB);
find_block_div(&map);
assert_int_equal(1 << map.log2_pages_per_group, 4);
assert_int_equal(1 << map.log2_groups_per_block, 1);
}
static void test_find_block_div3(void **state)
{
struct ftl_map map;
(void)state;
map.log2_block_size = ilog2(64 * KIB);
map.log2_page_size = ilog2(1 * KIB);
find_block_div(&map);
assert_int_equal(1 << map.log2_pages_per_group, 8);
assert_int_equal(1 << map.log2_groups_per_block, 8);
}
int test_find_block_div(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_find_block_div1),
cmocka_unit_test(test_find_block_div2),
cmocka_unit_test(test_find_block_div3),
};
return cmocka_run_group_tests_name("find_block_div", tests, NULL, NULL);
}