--- lbbs/src/test_file_loader.c 2025/11/11 00:28:05 1.13 +++ lbbs/src/test_file_loader.c 2026/01/03 10:27:14 1.18 @@ -3,7 +3,7 @@ * test_file_loader * - tester for shared memory based file loader * - * Copyright (C) 2004-2025 Leaflet + * Copyright (C) 2004-2026 Leaflet */ #ifdef HAVE_CONFIG_H @@ -12,13 +12,11 @@ #include "file_loader.h" #include "log.h" -#include "trie_dict.h" #include +#include #include +#include #include -#include - -static const char TRIE_DICT_SHM_FILE[] = "~trie_dict_shm.dat"; const char *files[] = { "../data/welcome.txt", @@ -32,14 +30,12 @@ int files_cnt = 6; int main(int argc, char *argv[]) { - int ret; int i; - const void *p_shm; + void *p_shm; size_t data_len; long line_total; const void *p_data; const long *p_line_offsets; - FILE *fp; if (log_begin("../log/bbsd.log", "../log/error.log") < 0) { @@ -50,32 +46,6 @@ int main(int argc, char *argv[]) log_common_redir(STDOUT_FILENO); log_error_redir(STDERR_FILENO); - if ((fp = fopen(TRIE_DICT_SHM_FILE, "w")) == NULL) - { - log_error("fopen(%s) error\n", TRIE_DICT_SHM_FILE); - return -1; - } - fclose(fp); - - if (trie_dict_init(TRIE_DICT_SHM_FILE, TRIE_NODE_PER_POOL) < 0) - { - printf("trie_dict_init failed\n"); - return -1; - } - - ret = file_loader_init(); - if (ret < 0) - { - printf("file_loader_init() error (%d)\n", ret); - return ret; - } - - ret = file_loader_init(); - if (ret == 0) - { - printf("Rerun file_loader_init() error\n"); - } - printf("Testing #1\n"); for (i = 0; i < files_cnt; i++) @@ -103,7 +73,7 @@ int main(int argc, char *argv[]) if (detach_file_shm(p_shm) < 0) { - log_error("detach_file_shm(%s) error\n", files[i]); + log_error("detach_file_shm(%s) error", files[i]); } } } @@ -153,23 +123,12 @@ int main(int argc, char *argv[]) if (detach_file_shm(p_shm) < 0) { - log_error("detach_file_shm(%s) error\n", files[i]); + log_error("detach_file_shm(%s) error", files[i]); } } } } - file_loader_cleanup(); - file_loader_cleanup(); - - trie_dict_cleanup(); - - if (unlink(TRIE_DICT_SHM_FILE) < 0) - { - log_error("unlink(%s) error\n", TRIE_DICT_SHM_FILE); - return -1; - } - log_end(); return 0;