1800b99b8Sopenharmony_ci/* 2800b99b8Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 3800b99b8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4800b99b8Sopenharmony_ci * you may not use this file except in compliance with the License. 5800b99b8Sopenharmony_ci * You may obtain a copy of the License at 6800b99b8Sopenharmony_ci * 7800b99b8Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8800b99b8Sopenharmony_ci * 9800b99b8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10800b99b8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11800b99b8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12800b99b8Sopenharmony_ci * See the License for the specific language governing permissions and 13800b99b8Sopenharmony_ci * limitations under the License. 14800b99b8Sopenharmony_ci */ 15800b99b8Sopenharmony_ci#include <gtest/gtest.h> 16800b99b8Sopenharmony_ci 17800b99b8Sopenharmony_ci#include <cstdio> 18800b99b8Sopenharmony_ci#include <dlfcn.h> 19800b99b8Sopenharmony_ci#include <cstdint> 20800b99b8Sopenharmony_ci 21800b99b8Sopenharmony_ci#include "dfx_ark.h" 22800b99b8Sopenharmony_ci#include "dfx_log.h" 23800b99b8Sopenharmony_ci 24800b99b8Sopenharmony_ciusing namespace testing; 25800b99b8Sopenharmony_ciusing namespace testing::ext; 26800b99b8Sopenharmony_ciusing namespace std; 27800b99b8Sopenharmony_ci 28800b99b8Sopenharmony_cinamespace OHOS { 29800b99b8Sopenharmony_cinamespace HiviewDFX { 30800b99b8Sopenharmony_cinamespace { 31800b99b8Sopenharmony_ciconst char ARK_LIB_NAME[] = "libark_jsruntime.so"; 32800b99b8Sopenharmony_ci 33800b99b8Sopenharmony_civoid* g_handle = nullptr; 34800b99b8Sopenharmony_cipthread_mutex_t g_mutex; 35800b99b8Sopenharmony_ciint (*g_getArkNativeFrameInfoFn)(int, uintptr_t*, uintptr_t*, uintptr_t*, JsFrame*, size_t&); 36800b99b8Sopenharmony_ciint (*g_stepArkFn)(void*, OHOS::HiviewDFX::ReadMemFunc, uintptr_t*, uintptr_t*, uintptr_t*, uintptr_t*, bool*); 37800b99b8Sopenharmony_ciint (*g_stepArkWithJitFn)(OHOS::HiviewDFX::ArkUnwindParam*); 38800b99b8Sopenharmony_ciint (*g_jitCodeWriteFileFn)(void*, OHOS::HiviewDFX::ReadMemFunc, int, const uintptr_t* const, const size_t); 39800b99b8Sopenharmony_ciint (*g_parseArkFileInfoFn)(uintptr_t, uintptr_t, uintptr_t, const char*, uintptr_t, JsFunction*); 40800b99b8Sopenharmony_ciint (*g_parseArkFrameInfoLocalFn)(uintptr_t, uintptr_t, uintptr_t, uintptr_t, JsFunction*); 41800b99b8Sopenharmony_ciint (*g_parseArkFrameInfoFn)(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uint8_t*, uint64_t, uintptr_t, JsFunction*); 42800b99b8Sopenharmony_ciint (*g_arkCreateJsSymbolExtractorFn)(uintptr_t*); 43800b99b8Sopenharmony_ciint (*g_arkDestoryJsSymbolExtractorFn)(uintptr_t); 44800b99b8Sopenharmony_ciint (*g_arkDestoryLocalFn)(); 45800b99b8Sopenharmony_ciusing RustDemangleFn = char*(*)(const char *); 46800b99b8Sopenharmony_ciRustDemangleFn g_rustDemangleFn = nullptr; 47800b99b8Sopenharmony_ci 48800b99b8Sopenharmony_cibool GetLibArkHandle() 49800b99b8Sopenharmony_ci{ 50800b99b8Sopenharmony_ci if (g_handle != nullptr) { 51800b99b8Sopenharmony_ci return true; 52800b99b8Sopenharmony_ci } 53800b99b8Sopenharmony_ci g_handle = dlopen(ARK_LIB_NAME, RTLD_LAZY); 54800b99b8Sopenharmony_ci if (g_handle == nullptr) { 55800b99b8Sopenharmony_ci DFXLOGU("Failed to load library(%{public}s).", dlerror()); 56800b99b8Sopenharmony_ci return false; 57800b99b8Sopenharmony_ci } 58800b99b8Sopenharmony_ci return true; 59800b99b8Sopenharmony_ci} 60800b99b8Sopenharmony_ci} // namespace 61800b99b8Sopenharmony_ci 62800b99b8Sopenharmony_ci#define DLSYM_ARK_FUNC(FuncName, DlsymFuncName) { \ 63800b99b8Sopenharmony_ci pthread_mutex_lock(&g_mutex); \ 64800b99b8Sopenharmony_ci do { \ 65800b99b8Sopenharmony_ci if (!GetLibArkHandle()) { \ 66800b99b8Sopenharmony_ci break; \ 67800b99b8Sopenharmony_ci } \ 68800b99b8Sopenharmony_ci *reinterpret_cast<void**>(&(DlsymFuncName)) = dlsym(g_handle, (FuncName)); \ 69800b99b8Sopenharmony_ci } while (false); \ 70800b99b8Sopenharmony_ci pthread_mutex_unlock(&g_mutex); \ 71800b99b8Sopenharmony_ci} 72800b99b8Sopenharmony_ci 73800b99b8Sopenharmony_ciclass ArkTest : public testing::Test { 74800b99b8Sopenharmony_cipublic: 75800b99b8Sopenharmony_ci static void SetUpTestCase() {} 76800b99b8Sopenharmony_ci static void TearDownTestCase() {} 77800b99b8Sopenharmony_ci void SetUp() {} 78800b99b8Sopenharmony_ci void TearDown() {} 79800b99b8Sopenharmony_ci}; 80800b99b8Sopenharmony_ci 81800b99b8Sopenharmony_ci/** 82800b99b8Sopenharmony_ci * @tc.name: ArkTest001 83800b99b8Sopenharmony_ci * @tc.desc: test ArkCreateJsSymbolExtractor functions 84800b99b8Sopenharmony_ci * @tc.type: FUNC 85800b99b8Sopenharmony_ci */ 86800b99b8Sopenharmony_ciHWTEST_F(ArkTest, ArkTest001, TestSize.Level2) 87800b99b8Sopenharmony_ci{ 88800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest001: start."; 89800b99b8Sopenharmony_ci uintptr_t zero = 0; 90800b99b8Sopenharmony_ci uintptr_t* extractorPtr = &zero; 91800b99b8Sopenharmony_ci const char* arkFuncName = "ark_create_js_symbol_extractor"; 92800b99b8Sopenharmony_ci DLSYM_ARK_FUNC(arkFuncName, g_arkCreateJsSymbolExtractorFn) 93800b99b8Sopenharmony_ci ASSERT_NE(g_arkCreateJsSymbolExtractorFn, nullptr); 94800b99b8Sopenharmony_ci g_arkCreateJsSymbolExtractorFn(extractorPtr); 95800b99b8Sopenharmony_ci g_arkCreateJsSymbolExtractorFn = nullptr; 96800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest001: end."; 97800b99b8Sopenharmony_ci} 98800b99b8Sopenharmony_ci 99800b99b8Sopenharmony_ci/** 100800b99b8Sopenharmony_ci * @tc.name: ArkTest002 101800b99b8Sopenharmony_ci * @tc.desc: test ArkDestoryJsSymbolExtractor functions 102800b99b8Sopenharmony_ci * @tc.type: FUNC 103800b99b8Sopenharmony_ci */ 104800b99b8Sopenharmony_ciHWTEST_F(ArkTest, ArkTest002, TestSize.Level2) 105800b99b8Sopenharmony_ci{ 106800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest002: start."; 107800b99b8Sopenharmony_ci uintptr_t extractorPtr = 0; 108800b99b8Sopenharmony_ci const char* arkFuncName = "ark_destory_js_symbol_extractor"; 109800b99b8Sopenharmony_ci DLSYM_ARK_FUNC(arkFuncName, g_arkDestoryJsSymbolExtractorFn) 110800b99b8Sopenharmony_ci ASSERT_NE(g_arkDestoryJsSymbolExtractorFn, nullptr); 111800b99b8Sopenharmony_ci g_arkDestoryJsSymbolExtractorFn(extractorPtr); 112800b99b8Sopenharmony_ci g_arkDestoryJsSymbolExtractorFn = nullptr; 113800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest002: end."; 114800b99b8Sopenharmony_ci} 115800b99b8Sopenharmony_ci 116800b99b8Sopenharmony_ci/** 117800b99b8Sopenharmony_ci * @tc.name: ArkTest003 118800b99b8Sopenharmony_ci * @tc.desc: test ParseArkFileInfo functions 119800b99b8Sopenharmony_ci * @tc.type: FUNC 120800b99b8Sopenharmony_ci */ 121800b99b8Sopenharmony_ciHWTEST_F(ArkTest, ArkTest003, TestSize.Level2) 122800b99b8Sopenharmony_ci{ 123800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest003: start."; 124800b99b8Sopenharmony_ci uintptr_t byteCodePc = 0; 125800b99b8Sopenharmony_ci uintptr_t methodid = 0; 126800b99b8Sopenharmony_ci uintptr_t mapBase = 0; 127800b99b8Sopenharmony_ci const char* name = nullptr; 128800b99b8Sopenharmony_ci uintptr_t extractorPtr = 0; 129800b99b8Sopenharmony_ci JsFunction *jsFunction = nullptr; 130800b99b8Sopenharmony_ci const char* arkFuncName = "ark_parse_js_file_info"; 131800b99b8Sopenharmony_ci DLSYM_ARK_FUNC(arkFuncName, g_parseArkFileInfoFn) 132800b99b8Sopenharmony_ci ASSERT_NE(g_parseArkFileInfoFn, nullptr); 133800b99b8Sopenharmony_ci g_parseArkFileInfoFn(byteCodePc, methodid, mapBase, name, extractorPtr, jsFunction); 134800b99b8Sopenharmony_ci g_parseArkFileInfoFn = nullptr; 135800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest003: end."; 136800b99b8Sopenharmony_ci} 137800b99b8Sopenharmony_ci 138800b99b8Sopenharmony_ci/** 139800b99b8Sopenharmony_ci * @tc.name: ArkTest004 140800b99b8Sopenharmony_ci * @tc.desc: test ParseArkFrameInfoLocal functions 141800b99b8Sopenharmony_ci * @tc.type: FUNC 142800b99b8Sopenharmony_ci */ 143800b99b8Sopenharmony_ciHWTEST_F(ArkTest, ArkTest004, TestSize.Level2) 144800b99b8Sopenharmony_ci{ 145800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest004: start."; 146800b99b8Sopenharmony_ci uintptr_t byteCodePc = 0; 147800b99b8Sopenharmony_ci uintptr_t methodid = 0; 148800b99b8Sopenharmony_ci uintptr_t mapBase = 0; 149800b99b8Sopenharmony_ci uintptr_t offset = 0; 150800b99b8Sopenharmony_ci JsFunction *jsFunction = nullptr; 151800b99b8Sopenharmony_ci const char* arkFuncName = "ark_parse_js_frame_info_local"; 152800b99b8Sopenharmony_ci DLSYM_ARK_FUNC(arkFuncName, g_parseArkFrameInfoLocalFn) 153800b99b8Sopenharmony_ci ASSERT_NE(g_parseArkFrameInfoLocalFn, nullptr); 154800b99b8Sopenharmony_ci g_parseArkFrameInfoLocalFn(byteCodePc, methodid, mapBase, offset, jsFunction); 155800b99b8Sopenharmony_ci g_parseArkFrameInfoLocalFn = nullptr; 156800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest004: end."; 157800b99b8Sopenharmony_ci} 158800b99b8Sopenharmony_ci 159800b99b8Sopenharmony_ci/** 160800b99b8Sopenharmony_ci * @tc.name: ArkTest005 161800b99b8Sopenharmony_ci * @tc.desc: test ParseArkFrameInfo functions 162800b99b8Sopenharmony_ci * @tc.type: FUNC 163800b99b8Sopenharmony_ci */ 164800b99b8Sopenharmony_ciHWTEST_F(ArkTest, ArkTest005, TestSize.Level2) 165800b99b8Sopenharmony_ci{ 166800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest005: start."; 167800b99b8Sopenharmony_ci uintptr_t byteCodePc = 0; 168800b99b8Sopenharmony_ci uintptr_t methodid = 0; 169800b99b8Sopenharmony_ci uintptr_t mapBase = 0; 170800b99b8Sopenharmony_ci uintptr_t loadOffset = 0; 171800b99b8Sopenharmony_ci uint8_t *data = nullptr; 172800b99b8Sopenharmony_ci uint64_t dataSize = 0; 173800b99b8Sopenharmony_ci uintptr_t extractorPtr = 0; 174800b99b8Sopenharmony_ci JsFunction *jsFunction = nullptr; 175800b99b8Sopenharmony_ci const char* arkFuncName = "ark_parse_js_frame_info"; 176800b99b8Sopenharmony_ci DLSYM_ARK_FUNC(arkFuncName, g_parseArkFrameInfoFn) 177800b99b8Sopenharmony_ci ASSERT_NE(g_parseArkFrameInfoFn, nullptr); 178800b99b8Sopenharmony_ci g_parseArkFrameInfoFn(byteCodePc, methodid, mapBase, loadOffset, data, dataSize, extractorPtr, jsFunction); 179800b99b8Sopenharmony_ci g_parseArkFrameInfoFn = nullptr; 180800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest005: end."; 181800b99b8Sopenharmony_ci} 182800b99b8Sopenharmony_ci 183800b99b8Sopenharmony_ci/** 184800b99b8Sopenharmony_ci * @tc.name: ArkTest006 185800b99b8Sopenharmony_ci * @tc.desc: test StepArkFrame functions 186800b99b8Sopenharmony_ci * @tc.type: FUNC 187800b99b8Sopenharmony_ci */ 188800b99b8Sopenharmony_ciHWTEST_F(ArkTest, ArkTest006, TestSize.Level2) 189800b99b8Sopenharmony_ci{ 190800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest006: start."; 191800b99b8Sopenharmony_ci pid_t pid = fork(); 192800b99b8Sopenharmony_ci if (pid == 0) { 193800b99b8Sopenharmony_ci uintptr_t zero = 0; 194800b99b8Sopenharmony_ci void *obj = nullptr; 195800b99b8Sopenharmony_ci OHOS::HiviewDFX::ReadMemFunc readMemFn = nullptr; 196800b99b8Sopenharmony_ci uintptr_t *fp = &zero; 197800b99b8Sopenharmony_ci uintptr_t *sp = &zero; 198800b99b8Sopenharmony_ci uintptr_t *pc = &zero; 199800b99b8Sopenharmony_ci uintptr_t* methodid = &zero; 200800b99b8Sopenharmony_ci bool *isJsFrame = nullptr; 201800b99b8Sopenharmony_ci const char* arkFuncName = "step_ark"; 202800b99b8Sopenharmony_ci DLSYM_ARK_FUNC(arkFuncName, g_stepArkFn) 203800b99b8Sopenharmony_ci ASSERT_NE(g_stepArkFn, nullptr); 204800b99b8Sopenharmony_ci g_stepArkFn(obj, readMemFn, fp, sp, pc, methodid, isJsFrame); 205800b99b8Sopenharmony_ci g_stepArkFn = nullptr; 206800b99b8Sopenharmony_ci ASSERT_NE(g_handle, nullptr); 207800b99b8Sopenharmony_ci const char* arkFuncName1 = "ark_destory_local"; 208800b99b8Sopenharmony_ci pthread_mutex_lock(&g_mutex); 209800b99b8Sopenharmony_ci *reinterpret_cast<void**>(&(g_arkDestoryLocalFn)) = dlsym(g_handle, arkFuncName1); 210800b99b8Sopenharmony_ci pthread_mutex_unlock(&g_mutex); 211800b99b8Sopenharmony_ci ASSERT_NE(g_arkDestoryLocalFn, nullptr); 212800b99b8Sopenharmony_ci g_arkDestoryLocalFn(); 213800b99b8Sopenharmony_ci g_arkDestoryLocalFn = nullptr; 214800b99b8Sopenharmony_ci exit(0); 215800b99b8Sopenharmony_ci } 216800b99b8Sopenharmony_ci int status; 217800b99b8Sopenharmony_ci bool isSuccess = waitpid(pid, &status, 0) != -1; 218800b99b8Sopenharmony_ci if (!isSuccess) { 219800b99b8Sopenharmony_ci ASSERT_FALSE(isSuccess); 220800b99b8Sopenharmony_ci return; 221800b99b8Sopenharmony_ci } 222800b99b8Sopenharmony_ci 223800b99b8Sopenharmony_ci int exitCode = -1; 224800b99b8Sopenharmony_ci if (WIFEXITED(status)) { 225800b99b8Sopenharmony_ci exitCode = WEXITSTATUS(status); 226800b99b8Sopenharmony_ci printf("Exit status was %d\n", exitCode); 227800b99b8Sopenharmony_ci } 228800b99b8Sopenharmony_ci ASSERT_EQ(exitCode, 0); 229800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest006: end."; 230800b99b8Sopenharmony_ci} 231800b99b8Sopenharmony_ci 232800b99b8Sopenharmony_ci/** 233800b99b8Sopenharmony_ci * @tc.name: ArkTest007 234800b99b8Sopenharmony_ci * @tc.desc: test StepArkFrameWithJit functions 235800b99b8Sopenharmony_ci * @tc.type: FUNC 236800b99b8Sopenharmony_ci */ 237800b99b8Sopenharmony_ciHWTEST_F(ArkTest, ArkTest007, TestSize.Level2) 238800b99b8Sopenharmony_ci{ 239800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest007: start."; 240800b99b8Sopenharmony_ci uintptr_t zero = 0; 241800b99b8Sopenharmony_ci void *ctx = &zero; 242800b99b8Sopenharmony_ci ReadMemFunc readMem = nullptr; 243800b99b8Sopenharmony_ci uintptr_t *fp = &zero; 244800b99b8Sopenharmony_ci uintptr_t *sp = &zero; 245800b99b8Sopenharmony_ci uintptr_t *pc = &zero; 246800b99b8Sopenharmony_ci uintptr_t *methodId = &zero; 247800b99b8Sopenharmony_ci bool *isJsFrame = nullptr; 248800b99b8Sopenharmony_ci std::vector<uintptr_t> vec; 249800b99b8Sopenharmony_ci std::vector<uintptr_t>& jitCache = vec; 250800b99b8Sopenharmony_ci OHOS::HiviewDFX::ArkUnwindParam ark(ctx, readMem, fp, sp, pc, methodId, isJsFrame, jitCache); 251800b99b8Sopenharmony_ci OHOS::HiviewDFX::ArkUnwindParam* arkPrama = &ark; 252800b99b8Sopenharmony_ci const char* const arkFuncName = "step_ark_with_record_jit"; 253800b99b8Sopenharmony_ci DLSYM_ARK_FUNC(arkFuncName, g_stepArkWithJitFn) 254800b99b8Sopenharmony_ci ASSERT_NE(g_stepArkWithJitFn, nullptr); 255800b99b8Sopenharmony_ci g_stepArkWithJitFn(arkPrama); 256800b99b8Sopenharmony_ci g_stepArkWithJitFn = nullptr; 257800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest007: end."; 258800b99b8Sopenharmony_ci} 259800b99b8Sopenharmony_ci 260800b99b8Sopenharmony_ci/** 261800b99b8Sopenharmony_ci * @tc.name: ArkTest008 262800b99b8Sopenharmony_ci * @tc.desc: test JitCodeWriteFile functions 263800b99b8Sopenharmony_ci * @tc.type: FUNC 264800b99b8Sopenharmony_ci */ 265800b99b8Sopenharmony_ciHWTEST_F(ArkTest, ArkTest008, TestSize.Level2) 266800b99b8Sopenharmony_ci{ 267800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest008: start."; 268800b99b8Sopenharmony_ci void* ctx = nullptr; 269800b99b8Sopenharmony_ci OHOS::HiviewDFX::ReadMemFunc readMemFn = nullptr; 270800b99b8Sopenharmony_ci int fd = -1; 271800b99b8Sopenharmony_ci const uintptr_t* const jitCodeArray = nullptr; 272800b99b8Sopenharmony_ci const size_t jitSize = 0; 273800b99b8Sopenharmony_ci const char* const arkFuncName = "ark_write_jit_code"; 274800b99b8Sopenharmony_ci DLSYM_ARK_FUNC(arkFuncName, g_jitCodeWriteFileFn) 275800b99b8Sopenharmony_ci ASSERT_NE(g_jitCodeWriteFileFn, nullptr); 276800b99b8Sopenharmony_ci g_jitCodeWriteFileFn(ctx, readMemFn, fd, jitCodeArray, jitSize); 277800b99b8Sopenharmony_ci g_jitCodeWriteFileFn = nullptr; 278800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest008: end."; 279800b99b8Sopenharmony_ci} 280800b99b8Sopenharmony_ci 281800b99b8Sopenharmony_ci/** 282800b99b8Sopenharmony_ci * @tc.name: ArkTest009 283800b99b8Sopenharmony_ci * @tc.desc: test GetArkNativeFrameInfo functions 284800b99b8Sopenharmony_ci * @tc.type: FUNC 285800b99b8Sopenharmony_ci */ 286800b99b8Sopenharmony_ciHWTEST_F(ArkTest, ArkTest009, TestSize.Level2) 287800b99b8Sopenharmony_ci{ 288800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest009: start."; 289800b99b8Sopenharmony_ci int pid = 0; 290800b99b8Sopenharmony_ci uintptr_t zero = 0; 291800b99b8Sopenharmony_ci uintptr_t& pc = zero; 292800b99b8Sopenharmony_ci uintptr_t& fp = zero; 293800b99b8Sopenharmony_ci uintptr_t& sp = zero; 294800b99b8Sopenharmony_ci JsFrame* frames = nullptr; 295800b99b8Sopenharmony_ci size_t& size = zero; 296800b99b8Sopenharmony_ci const char* arkFuncName = "get_ark_native_frame_info"; 297800b99b8Sopenharmony_ci DLSYM_ARK_FUNC(arkFuncName, g_getArkNativeFrameInfoFn) 298800b99b8Sopenharmony_ci ASSERT_NE(g_getArkNativeFrameInfoFn, nullptr); 299800b99b8Sopenharmony_ci g_getArkNativeFrameInfoFn(pid, &pc, &fp, &sp, frames, size); 300800b99b8Sopenharmony_ci g_getArkNativeFrameInfoFn = nullptr; 301800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest009: end."; 302800b99b8Sopenharmony_ci} 303800b99b8Sopenharmony_ci 304800b99b8Sopenharmony_ci/** 305800b99b8Sopenharmony_ci * @tc.name: ArkTest010 306800b99b8Sopenharmony_ci * @tc.desc: test rustc_demangle functions 307800b99b8Sopenharmony_ci * @tc.type: FUNC 308800b99b8Sopenharmony_ci */ 309800b99b8Sopenharmony_ciHWTEST_F(ArkTest, ArkTest010, TestSize.Level2) 310800b99b8Sopenharmony_ci{ 311800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest010: start."; 312800b99b8Sopenharmony_ci void* handle = dlopen("librustc_demangle.z.so", RTLD_LAZY | RTLD_NODELETE); 313800b99b8Sopenharmony_ci ASSERT_TRUE(handle) << "Failed to dlopen librustc_demangle"; 314800b99b8Sopenharmony_ci g_rustDemangleFn = (RustDemangleFn)dlsym(handle, "rustc_demangle"); 315800b99b8Sopenharmony_ci ASSERT_TRUE(g_rustDemangleFn) << "Failed to dlsym rustc_demangle"; 316800b99b8Sopenharmony_ci std::string reason = "reason"; 317800b99b8Sopenharmony_ci const char *bufStr = reason.c_str(); 318800b99b8Sopenharmony_ci g_rustDemangleFn(bufStr); 319800b99b8Sopenharmony_ci g_rustDemangleFn = nullptr; 320800b99b8Sopenharmony_ci GTEST_LOG_(INFO) << "ArkTest010: end."; 321800b99b8Sopenharmony_ci} 322800b99b8Sopenharmony_ci} 323800b99b8Sopenharmony_ci}