Merged
[fix] 修复aarch64环境UT运行报错 #5664
JankinEEAdd on Sep 23
[fix] 修复aarch64环境UT运行报错 #5664
Merged
JankinEEAdd on Sep 23
Total: 68 files changed+174-112
@@ -28,7 +28,8 @@
28| 依赖 | 不涉及 | cmake/third_party/json.cmake | https://gitcode.com/cann-src-third-party/json/releases/download/v3.11.3/include.zip | 从 gitcode 下载 json 源码,作为编译依赖 |28| 依赖 | 不涉及 | cmake/third_party/json.cmake | https://gitcode.com/cann-src-third-party/json/releases/download/v3.11.3/include.zip | 从 gitcode 下载 json 源码,作为编译依赖 |
29| 依赖 | 不涉及 | cmake/third_party/openssl.cmake | https://gitcode.com/cann-src-third-party/openssl/releases/download/openssl-3.0.9/openssl-openssl-3.0.9.tar.gz | 从 gitcode 下载 openssl 源码,作为编译依赖 |29| 依赖 | 不涉及 | cmake/third_party/openssl.cmake | https://gitcode.com/cann-src-third-party/openssl/releases/download/openssl-3.0.9/openssl-openssl-3.0.9.tar.gz | 从 gitcode 下载 openssl 源码,作为编译依赖 |
30| 依赖 | 不涉及 | cmake/third_party/gtest.cmake | https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz | 从 gitcode 下载 googletest 源码,作为编译依赖 |30| 依赖 | 不涉及 | cmake/third_party/gtest.cmake | https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz | 从 gitcode 下载 googletest 源码,作为编译依赖 |
31-| 依赖 | 不涉及 | cmake/third_party/mockcpp.cmake | https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h4/mockcpp-2.7.tar.gz | 从 gitcode 下载 mockcpp 源码,作为编译依赖 |31+| 依赖 | 不涉及 | cmake/third_party/mockcpp.cmake | https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h6/mockcpp-2.7.tar.gz | 从 gitcode 下载 mockcpp 源码,作为编译依赖 |
JankinEE
JankinEEJankinEE26 days ago

[MEDIUM] 新增的mockcpp补丁公网URL未在「公网地址声明」中声明

本 PR 在 cmake/third_party/mockcpp.cmake:23 引入新公网 URL https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h6/mockcpp-2.7-h6.patch(经 PR diff 全量筛查,这是本 PR 唯一未声明的新增公网地址),但 SECURITY.md:31 仅声明了 mockcpp 源码包地址,未声明补丁地址;对照同表 rdma-core-patch(第34行)对补丁地址单独声明行的既有惯例,以及该表「本项目代码中包含的公网地址声明」的定位,此 URL 应补声明。修复建议:在 SECURITY.md 第31行 mockcpp 行后新增一行 mockcpp-patch 的声明(依赖 | 不涉及 | mockcpp-patch | https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h6/mockcpp-2.7-h6.patch | 从 gitcode 下载 mockcpp 补丁,作为编译依赖),并在 SECURITY_en.md:31 同步新增对应英文行。

