@@ -45,16 +45,13 @@ static void test_fdb_kvdb_init(void)
4545 {
4646 mkdir (TEST_TS_PART_NAME , 0 );
4747 }
48- #ifndef FDB_USING_FAL_MODE
48+
4949 uint32_t sec_size = TEST_KVDB_SECTOR_SIZE , db_size = sec_size * 4 ;
5050 rt_bool_t file_mode = true;
51- #endif
5251
53- #ifndef FDB_USING_FAL_MODE
5452 fdb_kvdb_control (& (test_kvdb ), FDB_KVDB_CTRL_SET_SEC_SIZE , & sec_size );
5553 fdb_kvdb_control (& (test_kvdb ), FDB_KVDB_CTRL_SET_FILE_MODE , & file_mode );
5654 fdb_kvdb_control (& (test_kvdb ), FDB_KVDB_CTRL_SET_MAX_SIZE , & db_size );
57- #endif
5855
5956 uassert_true (fdb_kvdb_init (& test_kvdb , "test_kv" , TEST_TS_PART_NAME , NULL , NULL ) == FDB_NO_ERR );
6057}
@@ -224,7 +221,7 @@ static int iter_all_kv(fdb_kvdb_t db, struct test_kv *kv_tbl)
224221 return index ;
225222}
226223
227- static void test_fdb_by_kvs (struct test_kv * kv_tbl , size_t len )
224+ static void test_fdb_by_kvs (const struct test_kv * kv_tbl , size_t len )
228225{
229226 struct fdb_blob blob_obj , * blob = & blob_obj ;
230227 static struct test_kv saved_kv_tbl [TEST_KV_NUM ] = { 0 };
@@ -274,16 +271,15 @@ static void test_fdb_gc(void)
274271 * | | | | |
275272 * +---------------------------------------------------------+
276273 */
277- struct test_kv kv_tbl [TEST_KV_NUM ] = {
274+ const struct test_kv kv_tbl [] = {
278275 {"kv0" , "0" , 0 , 0 , 1 },
279276 {"kv1" , "1" , 0 , 0 , 1 },
280277 {"kv2" , "2" , 0 , 0 , 1 },
281278 {"kv3" , "3" , 1 , 0 , 1 },
282279 };
283280
284- test_fdb_by_kvs (kv_tbl , sizeof (kv_tbl )/ sizeof (kv_tbl [0 ]));
281+ test_fdb_by_kvs (kv_tbl , sizeof (kv_tbl ) / sizeof (kv_tbl [0 ]));
285282 uassert_true (RT_ALIGN_DOWN (test_kvdb .parent .oldest_addr , TEST_KVDB_SECTOR_SIZE ) == TEST_KVDB_SECTOR_SIZE * 0 );
286-
287283 }
288284
289285 {
@@ -309,7 +305,7 @@ static void test_fdb_gc(void)
309305 * | | | | |
310306 * +--------------+-------------+--------------+-------------+
311307 */
312- struct test_kv kv_tbl [TEST_KV_NUM ] = {
308+ const struct test_kv kv_tbl [] = {
313309 {"kv1" , "1" , 0 , 0 , 0 },
314310 {"kv2" , "2" , 0 , 0 , 0 },
315311 {"kv0" , "00" , 1 , 0 , 1 },
@@ -345,7 +341,7 @@ static void test_fdb_gc(void)
345341 * +--------------+-------------+--------------+-------------+
346342 *
347343 * step2.1: change kv3, start GC, only GC 1 sector on FlashDB V1.2
348- *
344+ *
349345 * +--------------+-------------+--------------+-------------+
350346 * | sector0 | sector1 | sector2 | sector3 |
351347 * | empty | using | using | empty |
@@ -364,9 +360,9 @@ static void test_fdb_gc(void)
364360 * | +----------------------------+ |
365361 * | | | | |
366362 * +--------------+-------------+--------------+-------------+
367- *
363+ *
368364 * step2.2: change kv3
369- *
365+ *
370366 * +--------------+-------------+--------------+-------------+
371367 * | sector0 | sector1 | sector2 | sector3 |
372368 * | empty | using | using | using |
@@ -387,7 +383,7 @@ static void test_fdb_gc(void)
387383 * +--------------+-------------+--------------+-------------+
388384 *
389385 */
390- struct test_kv kv_tbl [TEST_KV_NUM ] = {
386+ const struct test_kv kv_tbl [] = {
391387 {"kv0" , "000" , 2 , 0 , 1 },
392388 {"kv1" , "111" , 2 , 0 , 1 },
393389 {"kv2" , "222" , 2 , 0 , 1 },
@@ -485,7 +481,7 @@ static void test_fdb_gc(void)
485481 * | | | | |
486482 * +--------------+-------------+--------------+-------------+
487483 */
488- struct test_kv kv_tbl [TEST_KV_NUM ] = {
484+ const struct test_kv kv_tbl [] = {
489485 {"kv0" , "0000" , 3 , 0 , 1 },
490486 {"kv1" , "1111" , 3 , 0 , 1 },
491487 {"kv2" , "2222" , 0 , 0 , 1 },
@@ -496,14 +492,12 @@ static void test_fdb_gc(void)
496492 uassert_true (RT_ALIGN_DOWN (test_kvdb .parent .oldest_addr , TEST_KVDB_SECTOR_SIZE ) == TEST_KVDB_SECTOR_SIZE * 2 );
497493 }
498494
499- {
500- /* check the oldest address is already right when kvdb reinit */
501- extern void test_fdb_kvdb_deinit (void );
502- test_fdb_kvdb_deinit ();
503- test_fdb_kvdb_init ();
495+ /* check the oldest address is already right when kvdb reinit */
496+ extern void test_fdb_kvdb_deinit (void );
497+ test_fdb_kvdb_deinit ();
498+ test_fdb_kvdb_init ();
504499
505- uassert_true (RT_ALIGN_DOWN (test_kvdb .parent .oldest_addr , TEST_KVDB_SECTOR_SIZE ) == TEST_KVDB_SECTOR_SIZE * 2 );
506- }
500+ uassert_true (RT_ALIGN_DOWN (test_kvdb .parent .oldest_addr , TEST_KVDB_SECTOR_SIZE ) == TEST_KVDB_SECTOR_SIZE * 2 );
507501}
508502
509503static void test_fdb_kvdb_set_default (void )
0 commit comments