2023-04-23 20:09:27 +08:00
|
|
|
#include "test_common.h"
|
|
|
|
TEST_START
|
|
|
|
|
|
|
|
#include "PikaCompiler.h"
|
|
|
|
// TEST(packtool, unpack) {
|
|
|
|
|
2023-07-03 00:30:28 +08:00
|
|
|
//PIKA_RES res = pikafs_unpack_files("test/out/packout/a0424.pack", "test/out/unpackout/");
|
2023-04-23 20:09:27 +08:00
|
|
|
|
|
|
|
// EXPECT_EQ(res, PIKA_RES_OK);
|
|
|
|
// }
|
|
|
|
|
|
|
|
TEST(packtool, packfiles) {
|
|
|
|
|
|
|
|
PikaMaker* maker = New_PikaMaker();
|
|
|
|
PIKA_RES ret = PIKA_RES_OK;
|
|
|
|
|
2023-07-06 03:03:46 +08:00
|
|
|
pikaMaker_linkRaw_New(maker, "test/assets/test.txt", "/txt-file");
|
|
|
|
pikaMaker_linkRaw_New(maker, "test/assets/test.jpg", "/bmp-file");
|
2023-04-23 20:09:27 +08:00
|
|
|
|
2023-07-03 00:30:28 +08:00
|
|
|
// create "./test/out/packout" path if not exist
|
|
|
|
ret = pikaMaker_linkCompiledModulesFullPath(maker, "./test/out/packout/a0424.pack");
|
2023-04-23 20:09:27 +08:00
|
|
|
|
2023-04-24 13:28:00 +08:00
|
|
|
pikaMaker_deinit(maker);
|
2023-04-23 20:09:27 +08:00
|
|
|
EXPECT_EQ(ret, PIKA_RES_OK);
|
|
|
|
}
|
|
|
|
|
2023-04-24 13:28:00 +08:00
|
|
|
TEST(packtool, packread) {
|
|
|
|
size_t n = 0;
|
|
|
|
//Arg* fileArg = NULL;
|
2023-07-06 03:03:46 +08:00
|
|
|
pikafs_FILE* pack_file = pikafs_fopen_pack("test/out/packout/a0424.pack", "test.txt");
|
2023-07-02 23:02:50 +08:00
|
|
|
if (NULL == pack_file) {
|
2023-07-03 00:30:28 +08:00
|
|
|
pika_platform_printf("open file: %s error\r\n", "test/out/packout/a0424.pack");
|
2023-07-02 23:02:50 +08:00
|
|
|
}
|
|
|
|
|
2023-04-24 13:28:00 +08:00
|
|
|
FILE* file = pika_platform_fopen("test/out/unpackout/file3_test.txt", "wb+");
|
|
|
|
if (NULL == file) {
|
|
|
|
pika_platform_printf("open file: %s error\r\n", "test/out/unpackout/file3_test.txt");
|
|
|
|
}
|
2023-04-23 20:09:27 +08:00
|
|
|
|
2023-07-02 23:02:50 +08:00
|
|
|
n = pika_platform_fwrite(pack_file->addr, pack_file->size , 1, file);
|
2023-04-23 20:09:27 +08:00
|
|
|
|
2023-07-02 23:02:50 +08:00
|
|
|
arg_deinit(pack_file->farg);
|
2023-04-24 13:28:00 +08:00
|
|
|
pikaFree(pack_file, sizeof(pikafs_FILE));
|
|
|
|
pika_platform_fclose(file);
|
|
|
|
pack_file = NULL;
|
2023-07-02 23:02:50 +08:00
|
|
|
EXPECT_NE(n, 0);
|
|
|
|
}
|
2023-04-24 13:28:00 +08:00
|
|
|
|
2023-07-02 23:02:50 +08:00
|
|
|
TEST(packtool, packreadErr) {
|
|
|
|
pikafs_FILE* pack_file = pikafs_fopen_pack("test/out/packout/0425.pack", "file3.txt");
|
|
|
|
if (NULL == pack_file) {
|
2023-07-03 00:30:28 +08:00
|
|
|
pika_platform_printf("open file: %s error\r\n", "test/out/packout/a0424.pack");
|
2023-07-02 23:02:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_TRUE(!pack_file);
|
2023-04-24 13:28:00 +08:00
|
|
|
}
|
2023-04-23 20:09:27 +08:00
|
|
|
|
|
|
|
TEST_END
|