mirror of
https://github.com/armink/FlashDB.git
synced 2025-01-16 20:12:52 +08:00
[test] update the autotest bsp and testcase to latest version
This commit is contained in:
parent
fd08d7f323
commit
92ed442cfc
10
.github/workflows/main.yml
vendored
10
.github/workflows/main.yml
vendored
@ -1,5 +1,5 @@
|
|||||||
name: AutoTestCI
|
name: AutoTestCI
|
||||||
on: push
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
name: AutoTest
|
name: AutoTest
|
||||||
@ -7,15 +7,15 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TEST_BSP_ROOT: ../AutoTestBsp
|
TEST_BSP_ROOT: ../AutoTestBsp
|
||||||
UTEST_RUNNER_PATH: ../UtestRunner
|
UTEST_RUNNER_PATH: ../UtestRunner
|
||||||
RTT_EXEC_PATH: /opt/gcc-arm-none-eabi-6-2017-q2-update/bin
|
RTT_EXEC_PATH: /opt/gcc-arm-none-eabi-10-2020-q4-major/bin
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Prepare env
|
- name: Prepare env
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get -yqq install scons qemu-system git
|
sudo apt-get -yqq install scons qemu-system git
|
||||||
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/arm-2017q2-v6/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2
|
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.3/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
|
||||||
sudo tar xjf gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 -C /opt
|
sudo tar xjf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -C /opt
|
||||||
git clone https://github.com/armink/UtestRunner.git $UTEST_RUNNER_PATH
|
git clone https://github.com/armink/UtestRunner.git $UTEST_RUNNER_PATH
|
||||||
git clone https://github.com/armink/FlashDBAutoTestBSP.git $TEST_BSP_ROOT
|
git clone https://github.com/armink/FlashDBAutoTestBSP.git $TEST_BSP_ROOT
|
||||||
- name: Build bsp
|
- name: Build bsp
|
||||||
@ -25,7 +25,7 @@ jobs:
|
|||||||
cp -rf inc/fdb_def.h $TEST_BSP_ROOT/packages/FlashDB/inc/fdb_def.h
|
cp -rf inc/fdb_def.h $TEST_BSP_ROOT/packages/FlashDB/inc/fdb_def.h
|
||||||
cp -rf inc/fdb_low_lvl.h $TEST_BSP_ROOT/packages/FlashDB/inc/fdb_low_lvl.h
|
cp -rf inc/fdb_low_lvl.h $TEST_BSP_ROOT/packages/FlashDB/inc/fdb_low_lvl.h
|
||||||
cp -rf inc/flashdb.h $TEST_BSP_ROOT/packages/FlashDB/inc/flashdb.h
|
cp -rf inc/flashdb.h $TEST_BSP_ROOT/packages/FlashDB/inc/flashdb.h
|
||||||
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-gcc --version
|
/opt/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc --version
|
||||||
scons -j$(nproc) -C $TEST_BSP_ROOT
|
scons -j$(nproc) -C $TEST_BSP_ROOT
|
||||||
- name: Start test
|
- name: Start test
|
||||||
run: |
|
run: |
|
||||||
|
@ -179,13 +179,15 @@ static void test_fdb_create_kv_blob(void)
|
|||||||
static void test_fdb_change_kv_blob(void)
|
static void test_fdb_change_kv_blob(void)
|
||||||
{
|
{
|
||||||
fdb_err_t result = FDB_NO_ERR;
|
fdb_err_t result = FDB_NO_ERR;
|
||||||
rt_tick_t tick = rt_tick_get(), read_tick;
|
rt_tick_t tick = 0, read_tick;
|
||||||
size_t read_len;
|
size_t read_len;
|
||||||
struct fdb_blob blob_obj, *blob = &blob_obj;
|
struct fdb_blob blob_obj, *blob = &blob_obj;
|
||||||
|
|
||||||
read_len = fdb_kv_get_blob(&test_kvdb, TEST_KV_BLOB_NAME, fdb_blob_make(&blob_obj, &read_tick, sizeof(read_tick)));
|
read_len = fdb_kv_get_blob(&test_kvdb, TEST_KV_BLOB_NAME, fdb_blob_make(&blob_obj, &read_tick, sizeof(read_tick)));
|
||||||
uassert_int_equal(blob->saved.len, sizeof(read_tick));
|
uassert_int_equal(blob->saved.len, sizeof(read_tick));
|
||||||
uassert_int_equal(blob->saved.len, read_len);
|
uassert_int_equal(blob->saved.len, read_len);
|
||||||
|
rt_thread_mdelay(1);
|
||||||
|
tick = rt_tick_get();
|
||||||
uassert_int_not_equal(tick, read_tick);
|
uassert_int_not_equal(tick, read_tick);
|
||||||
|
|
||||||
result = fdb_kv_set_blob(&test_kvdb, TEST_KV_BLOB_NAME, fdb_blob_make(&blob_obj, &tick, sizeof(tick)));
|
result = fdb_kv_set_blob(&test_kvdb, TEST_KV_BLOB_NAME, fdb_blob_make(&blob_obj, &tick, sizeof(tick)));
|
||||||
@ -200,13 +202,15 @@ static void test_fdb_change_kv_blob(void)
|
|||||||
static void test_fdb_del_kv_blob(void)
|
static void test_fdb_del_kv_blob(void)
|
||||||
{
|
{
|
||||||
fdb_err_t result = FDB_NO_ERR;
|
fdb_err_t result = FDB_NO_ERR;
|
||||||
rt_tick_t tick = rt_tick_get(), read_tick;
|
rt_tick_t tick = 0, read_tick;
|
||||||
size_t read_len;
|
size_t read_len;
|
||||||
struct fdb_blob blob;
|
struct fdb_blob blob;
|
||||||
|
|
||||||
read_len = fdb_kv_get_blob(&test_kvdb, TEST_KV_BLOB_NAME, fdb_blob_make(&blob, &read_tick, sizeof(read_tick)));
|
read_len = fdb_kv_get_blob(&test_kvdb, TEST_KV_BLOB_NAME, fdb_blob_make(&blob, &read_tick, sizeof(read_tick)));
|
||||||
uassert_int_equal(blob.saved.len, sizeof(read_tick));
|
uassert_int_equal(blob.saved.len, sizeof(read_tick));
|
||||||
uassert_int_equal(blob.saved.len, read_len);
|
uassert_int_equal(blob.saved.len, read_len);
|
||||||
|
rt_thread_mdelay(1);
|
||||||
|
tick = rt_tick_get();
|
||||||
uassert_int_not_equal(tick, read_tick);
|
uassert_int_not_equal(tick, read_tick);
|
||||||
|
|
||||||
result = fdb_kv_set_blob(&test_kvdb, TEST_KV_BLOB_NAME, fdb_blob_make(&blob, NULL, 0));
|
result = fdb_kv_set_blob(&test_kvdb, TEST_KV_BLOB_NAME, fdb_blob_make(&blob, NULL, 0));
|
||||||
@ -236,12 +240,14 @@ static void test_fdb_create_kv(void)
|
|||||||
static void test_fdb_change_kv(void)
|
static void test_fdb_change_kv(void)
|
||||||
{
|
{
|
||||||
fdb_err_t result = FDB_NO_ERR;
|
fdb_err_t result = FDB_NO_ERR;
|
||||||
rt_tick_t tick = rt_tick_get(), read_tick;
|
rt_tick_t tick = 0, read_tick;
|
||||||
char value_buf[14], *read_value;
|
char value_buf[14], *read_value;
|
||||||
|
|
||||||
read_value = fdb_kv_get(&test_kvdb, TEST_KV_NAME);
|
read_value = fdb_kv_get(&test_kvdb, TEST_KV_NAME);
|
||||||
uassert_not_null(read_value);
|
uassert_not_null(read_value);
|
||||||
read_tick = atoi(read_value);
|
read_tick = atoi(read_value);
|
||||||
|
rt_thread_mdelay(1);
|
||||||
|
tick = rt_tick_get();
|
||||||
uassert_int_not_equal(tick, read_tick);
|
uassert_int_not_equal(tick, read_tick);
|
||||||
|
|
||||||
snprintf(value_buf, sizeof(value_buf), "%" PRIu32, tick);
|
snprintf(value_buf, sizeof(value_buf), "%" PRIu32, tick);
|
||||||
@ -264,12 +270,14 @@ static void fdb_reboot(void)
|
|||||||
static void test_fdb_del_kv(void)
|
static void test_fdb_del_kv(void)
|
||||||
{
|
{
|
||||||
fdb_err_t result = FDB_NO_ERR;
|
fdb_err_t result = FDB_NO_ERR;
|
||||||
rt_tick_t tick = rt_tick_get(), read_tick;
|
rt_tick_t tick = 0, read_tick;
|
||||||
char *read_value;
|
char *read_value;
|
||||||
|
|
||||||
read_value = fdb_kv_get(&test_kvdb, TEST_KV_NAME);
|
read_value = fdb_kv_get(&test_kvdb, TEST_KV_NAME);
|
||||||
uassert_not_null(read_value);
|
uassert_not_null(read_value);
|
||||||
read_tick = atoi(read_value);
|
read_tick = atoi(read_value);
|
||||||
|
rt_thread_mdelay(1);
|
||||||
|
tick = rt_tick_get();
|
||||||
uassert_int_not_equal(tick, read_tick);
|
uassert_int_not_equal(tick, read_tick);
|
||||||
|
|
||||||
result = fdb_kv_del(&test_kvdb, TEST_KV_NAME);
|
result = fdb_kv_del(&test_kvdb, TEST_KV_NAME);
|
||||||
|
@ -60,13 +60,27 @@ static void test_fdb_tsdb_init_ex(void)
|
|||||||
|
|
||||||
uint32_t sec_size = TEST_SECTOR_SIZE, db_size = sec_size * 16;
|
uint32_t sec_size = TEST_SECTOR_SIZE, db_size = sec_size * 16;
|
||||||
rt_bool_t file_mode = true;
|
rt_bool_t file_mode = true;
|
||||||
fdb_kvdb_control((fdb_kvdb_t)&(test_tsdb), FDB_TSDB_CTRL_SET_SEC_SIZE, &sec_size);
|
|
||||||
fdb_kvdb_control((fdb_kvdb_t)&(test_tsdb), FDB_TSDB_CTRL_SET_FILE_MODE, &file_mode);
|
memset(&test_tsdb, 0, sizeof(struct fdb_tsdb));
|
||||||
fdb_kvdb_control((fdb_kvdb_t)&(test_tsdb), FDB_TSDB_CTRL_SET_MAX_SIZE, &db_size);
|
fdb_tsdb_control((fdb_tsdb_t)&(test_tsdb), FDB_TSDB_CTRL_SET_SEC_SIZE, &sec_size);
|
||||||
|
fdb_tsdb_control((fdb_tsdb_t)&(test_tsdb), FDB_TSDB_CTRL_SET_FILE_MODE, &file_mode);
|
||||||
|
fdb_tsdb_control((fdb_tsdb_t)&(test_tsdb), FDB_TSDB_CTRL_SET_MAX_SIZE, &db_size);
|
||||||
|
|
||||||
uassert_true(fdb_tsdb_init(&test_tsdb, "test_ts", TEST_TS_PART_NAME, get_time, 128, NULL) == FDB_NO_ERR);
|
uassert_true(fdb_tsdb_init(&test_tsdb, "test_ts", TEST_TS_PART_NAME, get_time, 128, NULL) == FDB_NO_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_fdb_tsdb_deinit(void)
|
||||||
|
{
|
||||||
|
uassert_true(fdb_tsdb_deinit(&test_tsdb) == FDB_NO_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check reboot status */
|
||||||
|
static void fdb_reboot(void)
|
||||||
|
{
|
||||||
|
test_fdb_tsdb_deinit();
|
||||||
|
test_fdb_tsdb_init_ex();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_fdb_tsl_append(void)
|
static void test_fdb_tsl_append(void)
|
||||||
{
|
{
|
||||||
struct fdb_blob blob;
|
struct fdb_blob blob;
|
||||||
@ -101,6 +115,7 @@ static bool test_fdb_tsl_iter_cb(fdb_tsl_t tsl, void *arg)
|
|||||||
|
|
||||||
static void test_fdb_tsl_iter(void)
|
static void test_fdb_tsl_iter(void)
|
||||||
{
|
{
|
||||||
|
fdb_reboot();
|
||||||
fdb_tsl_iter(&test_tsdb, test_fdb_tsl_iter_cb, NULL);
|
fdb_tsl_iter(&test_tsdb, test_fdb_tsl_iter_cb, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +123,7 @@ static void test_fdb_tsl_iter_by_time(void)
|
|||||||
{
|
{
|
||||||
fdb_time_t from = 0, to = TEST_TS_COUNT * TEST_TIME_STEP - 1;
|
fdb_time_t from = 0, to = TEST_TS_COUNT * TEST_TIME_STEP - 1;
|
||||||
|
|
||||||
|
fdb_reboot();
|
||||||
for (fdb_time_t cur = from; cur <= to; cur += TEST_TIME_STEP) {
|
for (fdb_time_t cur = from; cur <= to; cur += TEST_TIME_STEP) {
|
||||||
fdb_tsl_iter_by_time(&test_tsdb, cur, cur, test_fdb_tsl_iter_cb, &cur);
|
fdb_tsl_iter_by_time(&test_tsdb, cur, cur, test_fdb_tsl_iter_cb, &cur);
|
||||||
}
|
}
|
||||||
@ -118,6 +134,7 @@ static void test_fdb_tsl_query_count(void)
|
|||||||
{
|
{
|
||||||
fdb_time_t from = 0, to = TEST_TS_COUNT * TEST_TIME_STEP;
|
fdb_time_t from = 0, to = TEST_TS_COUNT * TEST_TIME_STEP;
|
||||||
|
|
||||||
|
fdb_reboot();
|
||||||
uassert_true(fdb_tsl_query_count(&test_tsdb, from, to, FDB_TSL_WRITE) == TEST_TS_COUNT);
|
uassert_true(fdb_tsl_query_count(&test_tsdb, from, to, FDB_TSL_WRITE) == TEST_TS_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +155,7 @@ static void test_fdb_tsl_set_status(void)
|
|||||||
{
|
{
|
||||||
fdb_time_t from = 0, to = TEST_TS_COUNT * TEST_TIME_STEP;
|
fdb_time_t from = 0, to = TEST_TS_COUNT * TEST_TIME_STEP;
|
||||||
|
|
||||||
|
fdb_reboot();
|
||||||
fdb_tsl_iter_by_time(&test_tsdb, from, to, est_fdb_tsl_set_status_cb, &test_tsdb);
|
fdb_tsl_iter_by_time(&test_tsdb, from, to, est_fdb_tsl_set_status_cb, &test_tsdb);
|
||||||
|
|
||||||
uassert_true(fdb_tsl_query_count(&test_tsdb, from, to, FDB_TSL_USER_STATUS1) == TEST_TS_USER_STATUS1_COUNT);
|
uassert_true(fdb_tsl_query_count(&test_tsdb, from, to, FDB_TSL_USER_STATUS1) == TEST_TS_USER_STATUS1_COUNT);
|
||||||
@ -158,8 +176,13 @@ static void test_fdb_tsl_clean(void)
|
|||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
cur_times = 0;
|
cur_times = 0;
|
||||||
fdb_tsl_clean(&test_tsdb);
|
|
||||||
|
|
||||||
|
fdb_reboot();
|
||||||
|
fdb_tsl_clean(&test_tsdb);
|
||||||
|
fdb_tsl_iter(&test_tsdb, test_fdb_tsl_clean_cb, &count);
|
||||||
|
uassert_true(count == 0);
|
||||||
|
|
||||||
|
fdb_reboot();
|
||||||
fdb_tsl_iter(&test_tsdb, test_fdb_tsl_clean_cb, &count);
|
fdb_tsl_iter(&test_tsdb, test_fdb_tsl_clean_cb, &count);
|
||||||
|
|
||||||
uassert_true(count == 0);
|
uassert_true(count == 0);
|
||||||
@ -286,6 +309,29 @@ static void test_tsdb_data_by_time(fdb_time_t from, fdb_time_t to)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_fdb_tsl_sector_bound_test(int start_sec_index, int end_sec_index)
|
||||||
|
{
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].start_time - 1, test_secs_info[end_sec_index].end_time + 1);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].start_time - 1, test_secs_info[end_sec_index].end_time + 0);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].start_time - 1, test_secs_info[end_sec_index].end_time - 1);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].start_time + 0, test_secs_info[end_sec_index].end_time + 1);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].start_time + 0, test_secs_info[end_sec_index].end_time + 0);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].start_time + 0, test_secs_info[end_sec_index].end_time - 1);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].start_time + 1, test_secs_info[end_sec_index].end_time + 1);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].start_time + 1, test_secs_info[end_sec_index].end_time + 0);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].start_time + 1, test_secs_info[end_sec_index].end_time - 1);
|
||||||
|
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].end_time - 1, test_secs_info[end_sec_index].start_time + 1);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].end_time - 1, test_secs_info[end_sec_index].start_time + 0);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].end_time - 1, test_secs_info[end_sec_index].start_time - 1);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].end_time + 0, test_secs_info[end_sec_index].start_time + 1);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].end_time + 0, test_secs_info[end_sec_index].start_time + 0);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].end_time + 0, test_secs_info[end_sec_index].start_time - 1);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].end_time + 1, test_secs_info[end_sec_index].start_time + 1);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].end_time + 1, test_secs_info[end_sec_index].start_time + 0);
|
||||||
|
test_tsdb_data_by_time(test_secs_info[start_sec_index].end_time + 1, test_secs_info[end_sec_index].start_time - 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_fdb_tsl_iter_by_time_1(void)
|
static void test_fdb_tsl_iter_by_time_1(void)
|
||||||
{
|
{
|
||||||
struct fdb_blob blob;
|
struct fdb_blob blob;
|
||||||
@ -296,6 +342,9 @@ static void test_fdb_tsl_iter_by_time_1(void)
|
|||||||
for (data = 0; data < 800; data++) {
|
for (data = 0; data < 800; data++) {
|
||||||
fdb_tsl_append(&test_tsdb, fdb_blob_make(&blob, &data, sizeof(data)));
|
fdb_tsl_append(&test_tsdb, fdb_blob_make(&blob, &data, sizeof(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fdb_reboot();
|
||||||
|
|
||||||
/* init all test sectors info */
|
/* init all test sectors info */
|
||||||
for (i = 0; i < sizeof(test_secs_info) / sizeof(test_secs_info[0]); i++) {
|
for (i = 0; i < sizeof(test_secs_info) / sizeof(test_secs_info[0]); i++) {
|
||||||
test_secs_info[i].addr = TEST_SECTOR_SIZE * i;
|
test_secs_info[i].addr = TEST_SECTOR_SIZE * i;
|
||||||
@ -347,25 +396,64 @@ static void test_fdb_tsl_iter_by_time_1(void)
|
|||||||
test_tsdb_data_by_time(test_secs_info[0].end_time, test_secs_info[0].start_time);
|
test_tsdb_data_by_time(test_secs_info[0].end_time, test_secs_info[0].start_time);
|
||||||
|
|
||||||
/* check 1~2 sector */
|
/* check 1~2 sector */
|
||||||
test_tsdb_data_by_time(test_secs_info[0].start_time - 1, test_secs_info[1].end_time);
|
test_fdb_tsl_sector_bound_test(0, 0);
|
||||||
test_tsdb_data_by_time(test_secs_info[0].start_time + 1, test_secs_info[1].end_time);
|
test_fdb_tsl_sector_bound_test(0, 1);
|
||||||
test_tsdb_data_by_time(test_secs_info[0].end_time + 1, test_secs_info[1].end_time);
|
test_fdb_tsl_sector_bound_test(1, 0);
|
||||||
test_tsdb_data_by_time(test_secs_info[1].end_time + 1, test_secs_info[0].start_time);
|
test_fdb_tsl_sector_bound_test(1, 1);
|
||||||
test_tsdb_data_by_time(test_secs_info[1].end_time - 1, test_secs_info[0].start_time);
|
|
||||||
test_tsdb_data_by_time(test_secs_info[1].start_time - 1, test_secs_info[0].start_time);
|
|
||||||
|
|
||||||
/* check more than 2 sectors */
|
/* check more than 2 sectors */
|
||||||
test_tsdb_data_by_time(test_secs_info[0].start_time - 1, test_secs_info[2].end_time);
|
test_fdb_tsl_sector_bound_test(0, 2);
|
||||||
test_tsdb_data_by_time(test_secs_info[0].start_time + 1, test_secs_info[2].end_time);
|
test_fdb_tsl_sector_bound_test(2, 0);
|
||||||
test_tsdb_data_by_time(test_secs_info[0].end_time + 1, test_secs_info[2].end_time);
|
test_fdb_tsl_sector_bound_test(2, 2);
|
||||||
test_tsdb_data_by_time(test_secs_info[2].end_time + 1, test_secs_info[0].start_time);
|
|
||||||
test_tsdb_data_by_time(test_secs_info[2].end_time - 1, test_secs_info[0].start_time);
|
|
||||||
test_tsdb_data_by_time(test_secs_info[2].start_time - 1, test_secs_info[0].start_time);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_fdb_tsdb_deinit(void)
|
static void test_fdb_github_issue_249(void)
|
||||||
{
|
{
|
||||||
uassert_true(fdb_tsdb_deinit(&test_tsdb) == FDB_NO_ERR);
|
if (access("storage_tsdb", 0) < 0)
|
||||||
|
{
|
||||||
|
mkdir("storage_tsdb", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t sec_size = 16 * 1024, db_size = 512 * 1024, test_data_size = 0;
|
||||||
|
rt_bool_t file_mode = true, flag_not_format = false;
|
||||||
|
struct fdb_blob blob;
|
||||||
|
uint8_t *data = NULL;
|
||||||
|
|
||||||
|
memset(&test_tsdb, 0, sizeof(struct fdb_tsdb));
|
||||||
|
fdb_tsdb_control((fdb_tsdb_t) & (test_tsdb), FDB_TSDB_CTRL_SET_SEC_SIZE, &sec_size);
|
||||||
|
fdb_tsdb_control((fdb_tsdb_t) & (test_tsdb), FDB_TSDB_CTRL_SET_FILE_MODE, &file_mode);
|
||||||
|
fdb_tsdb_control((fdb_tsdb_t) & (test_tsdb), FDB_TSDB_CTRL_SET_NOT_FORMAT, &flag_not_format);
|
||||||
|
fdb_tsdb_control((fdb_tsdb_t) & (test_tsdb), FDB_TSDB_CTRL_SET_MAX_SIZE, &db_size);
|
||||||
|
|
||||||
|
uassert_true(fdb_tsdb_init(&test_tsdb, "storage_tsdb", "storage_tsdb", get_time, 10*1024, NULL) == FDB_NO_ERR);
|
||||||
|
/* clean status */
|
||||||
|
fdb_tsl_clean(&test_tsdb);
|
||||||
|
cur_times = 0;
|
||||||
|
|
||||||
|
test_data_size = 7 * 1024;
|
||||||
|
data = rt_malloc(test_data_size);
|
||||||
|
uassert_true(data != NULL);
|
||||||
|
uassert_true(fdb_tsl_append(&test_tsdb, fdb_blob_make(&blob, data, test_data_size)) == FDB_NO_ERR);
|
||||||
|
rt_free(data);
|
||||||
|
|
||||||
|
test_data_size = 8 * 1024;
|
||||||
|
data = rt_malloc(test_data_size);
|
||||||
|
uassert_true(data != NULL);
|
||||||
|
uassert_true(fdb_tsl_append(&test_tsdb, fdb_blob_make(&blob, data, test_data_size)) == FDB_NO_ERR);
|
||||||
|
rt_free(data);
|
||||||
|
|
||||||
|
test_data_size = 9 * 1024;
|
||||||
|
data = rt_malloc(test_data_size);
|
||||||
|
uassert_true(data != NULL);
|
||||||
|
uassert_true(fdb_tsl_append(&test_tsdb, fdb_blob_make(&blob, data, test_data_size)) == FDB_NO_ERR);
|
||||||
|
rt_free(data);
|
||||||
|
|
||||||
|
{ /* reboot simulation */
|
||||||
|
uassert_true(fdb_tsdb_deinit(&test_tsdb) == FDB_NO_ERR);
|
||||||
|
uassert_true(fdb_tsdb_init(&test_tsdb, "storage_tsdb", "storage_tsdb", get_time, 10 * 1024, NULL) == FDB_NO_ERR);
|
||||||
|
}
|
||||||
|
uassert_true(fdb_tsl_query_count(&test_tsdb, 2, 6, FDB_TSL_WRITE) == 3);
|
||||||
|
uassert_true(fdb_tsl_query_count(&test_tsdb, 0, INT32_MAX, FDB_TSL_WRITE) == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void testcase(void)
|
static void testcase(void)
|
||||||
@ -380,7 +468,9 @@ static void testcase(void)
|
|||||||
UTEST_UNIT_RUN(test_fdb_tsl_clean);
|
UTEST_UNIT_RUN(test_fdb_tsl_clean);
|
||||||
UTEST_UNIT_RUN(test_fdb_tsl_iter_by_time_1);
|
UTEST_UNIT_RUN(test_fdb_tsl_iter_by_time_1);
|
||||||
UTEST_UNIT_RUN(test_fdb_tsdb_deinit);
|
UTEST_UNIT_RUN(test_fdb_tsdb_deinit);
|
||||||
|
|
||||||
|
UTEST_UNIT_RUN(test_fdb_github_issue_249);
|
||||||
}
|
}
|
||||||
|
|
||||||
UTEST_TC_EXPORT(testcase, "packages.system.flashdb.tsdb", utest_tc_init, utest_tc_cleanup, 20);
|
UTEST_TC_EXPORT(testcase, "packages.system.flashdb.tsdb", utest_tc_init, utest_tc_cleanup, 60);
|
||||||
#endif /* defined(RT_USING_UTEST) && defined(FDBTC_USING_TSDB) && defined(TC_USING_FDBTC_TSDB) */
|
#endif /* defined(RT_USING_UTEST) && defined(FDBTC_USING_TSDB) && defined(TC_USING_FDBTC_TSDB) */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user