From f42bdff32493255c2514c18e137b11f15f81ca14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E6=98=8C=E6=99=B6?= Date: Tue, 25 Mar 2025 14:05:14 +0800 Subject: [PATCH] delete CheckHiLogdLinked --- .../moduletest/common/hilog_base_ndk_test.cpp | 55 ------------------- 1 file changed, 55 deletions(-) diff --git a/test/moduletest/common/hilog_base_ndk_test.cpp b/test/moduletest/common/hilog_base_ndk_test.cpp index 9f91a7e..ce6b83e 100644 --- a/test/moduletest/common/hilog_base_ndk_test.cpp +++ b/test/moduletest/common/hilog_base_ndk_test.cpp @@ -146,57 +146,6 @@ bool CheckHiLogPrint(char *needToMatch) } return ret; } - -// Detects how many FDs are linked to hilogd. -int CheckHiLogdLinked() -{ - #define PROC_PATH_LENGTH (64) - int result = 0; - char procPath[PROC_PATH_LENGTH]; - int res = snprintf_s(procPath, PROC_PATH_LENGTH, PROC_PATH_LENGTH - 1, "/proc/%d/fd", getpid()); - if (res == NEGATIVE_ONE) { - printf("CheckHiLogdLinked getpid snprintf_s failed\n"); - return 0; - } - DIR *dir = opendir(procPath); - if (dir == nullptr) { - return result; - } - struct dirent *entry; - while ((entry = readdir(dir)) != nullptr) { - if (entry->d_type != DT_LNK) { - continue; - } - char fdPath[128]; - res = snprintf_s(fdPath, sizeof(fdPath), sizeof(fdPath) - 1, "%s/%s", procPath, entry->d_name); - if (res == NEGATIVE_ONE) { - printf("CheckHiLogdLinked fd search snprintf_s failed\n"); - return 0; - } - - char target[256]; - ssize_t len = readlink(fdPath, target, sizeof(target) - 1); - if (len == -1) { - continue; - } - target[len] = '\0'; - if (!strstr(target, "socket")) { - continue; - } - struct sockaddr_un addr; - socklen_t addrLen = sizeof(addr); - - // Obtains the peer address connected to the socket. - getpeername(atoi(entry->d_name), reinterpret_cast(&addr), &addrLen); - if (strstr(addr.sun_path, "hilogInput")) { - printf("FD: %s Connected to: %s\n", entry->d_name, addr.sun_path); - result++; - } - } - - closedir(dir); - return result; -} class HiLogBaseNDKTest : public testing::Test { public: @@ -353,10 +302,6 @@ HWTEST_F(HiLogBaseNDKTest, HilogBasePrintCheck, TestSize.Level1) bool result = CheckHiLogPrint(g_str[i].data()); EXPECT_EQ(result, true); } - - // Check the number of socket links to hilogInput. - int result = CheckHiLogdLinked(); - EXPECT_EQ(result, TWO); } } // namespace HiLogTest } // namespace HiviewDFX -- Gitee