From 1153f2bdcd59e124260da317dd30a19c67701c08 Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Wed, 20 Sep 2017 14:56:07 +0200 Subject: [PATCH] test: ftl: improve descriptions for the test cases --- source/tests/ftl/find_block_div.c | 12 ++++++------ source/tests/ftl/next_upage.c | 25 ++++++++++++------------- source/tests/ftl/read_page_desc.c | 28 ++++++++++++++-------------- source/tests/ftl/write_page_desc.c | 20 ++++++++++---------- 4 files changed, 42 insertions(+), 43 deletions(-) diff --git a/source/tests/ftl/find_block_div.c b/source/tests/ftl/find_block_div.c index d753121..0c0bdd2 100644 --- a/source/tests/ftl/find_block_div.c +++ b/source/tests/ftl/find_block_div.c @@ -13,7 +13,7 @@ int find_block_div(struct ftl_map *map); -static void test_find_block_div1(void **state) +static void test_4k_page_64k_block(void **state) { struct ftl_map map; @@ -28,7 +28,7 @@ static void test_find_block_div1(void **state) assert_int_equal(1 << map.log2_groups_per_block, 1); } -static void test_find_block_div2(void **state) +static void test_4k_page_16k_block(void **state) { struct ftl_map map; @@ -43,7 +43,7 @@ static void test_find_block_div2(void **state) assert_int_equal(1 << map.log2_groups_per_block, 1); } -static void test_find_block_div3(void **state) +static void test_1k_page_64k_block(void **state) { struct ftl_map map; @@ -61,9 +61,9 @@ static void test_find_block_div3(void **state) 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), + { "find_block_div: 4K page, 64K block", test_4k_page_64k_block, NULL, NULL, NULL }, + { "find_block_div: 4K page, 16K block", test_4k_page_16k_block, NULL, NULL, NULL }, + { "find_block_div: 1K page, 64K block", test_1k_page_64k_block, NULL, NULL, NULL }, }; return cmocka_run_group_tests_name("find_block_div", tests, NULL, NULL); diff --git a/source/tests/ftl/next_upage.c b/source/tests/ftl/next_upage.c index 2a9029c..1fe12d9 100644 --- a/source/tests/ftl/next_upage.c +++ b/source/tests/ftl/next_upage.c @@ -13,7 +13,7 @@ int next_upage(struct ftl_map *map, uint32_t p); -static void test_next_upage1(void **state) +static void test_upage0(void **state) { struct ftl_map map; uint32_t ret; @@ -29,7 +29,7 @@ static void test_next_upage1(void **state) assert_int_equal(ret, 1); } -static void test_next_upage2(void **state) +static void test_upage14(void **state) { struct ftl_map map; uint32_t ret; @@ -45,7 +45,7 @@ static void test_next_upage2(void **state) assert_int_equal(ret, 16); } -static void test_next_upage3(void **state) +static void test_upage15(void **state) { struct ftl_map map; uint32_t ret; @@ -61,7 +61,7 @@ static void test_next_upage3(void **state) assert_int_equal(ret, 16); } -static void test_next_upage4(void **state) +static void test_upage16(void **state) { struct ftl_map map; uint32_t ret; @@ -77,7 +77,7 @@ static void test_next_upage4(void **state) assert_int_equal(ret, 17); } -static void test_next_upage5(void **state) +static void test_upage62(void **state) { struct ftl_map map; uint32_t ret; @@ -93,7 +93,7 @@ static void test_next_upage5(void **state) assert_int_equal(ret, 0); } -static void test_next_upage6(void **state) +static void test_upage63(void **state) { struct ftl_map map; uint32_t ret; @@ -112,13 +112,12 @@ static void test_next_upage6(void **state) 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), - + { "next_upage: upage=0", test_upage0, NULL, NULL, NULL }, + { "next_upage: upage=14", test_upage14, NULL, NULL, NULL }, + { "next_upage: upage=15", test_upage15, NULL, NULL, NULL }, + { "next_upage: upage=16", test_upage16, NULL, NULL, NULL }, + { "next_upage: upage=62 (wraparound)", test_upage62, NULL, NULL, NULL }, + { "next_upage: upage=63 (wraparound)", test_upage63, NULL, NULL, NULL }, }; return cmocka_run_group_tests_name("next_upage", tests, NULL, NULL); diff --git a/source/tests/ftl/read_page_desc.c b/source/tests/ftl/read_page_desc.c index d1e8c7c..337bf53 100644 --- a/source/tests/ftl/read_page_desc.c +++ b/source/tests/ftl/read_page_desc.c @@ -14,7 +14,7 @@ int read_page_desc(struct ftl_map *map, struct ftl_page_desc *page_desc, uint32_t upage); -static void test_read_page_desc1(void **state) +static void test_upage0(void **state) { struct ftl_map map; struct ftl_page_desc page_desc, ret_page_desc; @@ -38,7 +38,7 @@ static void test_read_page_desc1(void **state) assert_int_equal(ret, 0); } -static void test_read_page_desc2(void **state) +static void test_upage14(void **state) { struct ftl_map map; struct ftl_page_desc page_desc, ret_page_desc; @@ -62,7 +62,7 @@ static void test_read_page_desc2(void **state) assert_int_equal(ret, 0); } -static void test_read_page_desc3(void **state) +static void test_upage15(void **state) { struct ftl_map map; struct ftl_page_desc ret_page_desc; @@ -78,7 +78,7 @@ static void test_read_page_desc3(void **state) assert_int_equal(ret, -1); } -static void test_read_page_desc4(void **state) +static void test_upage16(void **state) { struct ftl_map map; struct ftl_page_desc page_desc, ret_page_desc; @@ -102,7 +102,7 @@ static void test_read_page_desc4(void **state) assert_int_equal(ret, 0); } -static void test_read_page_desc5(void **state) +static void test_upage30(void **state) { struct ftl_map map; struct ftl_page_desc page_desc, ret_page_desc; @@ -126,7 +126,7 @@ static void test_read_page_desc5(void **state) assert_int_equal(ret, 0); } -static void test_read_page_desc6(void **state) +static void test_upage31(void **state) { struct ftl_map map; struct ftl_page_desc ret_page_desc; @@ -142,7 +142,7 @@ static void test_read_page_desc6(void **state) assert_int_equal(ret, -1); } -static void test_read_page_desc7(void **state) +static void test_upage32(void **state) { struct ftl_map map; struct ftl_page_desc page_desc, ret_page_desc; @@ -169,13 +169,13 @@ static void test_read_page_desc7(void **state) int test_read_page_desc(void) { const struct CMUnitTest tests[] = { - cmocka_unit_test(test_read_page_desc1), - cmocka_unit_test(test_read_page_desc2), - cmocka_unit_test(test_read_page_desc3), - cmocka_unit_test(test_read_page_desc4), - cmocka_unit_test(test_read_page_desc5), - cmocka_unit_test(test_read_page_desc6), - cmocka_unit_test(test_read_page_desc7), + { "read_page_desc: upage=0", test_upage0, NULL, NULL, NULL }, + { "read_page_desc: upage=14", test_upage14, NULL, NULL, NULL }, + { "read_page_desc: upage=15 (invalid)", test_upage15, NULL, NULL, NULL }, + { "read_page_desc: upage=16", test_upage16, NULL, NULL, NULL }, + { "read_page_desc: upage=30", test_upage30, NULL, NULL, NULL }, + { "read_page_desc: upage=31 (invalid)", test_upage31, NULL, NULL, NULL }, + { "read_page_desc: upage=32", test_upage32, NULL, NULL, NULL }, }; return cmocka_run_group_tests_name("read_page_desc", tests, NULL, NULL); diff --git a/source/tests/ftl/write_page_desc.c b/source/tests/ftl/write_page_desc.c index 46344c2..430a9e1 100644 --- a/source/tests/ftl/write_page_desc.c +++ b/source/tests/ftl/write_page_desc.c @@ -41,7 +41,7 @@ static int test_teardown(void **state) return 0; } -static void test_write_page_desc1(void **state) +static void test_head0(void **state) { struct ftl_map *map = *state; struct ftl_page_desc page_desc, ret_page_desc; @@ -68,7 +68,7 @@ static void test_write_page_desc1(void **state) assert_memory_equal(ret_page_desc.magic, "page", 4); } -static void test_write_page_desc2(void **state) +static void test_head14(void **state) { struct ftl_map *map = *state; struct ftl_page_desc page_desc, ret_page_desc; @@ -95,7 +95,7 @@ static void test_write_page_desc2(void **state) assert_memory_equal(ret_page_desc.magic, "page", 4); } -static void test_write_page_desc3(void **state) +static void test_head16(void **state) { struct ftl_map *map = *state; struct ftl_page_desc page_desc, ret_page_desc; @@ -122,7 +122,7 @@ static void test_write_page_desc3(void **state) assert_memory_equal(ret_page_desc.magic, "page", 4); } -static void test_write_page_desc4(void **state) +static void test_head30(void **state) { struct ftl_map *map = *state; struct ftl_page_desc page_desc, ret_page_desc; @@ -149,7 +149,7 @@ static void test_write_page_desc4(void **state) assert_memory_equal(ret_page_desc.magic, "page", 4); } -static void test_write_page_desc5(void **state) +static void test_head32(void **state) { struct ftl_map *map = *state; struct ftl_page_desc page_desc, ret_page_desc; @@ -244,11 +244,11 @@ static void test_group_header(void **state) int test_write_page_desc(void) { const struct CMUnitTest tests[] = { - { "write_page_desc: head=0", test_write_page_desc1, NULL, NULL, NULL }, - { "write_page_desc: head=14", test_write_page_desc2, NULL, NULL, NULL }, - { "write_page_desc: head=16", test_write_page_desc3, NULL, NULL, NULL }, - { "write_page_desc: head=30", test_write_page_desc4, NULL, NULL, NULL }, - { "write_page_desc: head=32", test_write_page_desc5, NULL, NULL, NULL }, + { "write_page_desc: head=0", test_head0, NULL, NULL, NULL }, + { "write_page_desc: head=14", test_head14, NULL, NULL, NULL }, + { "write_page_desc: head=16", test_head16, NULL, NULL, NULL }, + { "write_page_desc: head=30", test_head30, NULL, NULL, NULL }, + { "write_page_desc: head=32", test_head32, NULL, NULL, NULL }, { "write_page_desc: epoch wraparound", test_epoch_wraparound, NULL, NULL, NULL }, { "write_page_desc: group header", test_group_header, NULL, NULL, NULL }, };