From 751999a82b8854ef5231e0ded5fe022b1ea5d8ff Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Sat, 4 Jul 2026 18:44:17 +0900 Subject: Harden backup import and restore coverage --- tests/storage_test.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests/storage_test.c') diff --git a/tests/storage_test.c b/tests/storage_test.c index 0343f46..5c343d0 100644 --- a/tests/storage_test.c +++ b/tests/storage_test.c @@ -193,6 +193,40 @@ main(void) tiny_sys_file_close(&log); CHECK(tiny_store_open(&store, directory) == TINY_STORE_CORRUPT); + { + char *tail_directory = tiny_sys_path_join(temporary_root, "snapshot-tail"); + tiny_store_t *tail_store = NULL; + tiny_message_t tail_input, tail_put; + tiny_store_health_t tail_health; + CHECK(tail_directory != NULL); + CHECK(tiny_sys_directory_create(tail_directory) == TINY_SYS_OK); + CHECK(tiny_store_open(&tail_store, tail_directory) == TINY_STORE_OK); + tiny_message_init(&tail_input); + tiny_message_init(&tail_put); + tail_input.session_id = duplicate_string("tail"); + tail_input.content = duplicate_string("snapshot base"); + tail_input.role = TINY_ROLE_USER; + CHECK(tiny_store_write(tail_store, &tail_input, &tail_put) == TINY_STORE_OK); + CHECK(tiny_store_rebuild(tail_store, &report) == TINY_STORE_OK); + tiny_store_health(tail_store, &tail_health); + CHECK(tail_health.snapshot_valid); + free(tail_input.content); + tail_input.content = duplicate_string("tail put then delete"); + tiny_message_free(&tail_put); + CHECK(tiny_store_write(tail_store, &tail_input, &tail_put) == TINY_STORE_OK); + CHECK(tiny_store_delete(tail_store, tail_put.message_id, "tail") == TINY_STORE_OK); + tiny_message_free(&tail_input); + tiny_message_free(&tail_put); + tiny_store_close(tail_store); + tail_store = NULL; + CHECK(tiny_store_open(&tail_store, tail_directory) == TINY_STORE_OK); + CHECK(tiny_store_entry_count(tail_store) == 2); + CHECK(!tiny_store_entry(tail_store, 0)->deleted); + CHECK(tiny_store_entry(tail_store, 1)->deleted); + tiny_store_close(tail_store); + free(tail_directory); + } + (void)tiny_sys_file_remove(log_path); (void)tiny_sys_file_remove(temporary_path); (void)tiny_sys_file_remove(lock_path); -- cgit v1.2.3