#include #include #include #include #include #include #include #include #include #include int next_upage(struct ftl_map *map, uint32_t p); static void test_next_upage1(void **state) { struct ftl_map map; uint32_t ret; (void)state; map.log2_pages_per_group = ilog2(16); map.log2_groups_per_block = ilog2(1); map.nblocks = 4; ret = next_upage(&map, 0); assert_int_equal(ret, 1); } static void test_next_upage2(void **state) { struct ftl_map map; uint32_t ret; (void)state; map.log2_pages_per_group = ilog2(16); map.log2_groups_per_block = ilog2(1); map.nblocks = 4; ret = next_upage(&map, 14); assert_int_equal(ret, 16); } static void test_next_upage3(void **state) { struct ftl_map map; uint32_t ret; (void)state; map.log2_pages_per_group = ilog2(16); map.log2_groups_per_block = ilog2(1); map.nblocks = 4; ret = next_upage(&map, 15); assert_int_equal(ret, 16); } static void test_next_upage4(void **state) { struct ftl_map map; uint32_t ret; (void)state; map.log2_pages_per_group = ilog2(16); map.log2_groups_per_block = ilog2(1); map.nblocks = 4; ret = next_upage(&map, 16); assert_int_equal(ret, 17); } static void test_next_upage5(void **state) { struct ftl_map map; uint32_t ret; (void)state; map.log2_pages_per_group = ilog2(16); map.log2_groups_per_block = ilog2(1); map.nblocks = 4; ret = next_upage(&map, 62); assert_int_equal(ret, 0); } static void test_next_upage6(void **state) { struct ftl_map map; uint32_t ret; (void)state; map.log2_pages_per_group = ilog2(16); map.log2_groups_per_block = ilog2(1); map.nblocks = 4; ret = next_upage(&map, 63); assert_int_equal(ret, 0); } int test_next_upage(void) { const struct CMUnitTest tests[] = { cmocka_unit_test(test_next_upage1), cmocka_unit_test(test_next_upage2), cmocka_unit_test(test_next_upage3), cmocka_unit_test(test_next_upage4), cmocka_unit_test(test_next_upage5), cmocka_unit_test(test_next_upage6), }; return cmocka_run_group_tests_name("next_upage", tests, NULL, NULL); }