mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
fix linklibrary open pikafs issue
This commit is contained in:
parent
d5796cd56e
commit
e3f1c3b26e
3
port/linux/.vscode/launch.json
vendored
3
port/linux/.vscode/launch.json
vendored
@ -23,7 +23,8 @@
|
|||||||
// "--gtest_filter=except.try_import_except"
|
// "--gtest_filter=except.try_import_except"
|
||||||
// "--gtest_filter=vm.test_cmodule_import_as"
|
// "--gtest_filter=vm.test_cmodule_import_as"
|
||||||
// "--gtest_filter=vm.subsrc_import"
|
// "--gtest_filter=vm.subsrc_import"
|
||||||
"--gtest_filter=event.event_thread"
|
// "--gtest_filter=event.event_thread"
|
||||||
|
"--gtest_filter=stddata.pikafs_open"
|
||||||
],
|
],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
|
@ -550,6 +550,26 @@ TEST(stddata, pikafs_open) {
|
|||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(stddata, pikafs_open_libfile) {
|
||||||
|
/* init */
|
||||||
|
g_PikaMemInfo.heapUsedMax = 0;
|
||||||
|
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||||
|
obj_linkLibraryFile(pikaMain,
|
||||||
|
"package/pikascript/pikascript-api/pikaModules.py.a");
|
||||||
|
/* run */
|
||||||
|
__platform_printf("BEGIN\r\n");
|
||||||
|
obj_run(pikaMain,
|
||||||
|
"f = open('/pikafs/widget_config.ini','r')\n"
|
||||||
|
"f.read(8)\n"
|
||||||
|
"f.close()\n");
|
||||||
|
/* collect */
|
||||||
|
/* assert */
|
||||||
|
EXPECT_STREQ(log_buff[0], "'[端口]'\r\n");
|
||||||
|
/* deinit */
|
||||||
|
obj_deinit(pikaMain);
|
||||||
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(stddata, pikafs_open_err) {
|
TEST(stddata, pikafs_open_err) {
|
||||||
/* init */
|
/* init */
|
||||||
g_PikaMemInfo.heapUsedMax = 0;
|
g_PikaMemInfo.heapUsedMax = 0;
|
||||||
|
@ -704,6 +704,7 @@ int LibObj_loadLibrary(LibObj* self, uint8_t* library_bytes) {
|
|||||||
&bytecode_addr, &bytecode_size);
|
&bytecode_addr, &bytecode_size);
|
||||||
LibObj_dynamicLink(self, module_name, bytecode_addr);
|
LibObj_dynamicLink(self, module_name, bytecode_addr);
|
||||||
}
|
}
|
||||||
|
obj_setPtr(self, "@libraw", library_bytes);
|
||||||
return PIKA_RES_OK;
|
return PIKA_RES_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1428,8 +1429,7 @@ pikafs_FILE* pikafs_fopen(char* file_name, char* mode) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(f, 0, sizeof(pikafs_FILE));
|
memset(f, 0, sizeof(pikafs_FILE));
|
||||||
extern volatile PikaObj* __pikaMain;
|
uint8_t* library_bytes = obj_getPtr(pika_getLibObj(), "@libraw");
|
||||||
uint8_t* library_bytes = obj_getPtr((PikaObj*)__pikaMain, "@libraw");
|
|
||||||
if (NULL == library_bytes) {
|
if (NULL == library_bytes) {
|
||||||
goto __error;
|
goto __error;
|
||||||
}
|
}
|
||||||
|
@ -2649,7 +2649,6 @@ PikaObj* obj_linkLibrary(PikaObj* self, uint8_t* library_bytes) {
|
|||||||
obj_newMetaObj(self, "@lib", New_LibObj);
|
obj_newMetaObj(self, "@lib", New_LibObj);
|
||||||
LibObj* lib = obj_getObj(self, "@lib");
|
LibObj* lib = obj_getObj(self, "@lib");
|
||||||
LibObj_loadLibrary(lib, library_bytes);
|
LibObj_loadLibrary(lib, library_bytes);
|
||||||
obj_setPtr(self, "@libraw", library_bytes);
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
#define PIKA_VERSION_MINOR 13
|
#define PIKA_VERSION_MINOR 13
|
||||||
#define PIKA_VERSION_MICRO 2
|
#define PIKA_VERSION_MICRO 2
|
||||||
|
|
||||||
#define PIKA_EDIT_TIME "2024/02/19 23:56:25"
|
#define PIKA_EDIT_TIME "2024/02/25 00:24:24"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user