likedislike
32+| 依赖 | 不涉及 | cmake/third_party/mockcpp.cmake | https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h6/mockcpp-2.7-h6.patch | 从 gitcode 下载 mockcpp 补丁,作为编译依赖 |
32| 依赖 | 不涉及 | cmake/third_party/protobuf.cmake | https://gitcode.com/cann-src-third-party/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz | 从 gitcode 下载 protobuf 源码,作为编译依赖 |33| 依赖 | 不涉及 | cmake/third_party/protobuf.cmake | https://gitcode.com/cann-src-third-party/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz | 从 gitcode 下载 protobuf 源码,作为编译依赖 |
33| 依赖 | 不涉及 | rdma-core | https://gitcode.com/cann-src-third-party/rdma-core/releases/download/v42.7-h1/rdma-core-42.7.tar.gz | 从 gitcode 下载 rdma-core 源码,作为编译依赖 |34| 依赖 | 不涉及 | rdma-core | https://gitcode.com/cann-src-third-party/rdma-core/releases/download/v42.7-h1/rdma-core-42.7.tar.gz | 从 gitcode 下载 rdma-core 源码,作为编译依赖 |
34| 依赖 | 不涉及 | rdma-core-patch | https://gitcode.com/cann-src-third-party/rdma-core/releases/download/v42.7-h1/rdma-core-42.7.patch | 从 gitcode 下载 rdma-core-patch 源码,作为编译依赖 |35| 依赖 | 不涉及 | rdma-core-patch | https://gitcode.com/cann-src-third-party/rdma-core/releases/download/v42.7-h1/rdma-core-42.7.patch | 从 gitcode 下载 rdma-core-patch 源码,作为编译依赖 |
@@ -28,7 +28,8 @@ The public URLs included in the code of this project are declared as follows:
28| Dependency | Not Applicable | cmake/third_party/json.cmake | https://gitcode.com/cann-src-third-party/json/releases/download/v3.11.3/include.zip | Download json source code from gitcode as a build dependency |28| Dependency | Not Applicable | cmake/third_party/json.cmake | https://gitcode.com/cann-src-third-party/json/releases/download/v3.11.3/include.zip | Download json source code from gitcode as a build dependency |
29| Dependency | Not Applicable | cmake/third_party/openssl.cmake | https://gitcode.com/cann-src-third-party/openssl/releases/download/openssl-3.0.9/openssl-openssl-3.0.9.tar.gz | Download openssl source code from gitcode as a build dependency |29| Dependency | Not Applicable | cmake/third_party/openssl.cmake | https://gitcode.com/cann-src-third-party/openssl/releases/download/openssl-3.0.9/openssl-openssl-3.0.9.tar.gz | Download openssl source code from gitcode as a build dependency |
30| Dependency | Not Applicable | cmake/third_party/gtest.cmake | https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz | Download googletest source code from gitcode as a build dependency |30| Dependency | Not Applicable | cmake/third_party/gtest.cmake | https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz | Download googletest source code from gitcode as a build dependency |
31-| Dependency | Not Applicable | cmake/third_party/mockcpp.cmake | https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h4/mockcpp-2.7.tar.gz | Download mockcpp source code from gitcode as a build dependency |31+| Dependency | Not Applicable | cmake/third_party/mockcpp.cmake | https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h6/mockcpp-2.7.tar.gz | Download mockcpp source code from gitcode as a build dependency |
32+| Dependency | Not Applicable | cmake/third_party/mockcpp.cmake | https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h6/mockcpp-2.7-h6.patch | Download mockcpp patch from gitcode as a build dependency |
32| Dependency | Not Applicable | cmake/third_party/protobuf.cmake | https://gitcode.com/cann-src-third-party/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz | Download protobuf source code from gitcode as a build dependency |33| Dependency | Not Applicable | cmake/third_party/protobuf.cmake | https://gitcode.com/cann-src-third-party/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz | Download protobuf source code from gitcode as a build dependency |
33| Dependency | Not Applicable | rdma-core | https://gitcode.com/cann-src-third-party/rdma-core/releases/download/v42.7-h1/rdma-core-42.7.tar.gz | Download rdma-core source code from gitcode as a build dependency |34| Dependency | Not Applicable | rdma-core | https://gitcode.com/cann-src-third-party/rdma-core/releases/download/v42.7-h1/rdma-core-42.7.tar.gz | Download rdma-core source code from gitcode as a build dependency |
34| Dependency | Not Applicable | rdma-core-patch | https://gitcode.com/cann-src-third-party/rdma-core/releases/download/v42.7-h1/rdma-core-42.7.patch | Download rdma-core-patch source code from gitcode as a build dependency |35| Dependency | Not Applicable | rdma-core-patch | https://gitcode.com/cann-src-third-party/rdma-core/releases/download/v42.7-h1/rdma-core-42.7.patch | Download rdma-core-patch source code from gitcode as a build dependency |
@@ -24,7 +24,7 @@ makeself:
24 version: v2.5.0-h124 version: v2.5.0-h1
25 type: build25 type: build
26mockcpp:26mockcpp:
27- version: v2.7-h427+ version: v2.7-h6
28 type: test28 type: test
29openssl:29openssl:
30 version: v3.0.930 version: v3.0.9
@@ -14,6 +14,19 @@ target_compile_definitions(intf_llt_pub_base INTERFACE
14 CFG_BUILD_DEBUG14 CFG_BUILD_DEBUG
15)15)
16 16 
17+# aarch64 的 BL 跳转距离有限,超大 UT 二进制需用 lld 链接(GNU ld 不生成跳转垫片)
18+if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
19+ # mockcpp aarch64 打桩会在函数入口覆写跳转代码,需函数对齐避免越界破坏相邻函数
20+ set(LLT_AARCH64_COMPILE_OPTS -falign-functions=32)
21+ find_program(LLT_LLD_LINKER NAMES ld.lld)
22+ if(LLT_LLD_LINKER)
23+ set(LLT_AARCH64_LINK_OPTS -fuse-ld=lld)
24+ message(STATUS "[intf_llt_pub] aarch64 UT 链接使用 lld")
25+ else()
26+ message(WARNING "[intf_llt_pub] 未找到 ld.lld,aarch64 下超大 UT 二进制可能链接失败,建议安装")
27+ endif()
28+endif()
29+ 
17target_compile_options(intf_llt_pub_base INTERFACE30target_compile_options(intf_llt_pub_base INTERFACE
18 -D_GLIBCXX_USE_CXX11_ABI=031 -D_GLIBCXX_USE_CXX11_ABI=0
19 -g32 -g
@@ -24,12 +37,14 @@ target_compile_options(intf_llt_pub_base INTERFACE
24 $<$<BOOL:${ENABLE_GCOV}>:-fprofile-arcs -ftest-coverage>37 $<$<BOOL:${ENABLE_GCOV}>:-fprofile-arcs -ftest-coverage>
25 -fPIC38 -fPIC
26 -pipe39 -pipe
40+ ${LLT_AARCH64_COMPILE_OPTS}
27)41)
28 42 
29target_link_options(intf_llt_pub_base INTERFACE43target_link_options(intf_llt_pub_base INTERFACE
30 -fprofile-arcs -ftest-coverage44 -fprofile-arcs -ftest-coverage
31 $<$<BOOL:${ENABLE_ASAN}>:-fsanitize=address -fsanitize=leak -fsanitize-recover=address>45 $<$<BOOL:${ENABLE_ASAN}>:-fsanitize=address -fsanitize=leak -fsanitize-recover=address>
32 $<$<BOOL:${ENABLE_GCOV}>:-fprofile-arcs -ftest-coverage>46 $<$<BOOL:${ENABLE_GCOV}>:-fprofile-arcs -ftest-coverage>
47+ ${LLT_AARCH64_LINK_OPTS}
33)48)
34 49 
35target_link_libraries(intf_llt_pub_base INTERFACE50target_link_libraries(intf_llt_pub_base INTERFACE
@@ -17,10 +17,10 @@ unset(MOCKCPP_STATIC_LIBRARY CACHE)
17set(MOCKCPP_FILE "mockcpp-2.7.tar.gz")17set(MOCKCPP_FILE "mockcpp-2.7.tar.gz")
18set(MOCKCPP_URL "https://cann-3rd.obs.cn-north-4.myhuaweicloud.com/mockcpp/mockcpp-2.7.tar.gz")18set(MOCKCPP_URL "https://cann-3rd.obs.cn-north-4.myhuaweicloud.com/mockcpp/mockcpp-2.7.tar.gz")
19set(MOCKCPP_PKG_PATH ${CANN_3RD_LIB_PATH}/${MOCKCPP_FILE})19set(MOCKCPP_PKG_PATH ${CANN_3RD_LIB_PATH}/${MOCKCPP_FILE})
20-set(MOCKCPP_INSTALL_PATH ${CANN_3RD_LIB_PATH}/mockcpp)20+set(MOCKCPP_INSTALL_PATH ${CANN_3RD_LIB_PATH}/mockcpp-2.7-h6)
21 21 
22-set(MOCKCPP_PATCH_FILE "mockcpp-2.7_py3.patch")22+set(MOCKCPP_PATCH_FILE "mockcpp-2.7-h6.patch")
23-set(MOCKCPP_PATCH_URL "https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h4/${MOCKCPP_PATCH_FILE}")23+set(MOCKCPP_PATCH_URL "https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h6/${MOCKCPP_PATCH_FILE}")
24set(MOCKCPP_PATCH_PATH ${CANN_3RD_LIB_PATH}/${MOCKCPP_PATCH_FILE})24set(MOCKCPP_PATCH_PATH ${CANN_3RD_LIB_PATH}/${MOCKCPP_PATCH_FILE})
25 25 
26# mockcpp 需要使用 boost 库26# mockcpp 需要使用 boost 库
@@ -95,7 +95,7 @@ else()
95 include(ExternalProject)95 include(ExternalProject)
96 ExternalProject_Add(third_party_mockcpp_patch96 ExternalProject_Add(third_party_mockcpp_patch
97 URL ${MOCKCPP_PATCH_PROJECT_URL}97 URL ${MOCKCPP_PATCH_PROJECT_URL}
98- URL_HASH SHA256=600c0a263182b1f988e77bb907666d24a72d6ea624a52212d61750384745327d98+ URL_HASH SHA256=238de206a3462886d186ea6c60105ed7d095143cbeb3c083599cc1986cf593f1
99 TLS_VERIFY OFF99 TLS_VERIFY OFF
100 DOWNLOAD_NO_EXTRACT TRUE100 DOWNLOAD_NO_EXTRACT TRUE
101 DOWNLOAD_NO_PROGRESS TRUE101 DOWNLOAD_NO_PROGRESS TRUE
@@ -238,6 +238,6 @@ When compiling this project, the following third-party open source software depe
238| abseil-cpp-patch | 20230802.1-h0 | [backport-CVE-2025-0838.patch](https://gitcode.com/cann-src-third-party/abseil-cpp/releases/download/20230802.1-h0/backport-CVE-2025-0838.patch) |238| abseil-cpp-patch | 20230802.1-h0 | [backport-CVE-2025-0838.patch](https://gitcode.com/cann-src-third-party/abseil-cpp/releases/download/20230802.1-h0/backport-CVE-2025-0838.patch) |
239| boost | 1.87.0 | [boost_1_87_0.tar.gz](https://gitcode.com/cann-src-third-party/boost/releases/download/v1.87.0/boost_1_87_0.tar.gz) |239| boost | 1.87.0 | [boost_1_87_0.tar.gz](https://gitcode.com/cann-src-third-party/boost/releases/download/v1.87.0/boost_1_87_0.tar.gz) |
240| googletest | 1.14.0 | [googletest-1.14.0.tar.gz](https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz) |240| googletest | 1.14.0 | [googletest-1.14.0.tar.gz](https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz) |
241-| mockcpp | 2.7-h4 | [mockcpp-2.7.tar.gz](https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h4/mockcpp-2.7.tar.gz) |241+| mockcpp | 2.7-h6 | [mockcpp-2.7.tar.gz](https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h6/mockcpp-2.7.tar.gz) |
242-| mockcpp-patch | 2.7-h4 | [mockcpp-2.7_py3.patch](https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h4/mockcpp-2.7_py3.patch) |242+| mockcpp-patch | 2.7-h6 | [mockcpp-2.7-h6.patch](https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h6/mockcpp-2.7-h6.patch) |
243| protobuf | 25.1 | [protobuf-25.1.tar.gz](https://gitcode.com/cann-src-third-party/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz) |243| protobuf | 25.1 | [protobuf-25.1.tar.gz](https://gitcode.com/cann-src-third-party/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz) |
@@ -238,6 +238,6 @@ bash build.sh --ut
238| abseil-cpp-patch | 20230802.1-h0 | [backport-CVE-2025-0838.patch](https://gitcode.com/cann-src-third-party/abseil-cpp/releases/download/20230802.1-h0/backport-CVE-2025-0838.patch) |238| abseil-cpp-patch | 20230802.1-h0 | [backport-CVE-2025-0838.patch](https://gitcode.com/cann-src-third-party/abseil-cpp/releases/download/20230802.1-h0/backport-CVE-2025-0838.patch) |
239| boost | 1.87.0 | [boost_1_87_0.tar.gz](https://gitcode.com/cann-src-third-party/boost/releases/download/v1.87.0/boost_1_87_0.tar.gz) |239| boost | 1.87.0 | [boost_1_87_0.tar.gz](https://gitcode.com/cann-src-third-party/boost/releases/download/v1.87.0/boost_1_87_0.tar.gz) |
240| googletest | 1.14.0 | [googletest-1.14.0.tar.gz](https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz) |240| googletest | 1.14.0 | [googletest-1.14.0.tar.gz](https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz) |
241-| mockcpp | 2.7-h4 | [mockcpp-2.7.tar.gz](https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h4/mockcpp-2.7.tar.gz) |241+| mockcpp | 2.7-h6 | [mockcpp-2.7.tar.gz](https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h6/mockcpp-2.7.tar.gz) |
242-| mockcpp-patch | 2.7-h4 | [mockcpp-2.7_py3.patch](https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h4/mockcpp-2.7_py3.patch) |242+| mockcpp-patch | 2.7-h6 | [mockcpp-2.7-h6.patch](https://gitcode.com/cann-src-third-party/mockcpp/releases/download/v2.7-h6/mockcpp-2.7-h6.patch) |
243| protobuf | 25.1 | [protobuf-25.1.tar.gz](https://gitcode.com/cann-src-third-party/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz) |243| protobuf | 25.1 | [protobuf-25.1.tar.gz](https://gitcode.com/cann-src-third-party/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz) |
@@ -175,7 +175,16 @@
175 MOCKER(HrtRaTlvInit).stubs().with(mockcpp::any()).will(returnValue(HcclResult::HCCL_SUCCESS)); \175 MOCKER(HrtRaTlvInit).stubs().with(mockcpp::any()).will(returnValue(HcclResult::HCCL_SUCCESS)); \
176 MOCKER(HrtGetDevicePhyIdByUserDevId).stubs().with(mockcpp::any()).will(returnValue(static_cast<DevId>(1))); \176 MOCKER(HrtGetDevicePhyIdByUserDevId).stubs().with(mockcpp::any()).will(returnValue(static_cast<DevId>(1))); \
177 MOCKER(RaInit).stubs().with(mockcpp::any()).will(returnValue(0)); \177 MOCKER(RaInit).stubs().with(mockcpp::any()).will(returnValue(0)); \
178- MOCKER(RaTlvInit).stubs().with(mockcpp::any()).will(returnValue(0)); \178+ MOCKER(RaTlvInit) \
179+ .stubs() \
180+ .with(mockcpp::any()) \
181+ .will(invoke(+[](struct TlvInitInfo*, unsigned int*, void** tlvHandle) { \
JankinEE
JankinEEJankinEE26 days ago

[LOW] RaTlvInit填充tlv_handle的invoke-lambda在3个文件中重复

同一段 9 行的 +[](struct TlvInitInfo*, unsigned int*, void** tlvHandle){...} lambda 在 test/legacy/common/test_mock_setup.h:181、test/legacy/ut/unified_platform/common/ut_hccp_tlv_hdc_manager.cc:50、test/legacy/ut/unified_platform/external_system/ut_adapter_hccp.cc:117 三处逐字重复(hccp_stub_ut.cc:178 还有第 4 处真实函数变体)。后续 RaTlvInit 签名若再变化需同步修改多处,易漏改。建议在公共测试头中提取一个共享静态桩函数,例如 static int FakeRaTlvInit(struct TlvInitInfo*, unsigned int* bufferSize, void** tlvHandle){ static char fakeTlvHandle; if (bufferSize != nullptr) { *bufferSize = 0; } if (tlvHandle != nullptr) { *tlvHandle = &fakeTlvHandle; } return 0; },各处统一改为 .will(invoke(FakeRaTlvInit));顺带填充 bufferSize 出参可使桩与真实 RaTlvInit 契约更一致。

likedislike
182+ static char fakeTlvHandle; \
183+ if (tlvHandle != nullptr) { \
184+ *tlvHandle = &fakeTlvHandle; \
185+ } \
186+ return 0; \
187+ })); \
179 MOCKER_CPP(&CommunicatorImpl::InitRankGraph, HcclResult (CommunicatorImpl::*)(const std::string&)) \188 MOCKER_CPP(&CommunicatorImpl::InitRankGraph, HcclResult (CommunicatorImpl::*)(const std::string&)) \
180 .stubs() \189 .stubs() \
181 .with(mockcpp::any()) \190 .with(mockcpp::any()) \
@@ -218,6 +218,6 @@ TEST_F(UbMemoryTransportMgrTest, ST_whenInput_param_should_create_remoteIpcRmaBu
218 binaryStream << devBuf->GetAddr() << devBuf->GetSize() << offset << pid << name;218 binaryStream << devBuf->GetAddr() << devBuf->GetSize() << offset << pid << name;
219 ExchangeIpcBufferDto dto;219 ExchangeIpcBufferDto dto;
220 dto.Deserialize(binaryStream);220 dto.Deserialize(binaryStream);
221- MOCKER(HrtDeviceGetBareTgid).stubs().will(returnValue(pid));221+ MOCKER(HrtDeviceGetBareTgid).stubs().will(returnValue(static_cast<s32>(pid)));
222 RemoteIpcRmaBuffer remoteIpcRmaBuffer(dto);222 RemoteIpcRmaBuffer remoteIpcRmaBuffer(dto);
223}223}
@@ -2323,7 +2323,7 @@ TEST(CommunicatorImplTest, St_CommunicatorImpl_When_EnableSuperFastLoad_Expect_L
2323 u32 fakeDevPhyId = 1;2323 u32 fakeDevPhyId = 1;
2324 u32 fakeSqId = 2;2324 u32 fakeSqId = 2;
2325 u64 fakeStmMode = 3;2325 u64 fakeStmMode = 3;
2326- MOCKER(HrtGetStreamId).stubs().will(returnValue(fakeId));2326+ MOCKER(HrtGetStreamId).stubs().will(returnValue(static_cast<s32>(fakeId)));
2327 MOCKER(HrtGetDevice).stubs().will(returnValue(fakeDevLogId));2327 MOCKER(HrtGetDevice).stubs().will(returnValue(fakeDevLogId));
2328 MOCKER(HrtGetDevicePhyIdByUserDevId).stubs().will(returnValue(static_cast<DevId>(fakeDevPhyId)));2328 MOCKER(HrtGetDevicePhyIdByUserDevId).stubs().will(returnValue(static_cast<DevId>(fakeDevPhyId)));
2329 MOCKER(HrtStreamGetSqId).stubs().will(returnValue(fakeSqId));2329 MOCKER(HrtStreamGetSqId).stubs().will(returnValue(fakeSqId));
@@ -514,7 +514,7 @@ TEST(LocalNotifyTest, ipc_local_notify_test)
514 MOCKER(HrtGetNotifyID).stubs().will(returnValue(fakeNotifyId));514 MOCKER(HrtGetNotifyID).stubs().will(returnValue(fakeNotifyId));
515 MOCKER(HrtNotifyGetAddr).stubs().with(mockcpp::any()).will(returnValue(fakeAddress));515 MOCKER(HrtNotifyGetAddr).stubs().with(mockcpp::any()).will(returnValue(fakeAddress));
516 MOCKER(HrtNotifyGetOffset).stubs().will(returnValue(fakeOffset));516 MOCKER(HrtNotifyGetOffset).stubs().will(returnValue(fakeOffset));
517- MOCKER(HrtDeviceGetBareTgid).stubs().will(returnValue(fakePid));517+ MOCKER(HrtDeviceGetBareTgid).stubs().will(returnValue(static_cast<s32>(fakePid)));
518};518};
519 519 
520TEST(LocalRmaBufferTest, localubrmabuffer_construct_error)520TEST(LocalRmaBufferTest, localubrmabuffer_construct_error)
@@ -1368,7 +1368,7 @@ TEST(LocalRmaBufferTest, getExchangeDto_ipc_test)
1368 localIpcRmaBuffer.GetExchangeDto();1368 localIpcRmaBuffer.GetExchangeDto();
1369 1369 
1370 u32 pid = 1;1370 u32 pid = 1;
1371- MOCKER(HrtDeviceGetBareTgid).stubs().will(returnValue(pid));1371+ MOCKER(HrtDeviceGetBareTgid).stubs().will(returnValue(static_cast<s32>(pid)));
1372 localIpcRmaBuffer.Grant(pid);1372 localIpcRmaBuffer.Grant(pid);
1373};1373};
1374 1374 
@@ -238,7 +238,7 @@ protected:
238 {238 {
239 MOCKER(HrtGetDeviceType).stubs().will(returnValue((DevType)DevType::DEV_TYPE_910A2));239 MOCKER(HrtGetDeviceType).stubs().will(returnValue((DevType)DevType::DEV_TYPE_910A2));
240 MOCKER(HrtIpcOpenNotify).stubs().with(mockcpp::any()).will(returnValue((void*)fakeNotifyHandleAddr));240 MOCKER(HrtIpcOpenNotify).stubs().with(mockcpp::any()).will(returnValue((void*)fakeNotifyHandleAddr));
241- MOCKER(HrtDeviceGetBareTgid).stubs().will(returnValue(fakePid));241+ MOCKER(HrtDeviceGetBareTgid).stubs().will(returnValue(static_cast<s32>(fakePid)));
242 MOCKER(HrtGetDevice).stubs().will(returnValue(0));242 MOCKER(HrtGetDevice).stubs().will(returnValue(0));
243 MOCKER(HrtNotifyCreate).stubs().will(returnValue((void*)(fakeNotifyHandleAddr)));243 MOCKER(HrtNotifyCreate).stubs().will(returnValue((void*)(fakeNotifyHandleAddr)));
244 MOCKER(HrtIpcSetNotifyName).stubs().with(mockcpp::any(), outBoundP(fakeName, sizeof(fakeName)), mockcpp::any());244 MOCKER(HrtIpcSetNotifyName).stubs().with(mockcpp::any(), outBoundP(fakeName, sizeof(fakeName)), mockcpp::any());
@@ -111,7 +111,7 @@ target_link_libraries(hccl_v2_utest PRIVATE
111 -pthread111 -pthread
112 # hccl_llt112 # hccl_llt
113 -Wl,--whole-archive113 -Wl,--whole-archive
114- -Wl,--no-whole-archi114+ -Wl,--no-whole-archive
115 -lgcov115 -lgcov
116 -lrt116 -lrt
117 -ldl117 -ldl
@@ -614,6 +614,8 @@ TEST_F(ProfilingHandlerTest, ReportHcclOpInfo_alltoallv_test)
614 op.opTag = "StubTag";614 op.opTag = "StubTag";
615 op.opType = OpType::ALLTOALLV;615 op.opType = OpType::ALLTOALLV;
616 op.staticAddr = false;616 op.staticAddr = false;
617+ u64 sendCounts[2] = {1, 2};
618+ op.all2AllVDataDes.sendCounts = sendCounts;
617 CommunicatorImpl* comm = new CommunicatorImpl;619 CommunicatorImpl* comm = new CommunicatorImpl;
618 comm->rankSize = 2;620 comm->rankSize = 2;
619 dfxOpInfo->comm_ = comm;621 dfxOpInfo->comm_ = comm;
@@ -236,7 +236,7 @@ TEST_F(HcomutCommManagerTest, ut_v2_comm_manager_max_device_id_test)
236 236 
237TEST_F(HcomutCommManagerTest, ut_v2_comm_manager_CallSingletons_Exception_test1)237TEST_F(HcomutCommManagerTest, ut_v2_comm_manager_CallSingletons_Exception_test1)
238{238{
239- MOCKER(HrtGetDevice).stubs().will(returnValue(::MAX_MODULE_DEVICE_NUM + 1));239+ MOCKER(HrtGetDevice).stubs().will(returnValue(static_cast<s32>(::MAX_MODULE_DEVICE_NUM + 1)));
240 EXPECT_EQ(HcclResult::HCCL_E_RUNTIME, CallSingletons());240 EXPECT_EQ(HcclResult::HCCL_E_RUNTIME, CallSingletons());
241}241}
242 242 
@@ -44,6 +44,15 @@ TEST_F(HccpTlvHdcManagerTest, should_successfully_init_HccpTlvHdcManager)
44{44{
45 u32 deviceLogicId = 0;45 u32 deviceLogicId = 0;
46 MOCKER(HrtGetDevicePhyIdByUserDevId).stubs().with(mockcpp::any()).will(returnValue(static_cast<DevId>(0)));46 MOCKER(HrtGetDevicePhyIdByUserDevId).stubs().with(mockcpp::any()).will(returnValue(static_cast<DevId>(0)));
47- MOCKER(RaTlvInit).stubs().will(returnValue(0));47+ MOCKER(RaTlvInit)
48+ .stubs()
49+ .with(mockcpp::any())
50+ .will(invoke(+[](struct TlvInitInfo*, unsigned int*, void** tlvHandle) {
51+ static char fakeTlvHandle;
52+ if (tlvHandle != nullptr) {
53+ *tlvHandle = &fakeTlvHandle;
54+ }
55+ return 0;
56+ }));
48 HccpTlvHdcManager::GetInstance().Init(deviceLogicId);57 HccpTlvHdcManager::GetInstance().Init(deviceLogicId);
49}58}
@@ -73,7 +73,7 @@ TEST_F(P2PEnableManagerTest, enable_p2p_failed_when_hrt_enable_p2p_failed)
73{73{
74 constexpr u32 localDeviceLogicID = 5U;74 constexpr u32 localDeviceLogicID = 5U;
75 constexpr u32 remoteDevicePhysicID = 50U;75 constexpr u32 remoteDevicePhysicID = 50U;
76- MOCKER(HrtGetDevice).stubs().will(returnValue(localDeviceLogicID));76+ MOCKER(HrtGetDevice).stubs().will(returnValue(static_cast<s32>(localDeviceLogicID)));
77 MOCKER(HrtEnableP2P).stubs().will(returnValue(HCCL_E_RUNTIME));77 MOCKER(HrtEnableP2P).stubs().will(returnValue(HCCL_E_RUNTIME));
78 78 
79 // 驱动下发失败:EnableP2P 返回失败,且未持有引用计数79 // 驱动下发失败:EnableP2P 返回失败,且未持有引用计数
@@ -92,7 +92,7 @@ TEST_F(P2PEnableManagerTest, wait_p2p_enabled_success_when_driver_not_enabled)
92{92{
93 constexpr u32 localDeviceLogicID = 5U;93 constexpr u32 localDeviceLogicID = 5U;
94 constexpr u32 remoteDevicePhysicID = 50U;94 constexpr u32 remoteDevicePhysicID = 50U;
95- MOCKER(HrtGetDevice).stubs().will(returnValue(localDeviceLogicID));95+ MOCKER(HrtGetDevice).stubs().will(returnValue(static_cast<s32>(localDeviceLogicID)));
96 MOCKER(HrtEnableP2P).stubs().will(returnValue(HCCL_SUCCESS));96 MOCKER(HrtEnableP2P).stubs().will(returnValue(HCCL_SUCCESS));
97 MOCKER(HrtDisableP2P).stubs().will(returnValue(HCCL_SUCCESS));97 MOCKER(HrtDisableP2P).stubs().will(returnValue(HCCL_SUCCESS));
98 uint32_t drvStatus = DRV_P2P_STATUS_DISABLE;98 uint32_t drvStatus = DRV_P2P_STATUS_DISABLE;
@@ -119,7 +119,7 @@ TEST_F(P2PEnableManagerTest, wait_p2p_enabled_success_when_driver_enabled_and_ca
119{119{
120 constexpr u32 localDeviceLogicID = 5U;120 constexpr u32 localDeviceLogicID = 5U;
121 constexpr u32 remoteDevicePhysicID = 50U;121 constexpr u32 remoteDevicePhysicID = 50U;
122- MOCKER(HrtGetDevice).stubs().will(returnValue(localDeviceLogicID));122+ MOCKER(HrtGetDevice).stubs().will(returnValue(static_cast<s32>(localDeviceLogicID)));
123 MOCKER(HrtEnableP2P).stubs().will(returnValue(HCCL_SUCCESS));123 MOCKER(HrtEnableP2P).stubs().will(returnValue(HCCL_SUCCESS));
124 MOCKER(HrtDisableP2P).stubs().will(returnValue(HCCL_SUCCESS));124 MOCKER(HrtDisableP2P).stubs().will(returnValue(HCCL_SUCCESS));
125 uint32_t drvStatus = DRV_P2P_STATUS_ENABLE;125 uint32_t drvStatus = DRV_P2P_STATUS_ENABLE;
@@ -152,7 +152,7 @@ TEST_F(P2PEnableManagerTest, wait_p2p_enabled_failed_when_hrt_get_p2p_status_fai
152{152{
153 constexpr u32 localDeviceLogicID = 5U;153 constexpr u32 localDeviceLogicID = 5U;
154 constexpr u32 remoteDevicePhysicID = 50U;154 constexpr u32 remoteDevicePhysicID = 50U;
155- MOCKER(HrtGetDevice).stubs().will(returnValue(localDeviceLogicID));155+ MOCKER(HrtGetDevice).stubs().will(returnValue(static_cast<s32>(localDeviceLogicID)));
156 MOCKER(HrtEnableP2P).stubs().will(returnValue(HCCL_SUCCESS));156 MOCKER(HrtEnableP2P).stubs().will(returnValue(HCCL_SUCCESS));
157 MOCKER(HrtDisableP2P).stubs().will(returnValue(HCCL_SUCCESS));157 MOCKER(HrtDisableP2P).stubs().will(returnValue(HCCL_SUCCESS));
158 MOCKER(HrtGetP2PStatus)158 MOCKER(HrtGetP2PStatus)
@@ -175,7 +175,15 @@ int RaGetNotifyBaseAddr(void* rdev_handle, unsigned long long* va, unsigned long
175 */175 */
176int RaInit(struct RaInitConfig* config) { return 0; }176int RaInit(struct RaInitConfig* config) { return 0; }
177 177 
178-int RaTlvInit(struct TlvInitInfo* init_info, unsigned int* buffer_size, void** tlv_handle) { return 0; }178+int RaTlvInit(struct TlvInitInfo* init_info, unsigned int* buffer_size, void** tlv_handle)
179+{
180+ static char fakeTlvHandle;
181+ if (tlv_handle != nullptr) {
182+ *tlv_handle = &fakeTlvHandle;
183+ }
184+ return 0;
185+}
186+ 
179int RaTlvRequest(void* tlv_handle, unsigned int module_type, struct TlvMsg* send_msg, struct TlvMsg* recv_msg)187int RaTlvRequest(void* tlv_handle, unsigned int module_type, struct TlvMsg* send_msg, struct TlvMsg* recv_msg)
JankinEE
JankinEEJankinEE26 days ago

[LOW] RaTlvInit与RaTlvRequest之间缺少空行,与文件内其余函数风格不一致

本次修改将 RaTlvInit 从单行实现展开为多行后,其结束大括号(第 185 行)与下一个函数 RaTlvRequest 的定义(第 186 行)之间没有空行;该文件其余相邻函数定义(如 RaInit/RaTlvInit、RaTlvRequest/RaTlvDeinit 之间)均以空行分隔。建议在第 185 行 '}' 之后补一个空行,保持文件内函数间分隔风格一致。

likedislike
180{188{
181 return 0;189 return 0;
@@ -111,7 +111,16 @@ protected:
111TEST_F(AdapterHccpTest, RaTlvInit_ok)111TEST_F(AdapterHccpTest, RaTlvInit_ok)
112{112{
113 // Given113 // Given
114- MOCKER(RaTlvInit).stubs().will(returnValue(0));114+ MOCKER(RaTlvInit)
115+ .stubs()
116+ .with(mockcpp::any())
117+ .will(invoke(+[](struct TlvInitInfo*, unsigned int*, void** tlvHandle) {
118+ static char fakeTlvHandle;
119+ if (tlvHandle != nullptr) {
120+ *tlvHandle = &fakeTlvHandle;
121+ }
122+ return 0;
123+ }));
115 HRaTlvInitConfig config;124 HRaTlvInitConfig config;
116 config.mode = HrtNetworkMode::HDC;125 config.mode = HrtNetworkMode::HDC;
117 config.phyId = 0;126 config.phyId = 0;
@@ -99,7 +99,7 @@ TEST_F(LocalRmaBufferTest, getExchangeDto_ipc_test)
99 localIpcRmaBuffer.GetExchangeDto();99 localIpcRmaBuffer.GetExchangeDto();
100 100 
101 u32 pid = 1;101 u32 pid = 1;
102- MOCKER(HrtDeviceGetBareTgid).stubs().will(returnValue(pid));102+ MOCKER(HrtDeviceGetBareTgid).stubs().will(returnValue(static_cast<s32>(pid)));
103 localIpcRmaBuffer.Grant(pid);103 localIpcRmaBuffer.Grant(pid);
104};104};
105 105 
@@ -24,7 +24,7 @@ protected:
24 24 
25 virtual void SetUp()25 virtual void SetUp()
26 {26 {
27- MOCKER(HrtGetStreamId).stubs().will(returnValue(fakeId));27+ MOCKER(HrtGetStreamId).stubs().will(returnValue(static_cast<s32>(fakeId)));
28 MOCKER(HrtGetDevice).stubs().will(returnValue(fakeDevLogId));28 MOCKER(HrtGetDevice).stubs().will(returnValue(fakeDevLogId));
29 MOCKER(HrtGetDevicePhyIdByUserDevId).stubs().will(returnValue(static_cast<DevId>(fakeDevPhyId)));29 MOCKER(HrtGetDevicePhyIdByUserDevId).stubs().will(returnValue(static_cast<DevId>(fakeDevPhyId)));
30 MOCKER(HrtStreamCreateWithFlags).stubs().will(returnValue(fakePtr));30 MOCKER(HrtStreamCreateWithFlags).stubs().will(returnValue(fakePtr));
@@ -64,6 +64,38 @@ protected:
64 return result;64 return result;
65 }65 }
66 66 
67+ // 按 P2PTransportLiteImpl 构造函数的解析格式序列化(参照生产端 P2PTransport::GetUniqueId):
68+ // [type][notifyNum][bufferNum][notifyUniqueIds][rmtNotifyUniqueIds][rmtBufferUniqueIds]。
69+ std::vector<char> BuildP2PTransportUniqueId(u32 devPhyId)
70+ {
71+ u32 transportType = 0; // 构造函数读后未使用
72+ u32 notifyNum = 1;
73+ u32 bufferNum = 0; // bufferNum=0 时 ParseRmtBufferVec 直接返回,无需远端 buffer 数据
74+ std::vector<char> notifyUniqueId = GetNotifyUniqueId(0, devPhyId);
75+ // 远端 notify DTO,字段与 RmtP2PNotifyLite(addr/size/id) 对应
76+ BinaryStream rmtNotifyStream;
77+ u64 fakeAddr = 0x1000;
78+ u64 fakeSize = 0x100;
79+ u32 fakeNotifyId = 0;
80+ rmtNotifyStream << fakeAddr;
81+ rmtNotifyStream << fakeSize;
82+ rmtNotifyStream << fakeNotifyId;
83+ std::vector<char> rmtNotifyUniqueId;
84+ rmtNotifyStream.Dump(rmtNotifyUniqueId);
85+ std::vector<char> rmtBufferUniqueId;
86+ 
87+ BinaryStream binaryStream;
88+ binaryStream << transportType;
89+ binaryStream << notifyNum;
90+ binaryStream << bufferNum;
91+ binaryStream << notifyUniqueId;
92+ binaryStream << rmtNotifyUniqueId;
93+ binaryStream << rmtBufferUniqueId;
94+ std::vector<char> p2pUniqueId;
95+ binaryStream.Dump(p2pUniqueId);
96+ return p2pUniqueId;
97+ }
98+ 
67 u8 mockSq[64];99 u8 mockSq[64];
68};100};
69 101 
@@ -84,17 +116,7 @@ TEST_F(P2PTransportLiteImplWaitWithTimeoutTest, P2PTransportLiteImpl_WaitWithTim
84 stream.rtsq = std::make_unique<RtsqA5>(fakeDevPhyId, fakeStreamId, fakeSqId);116 stream.rtsq = std::make_unique<RtsqA5>(fakeDevPhyId, fakeStreamId, fakeSqId);
85 RtsqA5& rtsq = *static_cast<RtsqA5*>(stream.rtsq.get());117 RtsqA5& rtsq = *static_cast<RtsqA5*>(stream.rtsq.get());
86 118 
87- std::vector<char> notifyUniqueId = GetNotifyUniqueId(0, fakeDevPhyId);119+ std::vector<char> p2pUniqueId = BuildP2PTransportUniqueId(fakeDevPhyId);
88- BinaryStream binaryStream;
89- u32 notifyNum = 2;
90- u32 bufferNum = 2;
91- u32 connNum = 1;
92- binaryStream << notifyNum;
93- binaryStream << bufferNum;
94- binaryStream << connNum;
95- binaryStream << notifyUniqueId;
96- std::vector<char> p2pUniqueId;
97- binaryStream.Dump(p2pUniqueId);
98 120 
99 auto callback = [](u32 streamId, u32 taskId, const Hccl::TaskParam& taskParam) {121 auto callback = [](u32 streamId, u32 taskId, const Hccl::TaskParam& taskParam) {
100 (void)streamId;122 (void)streamId;
@@ -124,17 +146,7 @@ TEST_F(P2PTransportLiteImplWaitWithTimeoutTest, P2PTransportLiteImpl_WaitWithTim
124 stream.rtsq = std::make_unique<RtsqA5>(fakeDevPhyId, fakeStreamId, fakeSqId);146 stream.rtsq = std::make_unique<RtsqA5>(fakeDevPhyId, fakeStreamId, fakeSqId);
125 RtsqA5& rtsq = *static_cast<RtsqA5*>(stream.rtsq.get());147 RtsqA5& rtsq = *static_cast<RtsqA5*>(stream.rtsq.get());
126 148 
127- std::vector<char> notifyUniqueId = GetNotifyUniqueId(0, fakeDevPhyId);149+ std::vector<char> p2pUniqueId = BuildP2PTransportUniqueId(fakeDevPhyId);
128- BinaryStream binaryStream;
129- u32 notifyNum = 2;
130- u32 bufferNum = 2;
131- u32 connNum = 1;
132- binaryStream << notifyNum;
133- binaryStream << bufferNum;
134- binaryStream << connNum;
135- binaryStream << notifyUniqueId;
136- std::vector<char> p2pUniqueId;
137- binaryStream.Dump(p2pUniqueId);
138 150 
139 auto callback = [](u32 streamId, u32 taskId, const Hccl::TaskParam& taskParam) {151 auto callback = [](u32 streamId, u32 taskId, const Hccl::TaskParam& taskParam) {
140 (void)streamId;152 (void)streamId;
@@ -164,17 +176,7 @@ TEST_F(P2PTransportLiteImplWaitWithTimeoutTest, P2PTransportLiteImpl_WaitWithTim
164 stream.rtsq = std::make_unique<RtsqA5>(fakeDevPhyId, fakeStreamId, fakeSqId);176 stream.rtsq = std::make_unique<RtsqA5>(fakeDevPhyId, fakeStreamId, fakeSqId);
165 RtsqA5& rtsq = *static_cast<RtsqA5*>(stream.rtsq.get());177 RtsqA5& rtsq = *static_cast<RtsqA5*>(stream.rtsq.get());
166 178 
167- std::vector<char> notifyUniqueId = GetNotifyUniqueId(0, fakeDevPhyId);179+ std::vector<char> p2pUniqueId = BuildP2PTransportUniqueId(fakeDevPhyId);
168- BinaryStream binaryStream;
169- u32 notifyNum = 2;
170- u32 bufferNum = 2;
171- u32 connNum = 1;
172- binaryStream << notifyNum;
173- binaryStream << bufferNum;
174- binaryStream << connNum;
175- binaryStream << notifyUniqueId;
176- std::vector<char> p2pUniqueId;
177- binaryStream.Dump(p2pUniqueId);
178 180 
179 auto callback = [](u32 streamId, u32 taskId, const Hccl::TaskParam& taskParam) {181 auto callback = [](u32 streamId, u32 taskId, const Hccl::TaskParam& taskParam) {
180 (void)streamId;182 (void)streamId;
@@ -42,7 +42,7 @@ target_link_libraries(aicpu_kfc_utest_aicpu PRIVATE
42 -pthread42 -pthread
43 hccl_llt43 hccl_llt
44 -Wl,--whole-archive44 -Wl,--whole-archive
45- -Wl,--no-whole-archi45+ -Wl,--no-whole-archive
46 -lgcov46 -lgcov
47 -lrt47 -lrt
48 -ldl48 -ldl
@@ -44,7 +44,7 @@ target_link_libraries(aicpu_kfc_utest_misc PRIVATE
44 -pthread44 -pthread
45 hccl_llt45 hccl_llt
46 -Wl,--whole-archive46 -Wl,--whole-archive
47- -Wl,--no-whole-archi47+ -Wl,--no-whole-archive
48 -lgcov48 -lgcov
49 -lrt49 -lrt
50 -ldl50 -ldl
@@ -46,7 +46,7 @@ target_link_libraries(hccl_ut_aicpu_task_cache PRIVATE
46 -pthread46 -pthread
47 hccl_llt47 hccl_llt
48 -Wl,--whole-archive48 -Wl,--whole-archive
49- -Wl,--no-whole-archi49+ -Wl,--no-whole-archive
50 -lgcov50 -lgcov
51 -lrt51 -lrt
52 -ldl52 -ldl
@@ -91,7 +91,7 @@ target_link_libraries(hccl_utest_device PRIVATE
91 -pthread91 -pthread
92 hccl_llt92 hccl_llt
93 -Wl,--whole-archive93 -Wl,--whole-archive
94- -Wl,--no-whole-archi94+ -Wl,--no-whole-archive
95 -lgcov95 -lgcov
96 -lrt96 -lrt
97 -ldl97 -ldl
@@ -145,7 +145,7 @@ target_link_libraries(hccl_utest_launch_aicpu_fw PRIVATE
145 -pthread145 -pthread
146 hccl_llt146 hccl_llt
147 -Wl,--whole-archive147 -Wl,--whole-archive
148- -Wl,--no-whole-archi148+ -Wl,--no-whole-archive
149 -lgcov149 -lgcov
150 -lrt150 -lrt
151 -ldl151 -ldl
@@ -53,7 +53,7 @@ target_link_libraries(hccl_utest_framework_cluster_maintenance PRIVATE
53 -pthread53 -pthread
54 hccl_llt54 hccl_llt
55 -Wl,--whole-archive55 -Wl,--whole-archive
56- -Wl,--no-whole-archi56+ -Wl,--no-whole-archive
57 -lgcov57 -lgcov
58 -lrt58 -lrt
59 -ldl59 -ldl
@@ -80,7 +80,7 @@ target_link_libraries(hccl_utest_framework_communicator PRIVATE
80 -pthread80 -pthread
81 hccl_llt81 hccl_llt
82 -Wl,--whole-archive82 -Wl,--whole-archive
83- -Wl,--no-whole-archi83+ -Wl,--no-whole-archive
84 -lgcov84 -lgcov
85 -lrt85 -lrt
86 -ldl86 -ldl
@@ -43,7 +43,7 @@ target_link_libraries(hccl_utest_dpu_manager PRIVATE
43 -pthread43 -pthread
44 hccl_llt44 hccl_llt
45 -Wl,--whole-archive45 -Wl,--whole-archive
46- -Wl,--no-whole-archi46+ -Wl,--no-whole-archive
47 -lgcov47 -lgcov
48 -lrt48 -lrt
49 -ldl49 -ldl
@@ -50,7 +50,7 @@ target_link_libraries(hccl_utest_framework_independent_op PRIVATE
50 -pthread50 -pthread
51 hccl_llt51 hccl_llt
52 -Wl,--whole-archive52 -Wl,--whole-archive
53- -Wl,--no-whole-archi53+ -Wl,--no-whole-archive
54 -lgcov54 -lgcov
55 -lrt55 -lrt
56 -ldl56 -ldl
@@ -66,7 +66,7 @@ target_link_libraries(hcomm_utest_api_data_aicpu_ts PRIVATE
66 -pthread66 -pthread
67 hccl_llt67 hccl_llt
68 -Wl,--whole-archive68 -Wl,--whole-archive
69- -Wl,--no-whole-archi69+ -Wl,--no-whole-archive
70 -lgcov70 -lgcov
71 -lrt71 -lrt
72 -ldl72 -ldl
@@ -52,7 +52,7 @@ target_link_libraries(hcomm_utest_api_data_cpu PRIVATE
52 -pthread52 -pthread
53 hccl_llt53 hccl_llt
54 -Wl,--whole-archive54 -Wl,--whole-archive
55- -Wl,--no-whole-archi55+ -Wl,--no-whole-archive
56 -lgcov56 -lgcov
57 -lrt57 -lrt
58 -ldl58 -ldl
@@ -44,7 +44,7 @@ target_link_libraries(hccl_utest_framework_one_sided_service PRIVATE
44 -pthread44 -pthread
45 hccl_llt45 hccl_llt
46 -Wl,--whole-archive46 -Wl,--whole-archive
47- -Wl,--no-whole-archi47+ -Wl,--no-whole-archive
48 -lgcov48 -lgcov
49 -lrt49 -lrt
50 -ldl50 -ldl
@@ -49,7 +49,7 @@ target_link_libraries(hccl_utest_framework_symmetric_memory PRIVATE
49 -pthread49 -pthread
50 hccl_llt50 hccl_llt
51 -Wl,--whole-archive51 -Wl,--whole-archive
52- -Wl,--no-whole-archi52+ -Wl,--no-whole-archive
53 -lgcov53 -lgcov
54 -lrt54 -lrt
55 -ldl55 -ldl
@@ -44,7 +44,7 @@ target_link_libraries(hcomm_utest_sync_data_aicpu_ts PRIVATE
44 -pthread44 -pthread
45 hccl_llt45 hccl_llt
46 -Wl,--whole-archive46 -Wl,--whole-archive
47- -Wl,--no-whole-archi47+ -Wl,--no-whole-archive
48 -lgcov48 -lgcov
49 -lrt49 -lrt
50 -ldl50 -ldl
@@ -47,7 +47,7 @@ target_link_libraries(hccl_utest_framework_group PRIVATE
47 -Wl,--allow-multiple-definition47 -Wl,--allow-multiple-definition
48 hccl_llt48 hccl_llt
49 -Wl,--whole-archive49 -Wl,--whole-archive
50- -Wl,--no-whole-archi50+ -Wl,--no-whole-archive
51 -lgcov51 -lgcov
52 -lrt52 -lrt
53 -ldl53 -ldl
@@ -47,7 +47,7 @@ target_link_libraries(hccl_utest_framework_hcom PRIVATE
47 -pthread47 -pthread
48 hccl_llt48 hccl_llt
49 -Wl,--whole-archive49 -Wl,--whole-archive
50- -Wl,--no-whole-archi50+ -Wl,--no-whole-archive
51 -lgcov51 -lgcov
52 -lrt52 -lrt
53 -ldl53 -ldl
@@ -43,7 +43,7 @@ target_link_libraries(hccl_utest_coll_comms_common_loggers PRIVATE
43 -pthread43 -pthread
44 hccl_llt44 hccl_llt
45 -Wl,--whole-archive45 -Wl,--whole-archive
46- -Wl,--no-whole-archi46+ -Wl,--no-whole-archive
47 -lgcov47 -lgcov
48 -lrt48 -lrt
49 -ldl49 -ldl
@@ -84,7 +84,7 @@ target_link_libraries(hccl_utest_comms_ccu_features PRIVATE
84 -pthread84 -pthread
85 hccl_llt85 hccl_llt
86 -Wl,--whole-archive86 -Wl,--whole-archive
87- -Wl,--no-whole-archi87+ -Wl,--no-whole-archive
88 -lgcov88 -lgcov
89 -lrt89 -lrt
90 -ldl90 -ldl
@@ -44,7 +44,7 @@ target_link_libraries(hccl_utest_comms_ccu_microcode PRIVATE
44 -pthread44 -pthread
45 hccl_llt45 hccl_llt
46 -Wl,--whole-archive46 -Wl,--whole-archive
47- -Wl,--no-whole-archi47+ -Wl,--no-whole-archive
48 -lgcov48 -lgcov
49 -lrt49 -lrt
50 -ldl50 -ldl
@@ -54,7 +54,7 @@ target_link_libraries(hccl_utest_comms_ccu_rep_interface PRIVATE
54 -pthread54 -pthread
55 hccl_llt55 hccl_llt
56 -Wl,--whole-archive56 -Wl,--whole-archive
57- -Wl,--no-whole-archi57+ -Wl,--no-whole-archive
58 -lgcov58 -lgcov
59 -lrt59 -lrt
60 -ldl60 -ldl
@@ -43,7 +43,7 @@ target_link_libraries(hccl_utest_comms_ccu_rep_arithmetic PRIVATE
43 -pthread43 -pthread
44 hccl_llt44 hccl_llt
45 -Wl,--whole-archive45 -Wl,--whole-archive
46- -Wl,--no-whole-archi46+ -Wl,--no-whole-archive
47 -lgcov47 -lgcov
48 -lrt48 -lrt
49 -ldl49 -ldl
@@ -54,7 +54,7 @@ target_link_libraries(hccl_utest_comms_ccu_rep_common PRIVATE
54 -pthread54 -pthread
55 hccl_llt55 hccl_llt
56 -Wl,--whole-archive56 -Wl,--whole-archive
57- -Wl,--no-whole-archi57+ -Wl,--no-whole-archive
58 -lgcov58 -lgcov
59 -lrt59 -lrt
60 -ldl60 -ldl
@@ -54,7 +54,7 @@ target_link_libraries(hccl_utest_comms_ccu_rep_control PRIVATE
54 -pthread54 -pthread
55 hccl_llt55 hccl_llt
56 -Wl,--whole-archive56 -Wl,--whole-archive
57- -Wl,--no-whole-archi57+ -Wl,--no-whole-archive
58 -lgcov58 -lgcov
59 -lrt59 -lrt
60 -ldl60 -ldl
@@ -54,7 +54,7 @@ target_link_libraries(hccl_utest_comms_ccu_rep_data PRIVATE
54 -pthread54 -pthread
55 hccl_llt55 hccl_llt
56 -Wl,--whole-archive56 -Wl,--whole-archive
57- -Wl,--no-whole-archi57+ -Wl,--no-whole-archive
58 -lgcov58 -lgcov
59 -lrt59 -lrt
60 -ldl60 -ldl
@@ -45,7 +45,7 @@ target_link_libraries(hccl_utest_comms_ccu_rep_loop PRIVATE
45 -pthread45 -pthread
46 hccl_llt46 hccl_llt
47 -Wl,--whole-archive47 -Wl,--whole-archive
48- -Wl,--no-whole-archi48+ -Wl,--no-whole-archive
49 -lgcov49 -lgcov
50 -lrt50 -lrt
51 -ldl51 -ldl
@@ -43,7 +43,7 @@ target_link_libraries(hccl_utest_comms_ccu_rep_shift PRIVATE
43 -pthread43 -pthread
44 hccl_llt44 hccl_llt
45 -Wl,--whole-archive45 -Wl,--whole-archive
46- -Wl,--no-whole-archi46+ -Wl,--no-whole-archive
47 -lgcov47 -lgcov
48 -lrt48 -lrt
49 -ldl49 -ldl
@@ -45,7 +45,7 @@ target_link_libraries(hccl_utest_comms_ccu_rep_sync PRIVATE
45 -pthread45 -pthread
46 hccl_llt46 hccl_llt
47 -Wl,--whole-archive47 -Wl,--whole-archive
48- -Wl,--no-whole-archi48+ -Wl,--no-whole-archive
49 -lgcov49 -lgcov
50 -lrt50 -lrt
51 -ldl51 -ldl
@@ -46,7 +46,7 @@ target_link_libraries(hccl_utest_comms_ccu_rep_translator PRIVATE
46 -pthread46 -pthread
47 hccl_llt47 hccl_llt
48 -Wl,--whole-archive48 -Wl,--whole-archive
49- -Wl,--no-whole-archi49+ -Wl,--no-whole-archive
50 -lgcov50 -lgcov
51 -lrt51 -lrt
52 -ldl52 -ldl
@@ -2391,7 +2391,7 @@ CCU_FUNC_KERNEL_TEST(Ut_HcommCcuKernelLocalCopy_When_AllFine_Expect_ReturnCcuSUC
2391TEST_F(HcommCcuControlApiTest, Ut_HcommCcuGetTaskArgsNum_When_MultiArgIds_Expect_MaxArgId)2391TEST_F(HcommCcuControlApiTest, Ut_HcommCcuGetTaskArgsNum_When_MultiArgIds_Expect_MaxArgId)
2392{2392{
2393 constexpr uint32_t fakeDevId = MAX_MODULE_DEVICE_NUM - 10;2393 constexpr uint32_t fakeDevId = MAX_MODULE_DEVICE_NUM - 10;
2394- MOCKER(HcclGetThreadDeviceId).stubs().will(returnValue(fakeDevId));2394+ MOCKER(HcclGetThreadDeviceId).stubs().will(returnValue(static_cast<int32_t>(fakeDevId)));
2395 2395 
2396 // 通过单例注入 fake kernel,设置 loadArgUsedSet_ = {0, 3, 1},max=3,+1=42396 // 通过单例注入 fake kernel,设置 loadArgUsedSet_ = {0, 3, 1},max=3,+1=4
2397 constexpr CcuKernelHandle fakeHandle = 0xBEEF;2397 constexpr CcuKernelHandle fakeHandle = 0xBEEF;
@@ -2421,7 +2421,7 @@ TEST_F(HcommCcuControlApiTest, Ut_HcommCcuGetTaskArgsNum_When_NullPtr_Expect_Ccu
2421TEST_F(HcommCcuControlApiTest, Ut_HcommCcuGetTaskArgsNum_When_InvalidHandle_Expect_CcuENotFound)2421TEST_F(HcommCcuControlApiTest, Ut_HcommCcuGetTaskArgsNum_When_InvalidHandle_Expect_CcuENotFound)
2422{2422{
2423 constexpr uint32_t fakeDevId = MAX_MODULE_DEVICE_NUM - 10;2423 constexpr uint32_t fakeDevId = MAX_MODULE_DEVICE_NUM - 10;
2424- MOCKER(HcclGetThreadDeviceId).stubs().will(returnValue(fakeDevId));2424+ MOCKER(HcclGetThreadDeviceId).stubs().will(returnValue(static_cast<int32_t>(fakeDevId)));
2425 2425 
2426 // 不注册任何 kernel,使用不存在的 handle2426 // 不注册任何 kernel,使用不存在的 handle
2427 constexpr CcuKernelHandle invalidHandle = 0xDEAD;2427 constexpr CcuKernelHandle invalidHandle = 0xDEAD;
@@ -2436,7 +2436,7 @@ TEST_F(HcommCcuControlApiTest, Ut_HcommCcuGetTaskArgsNum_When_InvalidHandle_Expe
2436TEST_F(HcommCcuControlApiTest, Ut_HcommCcuGetTaskArgsNum_When_NoLoadArg_Expect_Zero)2436TEST_F(HcommCcuControlApiTest, Ut_HcommCcuGetTaskArgsNum_When_NoLoadArg_Expect_Zero)
2437{2437{
2438 constexpr uint32_t fakeDevId = MAX_MODULE_DEVICE_NUM - 10;2438 constexpr uint32_t fakeDevId = MAX_MODULE_DEVICE_NUM - 10;
2439- MOCKER(HcclGetThreadDeviceId).stubs().will(returnValue(fakeDevId));2439+ MOCKER(HcclGetThreadDeviceId).stubs().will(returnValue(static_cast<int32_t>(fakeDevId)));
2440 2440 
2441 // 注入 fake kernel,loadArgUsedSet_ 保持默认空集,GetCcuKernelInfo 填充 maxTaskArgsNum=02441 // 注入 fake kernel,loadArgUsedSet_ 保持默认空集,GetCcuKernelInfo 填充 maxTaskArgsNum=0
2442 constexpr CcuKernelHandle fakeHandle = 0xBEEF;2442 constexpr CcuKernelHandle fakeHandle = 0xBEEF;
@@ -60,7 +60,7 @@ target_link_libraries(hccl_utest_framework_op_base_api PRIVATE
60 -pthread60 -pthread
61 hccl_llt61 hccl_llt
62 -Wl,--whole-archive62 -Wl,--whole-archive
63- -Wl,--no-whole-archi63+ -Wl,--no-whole-archive
64 -lgcov64 -lgcov
65 -lrt65 -lrt
66 -ldl66 -ldl
@@ -55,7 +55,7 @@ target_link_libraries(hccl_utest_framework_resource PRIVATE
55 -pthread55 -pthread
56 hccl_llt56 hccl_llt
57 -Wl,--whole-archive57 -Wl,--whole-archive
58- -Wl,--no-whole-archi58+ -Wl,--no-whole-archive
59 -lgcov59 -lgcov
60 -lrt60 -lrt
61 -ldl61 -ldl
@@ -102,7 +102,7 @@ target_link_libraries(hccl_utest_framework_resource_a5 PRIVATE
102 -pthread102 -pthread
103 hccl_llt103 hccl_llt
104 -Wl,--whole-archive104 -Wl,--whole-archive
105- -Wl,--no-whole-archi105+ -Wl,--no-whole-archive
106 -lgcov106 -lgcov
107 -lrt107 -lrt
108 -ldl108 -ldl
@@ -55,7 +55,7 @@ target_link_libraries(hccl_utest_impl PRIVATE
55 -pthread55 -pthread
56 hccl_llt56 hccl_llt
57 -Wl,--whole-archive57 -Wl,--whole-archive
58- -Wl,--no-whole-archi58+ -Wl,--no-whole-archive
59 -lgcov59 -lgcov
60 -lrt60 -lrt
61 -ldl61 -ldl
@@ -69,7 +69,7 @@ target_link_libraries(hccl_utest_inter_comm PRIVATE
69 -pthread69 -pthread
70 hccl_llt70 hccl_llt
71 -Wl,--whole-archive71 -Wl,--whole-archive
72- -Wl,--no-whole-archi72+ -Wl,--no-whole-archive
73 -lgcov73 -lgcov
74 -lrt74 -lrt
75 -ldl75 -ldl
@@ -48,7 +48,7 @@ target_link_libraries(hccl_utest_inter_hcom PRIVATE
48 -pthread48 -pthread
49 hccl_llt49 hccl_llt
50 -Wl,--whole-archive50 -Wl,--whole-archive
51- -Wl,--no-whole-archi51+ -Wl,--no-whole-archive
52 -lgcov52 -lgcov
53 -lrt53 -lrt
54 -ldl54 -ldl
@@ -82,7 +82,7 @@ target_link_libraries(hccl_utest_misc PRIVATE
82 -pthread82 -pthread
83 hccl_llt83 hccl_llt
84 -Wl,--whole-archive84 -Wl,--whole-archive
85- -Wl,--no-whole-archi85+ -Wl,--no-whole-archive
86 -lgcov86 -lgcov
87 -lrt87 -lrt
88 -ldl88 -ldl
@@ -357,7 +357,7 @@ TEST_F(TopoExchangeAgentTest, TryRecvFromServer_CorrectMessage_ReturnSuccess)
357{357{
358 u32 retryTime = AGENT_MAX_RETRY_TIME;358 u32 retryTime = AGENT_MAX_RETRY_TIME;
359 u32 timeout = 3000;359 u32 timeout = 3000;
360- MOCKER(GetExternalInputHcclLinkTimeOut).stubs().will(returnValue(timeout * retryTime));360+ MOCKER(GetExternalInputHcclLinkTimeOut).stubs().will(returnValue(static_cast<s32>(timeout * retryTime)));
361 MOCKER_CPP(361 MOCKER_CPP(
362 static_cast<HcclResult (hccl::HcclSocket::*)(void*, uint32_t, uint32_t)>(&hccl::HcclSocket::Recv),362 static_cast<HcclResult (hccl::HcclSocket::*)(void*, uint32_t, uint32_t)>(&hccl::HcclSocket::Recv),
363 HcclResult(hccl::HcclSocket::*)(void*, uint32_t, uint32_t))363 HcclResult(hccl::HcclSocket::*)(void*, uint32_t, uint32_t))
@@ -382,7 +382,7 @@ TEST_F(TopoExchangeAgentTest, TryRecvFromServer_WrongMessage_ReturnInternalError
382{382{
383 u32 retryTime = AGENT_MAX_RETRY_TIME;383 u32 retryTime = AGENT_MAX_RETRY_TIME;
384 u32 timeout = 3000;384 u32 timeout = 3000;
385- MOCKER(GetExternalInputHcclLinkTimeOut).stubs().will(returnValue(timeout * retryTime));385+ MOCKER(GetExternalInputHcclLinkTimeOut).stubs().will(returnValue(static_cast<s32>(timeout * retryTime)));
386 MOCKER_CPP(386 MOCKER_CPP(
387 static_cast<HcclResult (hccl::HcclSocket::*)(void*, uint32_t, uint32_t)>(&hccl::HcclSocket::Recv),387 static_cast<HcclResult (hccl::HcclSocket::*)(void*, uint32_t, uint32_t)>(&hccl::HcclSocket::Recv),
388 HcclResult(hccl::HcclSocket::*)(void*, uint32_t, uint32_t))388 HcclResult(hccl::HcclSocket::*)(void*, uint32_t, uint32_t))
@@ -407,7 +407,7 @@ TEST_F(TopoExchangeAgentTest, TryRecvFromServer_RecvFailed_ReturnError)
407{407{
408 u32 retryTime = AGENT_MAX_RETRY_TIME;408 u32 retryTime = AGENT_MAX_RETRY_TIME;
409 u32 timeout = 3000;409 u32 timeout = 3000;
410- MOCKER(GetExternalInputHcclLinkTimeOut).stubs().will(returnValue(timeout * retryTime));410+ MOCKER(GetExternalInputHcclLinkTimeOut).stubs().will(returnValue(static_cast<s32>(timeout * retryTime)));
411 MOCKER_CPP(411 MOCKER_CPP(
412 static_cast<HcclResult (hccl::HcclSocket::*)(void*, uint32_t, uint32_t)>(&hccl::HcclSocket::Recv),412 static_cast<HcclResult (hccl::HcclSocket::*)(void*, uint32_t, uint32_t)>(&hccl::HcclSocket::Recv),
413 HcclResult(hccl::HcclSocket::*)(void*, uint32_t, uint32_t))413 HcclResult(hccl::HcclSocket::*)(void*, uint32_t, uint32_t))
@@ -40,7 +40,7 @@ target_link_libraries(hccl_utest_device_capacity PRIVATE
40 -pthread40 -pthread
41 hccl_llt41 hccl_llt
42 -Wl,--whole-archive42 -Wl,--whole-archive
43- -Wl,--no-whole-archi43+ -Wl,--no-whole-archive
44 -lgcov44 -lgcov
45 -lrt45 -lrt
46 -ldl46 -ldl
@@ -40,7 +40,7 @@ target_link_libraries(hccl_utest_mr_manager PRIVATE
40 -pthread40 -pthread
41 hccl_llt41 hccl_llt
42 -Wl,--whole-archive42 -Wl,--whole-archive
43- -Wl,--no-whole-archi43+ -Wl,--no-whole-archive
44 -lgcov44 -lgcov
45 -lrt45 -lrt
46 -ldl46 -ldl
@@ -41,7 +41,7 @@ target_link_libraries(hccl_utest_unfold_cache PRIVATE
41 -pthread41 -pthread
42 hccl_llt42 hccl_llt
43 -Wl,--whole-archive43 -Wl,--whole-archive
44- -Wl,--no-whole-archi44+ -Wl,--no-whole-archive
45 -lgcov45 -lgcov
46 -lrt46 -lrt
47 -ldl47 -ldl
@@ -41,7 +41,7 @@ target_link_libraries(hccl_utest_platform_hcom PRIVATE
41 -pthread41 -pthread
42 hccl_llt42 hccl_llt
43 -Wl,--whole-archive43 -Wl,--whole-archive
44- -Wl,--no-whole-archi44+ -Wl,--no-whole-archive
45 -lgcov45 -lgcov
46 -lrt46 -lrt
47)47)
@@ -42,7 +42,7 @@ target_link_libraries(hccl_utest_pingmesh PRIVATE
42 -pthread42 -pthread
43 hccl_llt43 hccl_llt
44 -Wl,--whole-archive44 -Wl,--whole-archive
45- -Wl,--no-whole-archi45+ -Wl,--no-whole-archive
46 -lgcov46 -lgcov
47 -lrt47 -lrt
48 -ldl48 -ldl
@@ -39,7 +39,7 @@ target_link_libraries(hccl_utest_platform_dispatcher PRIVATE
39 -pthread39 -pthread
40 hccl_llt40 hccl_llt
41 -Wl,--whole-archive41 -Wl,--whole-archive
42- -Wl,--no-whole-archi42+ -Wl,--no-whole-archive
43 -lgcov43 -lgcov
44 -lrt44 -lrt
45 -pthread45 -pthread
@@ -38,7 +38,7 @@ target_link_libraries(hccl_utest_platform_notify PRIVATE
38 -pthread38 -pthread
39 hccl_llt39 hccl_llt
40 -Wl,--whole-archive40 -Wl,--whole-archive
41- -Wl,--no-whole-archi41+ -Wl,--no-whole-archive
42 -lgcov42 -lgcov
43 -lrt43 -lrt
44 -pthread44 -pthread
@@ -40,7 +40,7 @@ target_link_libraries(hccl_utest_platform_transport PRIVATE
40 -pthread40 -pthread
41 hccl_llt41 hccl_llt
42 -Wl,--whole-archive42 -Wl,--whole-archive
43- -Wl,--no-whole-archi43+ -Wl,--no-whole-archive
44 -lgcov44 -lgcov
45 -lrt45 -lrt
46 -pthread46 -pthread
@@ -39,7 +39,7 @@ target_link_libraries(hccl_utest_platform_task_rtsq_interact PRIVATE
39 -pthread39 -pthread
40 hccl_llt40 hccl_llt
41 -Wl,--whole-archive41 -Wl,--whole-archive
42- -Wl,--no-whole-archi42+ -Wl,--no-whole-archive
43 -lgcov43 -lgcov
44 -lrt44 -lrt
45 -pthread45 -pthread
@@ -40,7 +40,7 @@ target_link_libraries(hccl_utest_task_logic PRIVATE
40 -pthread40 -pthread
41 hccl_llt41 hccl_llt
42 -Wl,--whole-archive42 -Wl,--whole-archive
43- -Wl,--no-whole-archi43+ -Wl,--no-whole-archive
44 -lgcov44 -lgcov
45 -lrt45 -lrt
46 -ldl46 -ldl
@@ -439,6 +439,12 @@ int RaQpDestroy(void* handle)
439 return -1;439 return -1;
440 }440 }
441 441 
442+ // 仅接受本桩 RaQpCreate 发放的静态句柄池(cn[])内的指针
443+ if ((handle < (void*)&cn[0]) || (handle >= (void*)&cn[QP_MAX])) {
JankinEE
JankinEEJankinEE26 days ago

[LOW] void*关系比较非标准C++写法,且未校验句柄在池内的元素对齐

两处问题:(1) 对 void* 使用 < / >= 关系运算在标准 C++ 中不合法(void 非对象类型,[expr.rel] 要求操作数为指向对象类型的指针),当前仅依赖 GCC/Clang 的编译器扩展通过;且对不同对象(任意 handle 与静态数组边界)做关系比较结果为未指明,只是平坦地址空间下碰巧等价于数值比较。(2) 范围校验只判上下界,落在池区间内的非对齐内部指针(如 (char*)&cn[0] + 4)仍会通过校验并被强转 cn_info* 解引用,set_flag 会读到相邻字段的垃圾值。建议改为基于整数的比较并追加对齐校验:const uintptr_t h = reinterpret_cast<uintptr_t>(handle); const uintptr_t base = reinterpret_cast<uintptr_t>(&cn[0]); if (h < base || (h - base) >= sizeof(cn) || (h - base) % sizeof(struct cn_info) != 0) { HCCL_ERROR(...); return -1; }

likedislike
444+ HCCL_ERROR("invalid qp handle[%p], not issued by this stub", handle);
445+ return -1;
446+ }
447+ 
442 struct cn_info* p_cn = (struct cn_info*)handle;448 struct cn_info* p_cn = (struct cn_info*)handle;
443 if (!p_cn->set_flag) {449 if (!p_cn->set_flag) {
444 HCCL_ERROR("flag not set");450 HCCL_ERROR("flag not set");