Skip to content

Commit

Permalink
[kvdb] fix testcase running error on ci env
Browse files Browse the repository at this point in the history
  • Loading branch information
armink committed Apr 30, 2023
1 parent d3eaa54 commit b73fb75
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions tests/fdb_kvdb_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static int iter_all_kv(fdb_kvdb_t db, struct test_kv *kv_tbl)
return index;
}

static void test_fdb_by_kvs(struct test_kv *kv_tbl, size_t len)
static void test_fdb_by_kvs(const struct test_kv *kv_tbl, size_t len)
{
struct fdb_blob blob_obj, * blob = &blob_obj;
static struct test_kv saved_kv_tbl[TEST_KV_NUM] = { 0 };
Expand Down Expand Up @@ -274,16 +274,15 @@ static void test_fdb_gc(void)
* | | | | |
* +---------------------------------------------------------+
*/
struct test_kv kv_tbl[TEST_KV_NUM] = {
const struct test_kv kv_tbl[] = {
{"kv0", "0", 0, 0, 1},
{"kv1", "1", 0, 0, 1},
{"kv2", "2", 0, 0, 1},
{"kv3", "3", 1, 0, 1},
};

test_fdb_by_kvs(kv_tbl, sizeof(kv_tbl)/sizeof(kv_tbl[0]));
test_fdb_by_kvs(kv_tbl, sizeof(kv_tbl) / sizeof(kv_tbl[0]));
uassert_true(RT_ALIGN_DOWN(test_kvdb.parent.oldest_addr, TEST_KVDB_SECTOR_SIZE) == TEST_KVDB_SECTOR_SIZE * 0);

}

{
Expand All @@ -309,7 +308,7 @@ static void test_fdb_gc(void)
* | | | | |
* +--------------+-------------+--------------+-------------+
*/
struct test_kv kv_tbl[TEST_KV_NUM] = {
const struct test_kv kv_tbl[] = {
{"kv1", "1", 0, 0, 0},
{"kv2", "2", 0, 0, 0},
{"kv0", "00", 1, 0, 1},
Expand Down Expand Up @@ -345,7 +344,7 @@ static void test_fdb_gc(void)
* +--------------+-------------+--------------+-------------+
*
* step2.1: change kv3, start GC, only GC 1 sector on FlashDB V1.2
*
*
* +--------------+-------------+--------------+-------------+
* | sector0 | sector1 | sector2 | sector3 |
* | empty | using | using | empty |
Expand All @@ -364,9 +363,9 @@ static void test_fdb_gc(void)
* | +----------------------------+ |
* | | | | |
* +--------------+-------------+--------------+-------------+
*
*
* step2.2: change kv3
*
*
* +--------------+-------------+--------------+-------------+
* | sector0 | sector1 | sector2 | sector3 |
* | empty | using | using | using |
Expand All @@ -387,7 +386,7 @@ static void test_fdb_gc(void)
* +--------------+-------------+--------------+-------------+
*
*/
struct test_kv kv_tbl[TEST_KV_NUM] = {
const struct test_kv kv_tbl[] = {
{"kv0", "000", 2, 0, 1},
{"kv1", "111", 2, 0, 1},
{"kv2", "222", 2, 0, 1},
Expand Down Expand Up @@ -485,7 +484,7 @@ static void test_fdb_gc(void)
* | | | | |
* +--------------+-------------+--------------+-------------+
*/
struct test_kv kv_tbl[TEST_KV_NUM] = {
const struct test_kv kv_tbl[] = {
{"kv0", "0000", 3, 0, 1},
{"kv1", "1111", 3, 0, 1},
{"kv2", "2222", 0, 0, 1},
Expand All @@ -496,14 +495,12 @@ static void test_fdb_gc(void)
uassert_true(RT_ALIGN_DOWN(test_kvdb.parent.oldest_addr, TEST_KVDB_SECTOR_SIZE) == TEST_KVDB_SECTOR_SIZE * 2);
}

{
/* check the oldest address is already right when kvdb reinit */
extern void test_fdb_kvdb_deinit(void);
test_fdb_kvdb_deinit();
test_fdb_kvdb_init();
/* check the oldest address is already right when kvdb reinit */
extern void test_fdb_kvdb_deinit(void);
test_fdb_kvdb_deinit();
test_fdb_kvdb_init();

uassert_true(RT_ALIGN_DOWN(test_kvdb.parent.oldest_addr, TEST_KVDB_SECTOR_SIZE) == TEST_KVDB_SECTOR_SIZE * 2);
}
uassert_true(RT_ALIGN_DOWN(test_kvdb.parent.oldest_addr, TEST_KVDB_SECTOR_SIZE) == TEST_KVDB_SECTOR_SIZE * 2);
}

static void test_fdb_kvdb_set_default(void)
Expand Down

0 comments on commit b73fb75

Please sign in to comment.