2023-03-08 15:16:05 +00:00
|
|
|
#include "test_common.h"
|
|
|
|
TEST_START
|
|
|
|
|
|
|
|
#include "PikaCompiler.h"
|
2023-03-09 11:20:51 +08:00
|
|
|
|
2023-03-23 16:30:26 +08:00
|
|
|
TEST(packtool, pack_unpack) {
|
2023-03-23 16:47:22 +08:00
|
|
|
PIKA_RES res = pikafs_pack_files(
|
|
|
|
"test/out/a.pack", 3, "test/assets/test.txt",
|
|
|
|
"test/assets/widget_config.ini", "test/assets/test.jpg");
|
|
|
|
pikafs_unpack_files("test/out/a.pack", "test/out/unpack");
|
2023-03-08 15:16:05 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(res, PIKA_RES_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(packtool, packread) {
|
|
|
|
size_t n = 0;
|
2023-03-23 16:56:25 +08:00
|
|
|
// Arg* fileArg = NULL;
|
|
|
|
pikafs_pack_files("test/out/a2.pack", 3, "test/assets/test.txt",
|
|
|
|
"test/assets/widget_config.ini", "test/assets/test.jpg");
|
|
|
|
pikafs_FILE* pack_file = pikafs_fopen_pack("test/out/a2.pack", "test.txt");
|
|
|
|
// pikafs_FILE* pack_file = pikafs_fopen_pack_new(&fileArg,
|
|
|
|
// "test/assets/a.pack", "main.py");
|
|
|
|
FILE* file = pika_platform_fopen("test/out/unpack/test2.txt", "wb+");
|
2023-03-08 15:16:05 +00:00
|
|
|
if (NULL == file) {
|
2023-03-23 16:56:25 +08:00
|
|
|
pika_platform_printf("open file: %s error\r\n",
|
|
|
|
"test/out/unpack/test2.txt");
|
2023-03-08 15:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
n = pika_platform_fwrite(pack_file->addr, pack_file->size, 1, file);
|
|
|
|
EXPECT_NE(n, 0);
|
|
|
|
|
2023-03-23 16:56:25 +08:00
|
|
|
// arg_deinit(fileArg);
|
2023-03-08 15:16:05 +00:00
|
|
|
pikaFree(pack_file, sizeof(pikafs_FILE));
|
|
|
|
pika_platform_fclose(file);
|
|
|
|
pack_file = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_END
|