| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
feat: add loadErrInfo for LoadNativeModule to return precise error info When NativeModule (so) loading fails, capture precise error information through the new loadErrInfo parameter, enabling JS Crash faultlog to display specific so loading failure details (dlopen failed reason, module not found, app lib path not registered, etc.). Changes: - Add SetLoadErrInfo helper for null-safe loadErrInfo writing - Add std::string* loadErrInfo parameter to LoadNativeModule and FindNativeModuleByDisk - Classify errors: dlopen failed, app lib path not registered, module not found, blocklist, internal errors - Clear stale dlerror before each dlopen/dlopen_ns call - Refactor mock: remove FindNativeModuleByDisk mock, add MockDiskCheckOnly - Add 10 test cases covering all error paths Reference: PR #2686 by yewei0794 Issue: openharmony/ability_ability_runtime#15447 Signed-off-by: zhang_hao_zheng <zhanghaozheng2@h-partners.com> Co-Authored-By: Agent Change-Id: I2d7a589a1642cb41f916708ac511832ca2d525a6 | 1 个月前 | |
test: add MockCheckModuleLoadable(true) to FindNativeModuleByDisk ErrInfo cases The four FindNativeModuleByDisk_ErrInfo_* test cases all failed on device with "module XXX is in blocklist" instead of the expected loadErrInfo strings. Root cause: ModuleManagerTest::SetUp() calls MockResetModuleManagerState(), which resets g_mockCheckModuleLoadable to false. The mock in mock_native_module_manager.cpp overrides ModuleLoadChecker::CheckModuleLoadable to return g_mockCheckModuleLoadable directly. So every test starts with CheckModuleLoadable returning false, hitting the blocklist branch at native_module_manager.cpp:1372-1377, which overwrites loadErrInfo with "module XXX is in blocklist". Fix: call MockCheckModuleLoadable(true) right after ASSERT_NE(nullptr, moduleManager) in each of the four cases, mirroring the pattern in the existing LoadNativeModuleTest_002 (module_manager_test.cpp:106). This unblocks the mock and lets the test reach the expected error classification path. Cases fixed: - FindNativeModuleByDisk_ErrInfo_ModuleNotFound - FindNativeModuleByDisk_ErrInfo_AppLibPathNotRegistered - FindNativeModuleByDisk_ErrInfo_LoadErrInfoNull - FindNativeModuleByDisk_ErrInfo_DlopenFailed The ModuleCreateFailed case was removed in the previous commit because even with the mock unblocked it cannot reach the "internal error: module create failed" branch (OOM-only path). Issue: https://gitcode.com/openharmony/arkui_napi/issues/2144 Signed-off-by: zhang_hao_zheng <zhanghaozheng2@h-partners.com> Co-Authored-By: Agent Change-Id: I45e764e5d75fb3019cb3adda044641b6236156e6 | 19 天前 |