已合并
【PR】: fix magic number #4232
duanpengliang创建于 17 天前
【PR】: fix magic number #4232
已合并
duanpengliang创建于 17 天前
11 个文件变更+111-21
@@ -315,7 +315,7 @@ aclError aclrtGetStreamAvailableNumImpl(uint32_t* streamCount)
315aclError aclrtSetStreamAttributeImpl(aclrtStream stream, aclrtStreamAttr stmAttrType, aclrtStreamAttrValue* value)315aclError aclrtSetStreamAttributeImpl(aclrtStream stream, aclrtStreamAttr stmAttrType, aclrtStreamAttrValue* value)
316{316{
317 ACL_PROFILING_REG(acl::AclProfType::AclrtSetStreamAttribute);317 ACL_PROFILING_REG(acl::AclProfType::AclrtSetStreamAttribute);
318- ACL_LOG_INFO("start to execute aclrtSetStreamAttribute, stmAttrType = [%u]", static_cast<uint32_t>(stmAttrType));318+ ACL_LOG_INFO("start to execute aclrtSetStreamAttribute, stmAttrType = [%s]", acl::GetStreamAttrDesc(stmAttrType));
319 ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(value);319 ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(value);
320 320 
321 ACL_REQUIRES_RTS_OK(rtsStreamSetAttribute(321 ACL_REQUIRES_RTS_OK(rtsStreamSetAttribute(
@@ -518,6 +518,28 @@ const char* GetErrorTypeDesc(aclrtErrorType type)
518 return enumBuf;518 return enumBuf;
519}519}
520 520 
521+const char* GetStreamAttrDesc(aclrtStreamAttr attr)
522+{
523+ switch (attr) {
524+ case ACL_STREAM_ATTR_FAILURE_MODE:
525+ return "STREAM_ATTR_FAILURE_MODE(1)";
526+ case ACL_STREAM_ATTR_FLOAT_OVERFLOW_CHECK:
527+ return "STREAM_ATTR_FLOAT_OVERFLOW_CHECK(2)";
528+ case ACL_STREAM_ATTR_USER_CUSTOM_TAG:
529+ return "STREAM_ATTR_USER_CUSTOM_TAG(3)";
530+ case ACL_STREAM_ATTR_CACHE_OP_INFO:
531+ return "STREAM_ATTR_CACHE_OP_INFO(4)";
532+ case ACL_STREAM_ATTR_PRIORITY:
533+ return "STREAM_ATTR_PRIORITY(5)";
534+ default:
535+ break;
536+ }
537+ static thread_local char enumBuf[32];
538+ (void)snprintf_s(enumBuf, sizeof(enumBuf), sizeof(enumBuf) - 1, "UNKNOWN(%d)", static_cast<int32_t>(attr));
539+ enumBuf[sizeof(enumBuf) - 1U] = '\0';
540+ return enumBuf;
541+}
542+ 
521const char* GetConditionDesc(aclrtCondition condition)543const char* GetConditionDesc(aclrtCondition condition)
522{544{
523 switch (condition) {545 switch (condition) {
@@ -389,6 +389,7 @@ const char* GetDevResLimitTypeDesc(aclrtDevResLimitType type);
389const char* GetReduceKindDesc(aclrtReduceKind kind);389const char* GetReduceKindDesc(aclrtReduceKind kind);
390const char* GetMemLinkTypeDesc(aclrtMemLinkType type);390const char* GetMemLinkTypeDesc(aclrtMemLinkType type);
391const char* GetErrorTypeDesc(aclrtErrorType type);391const char* GetErrorTypeDesc(aclrtErrorType type);
392+const char* GetStreamAttrDesc(aclrtStreamAttr attr);
392const char* GetConditionDesc(aclrtCondition condition);393const char* GetConditionDesc(aclrtCondition condition);
393const char* GetCompareDataTypeDesc(aclrtCompareDataType type);394const char* GetCompareDataTypeDesc(aclrtCompareDataType type);
394 395 
@@ -724,7 +724,7 @@ rtError_t rtsLaunchBarrierTask(rtBarrierTaskInfo_t* taskInfo, rtStream_t stm, ui
724 auto cmoInfo = taskInfo->cmoInfo[i];724 auto cmoInfo = taskInfo->cmoInfo[i];
725 // if cmoType!=invalid return error725 // if cmoType!=invalid return error
726 COND_RETURN_EXT_ERRCODE_AND_MSG_OUTER_WITH_PARAM(726 COND_RETURN_EXT_ERRCODE_AND_MSG_OUTER_WITH_PARAM(
727- cmoInfo.cmoType != RT_CMO_INVALID, RT_ERROR_INVALID_VALUE, cmoInfo.cmoType, "RT_CMO_INVALID(8)");727+ cmoInfo.cmoType != RT_CMO_INVALID, RT_ERROR_INVALID_VALUE, cmoInfo.cmoType, "CMO_INVALID(8)");
Z

严重程度:建议修改。该新增行在 git diff --check origin/master...refs/codex-review/pr-4232-head 中报 trailing whitespace,输出内容带 CRLF/行尾空白。该问题通常不影响运行逻辑,但可能导致仓库格式检查或提交前检查失败,并增加后续 diff 噪声。建议将受影响文件统一转为 LF,例如使用 dos2unix 或在编辑器中选择 LF 并去除行尾空白,然后重新执行 git diff --check origin/master...refs/codex-review/pr-4232-head 验证。

likedislike
duanpengliang
duanpengliang
16 天前 评论:
728 COND_RETURN_EXT_ERRCODE_AND_MSG_OUTER_WITH_PARAM(728 COND_RETURN_EXT_ERRCODE_AND_MSG_OUTER_WITH_PARAM(
729 cmoInfo.logicId == 0, RT_ERROR_INVALID_VALUE, cmoInfo.logicId, "not equal to 0");729 cmoInfo.logicId == 0, RT_ERROR_INVALID_VALUE, cmoInfo.logicId, "not equal to 0");
730 }730 }
@@ -16,6 +16,7 @@
16#include "runtime/config.h"16#include "runtime/config.h"
17#include "runtime/mem_base.h"17#include "runtime/mem_base.h"
18#include "runtime/mem.h"18#include "runtime/mem.h"
19+#include "runtime/rt_ras.h"
19#include "runtime/rt_inner_mem.h"20#include "runtime/rt_inner_mem.h"
20#include "runtime/rt_external_mem.h"21#include "runtime/rt_external_mem.h"
21#include "runtime/rt_external_stream.h"22#include "runtime/rt_external_stream.h"
@@ -69,6 +70,40 @@ static inline std::string ReduceKindToString(const rtRecudeKind_t kind)
69 return desc;70 return desc;
70}71}
71 72 
73+static inline std::string ErrorTypeToString(const rtErrType type)
74+{
75+ switch (type) {
76+ case RT_NO_ERROR:
77+ return "NO_ERROR(0)";
78+ case RT_ERROR_MEMORY:
79+ return "ERROR_MEMORY(1)";
80+ case RT_ERROR_L2:
81+ return "ERROR_L2(2)";
82+ case RT_ERROR_AICORE:
83+ return "ERROR_AICORE(3)";
84+ case RT_ERROR_LINK:
85+ return "ERROR_LINK(4)";
86+ case RT_ERROR_L3_PORT:
87+ return "ERROR_L3_PORT(5)";
88+ case RT_ERROR_OTHERS:
89+ return "ERROR_OTHERS(65535)";
90+ default:
91+ return RtFmtMsg("UNKNOWN(%d)", static_cast<int32_t>(type));
92+ }
93+}
94+ 
95+static inline std::string HostMemMapCapabilityToString(const rtHostMemMapCapability capability)
96+{
97+ switch (capability) {
98+ case RT_HOST_MEM_MAP_NOT_SUPPORTED:
99+ return "HOST_MEM_MAP_NOT_SUPPORTED(0)";
100+ case RT_HOST_MEM_MAP_SUPPORTED:
101+ return "HOST_MEM_MAP_SUPPORTED(1)";
102+ default:
103+ return RtFmtMsg("UNKNOWN(%d)", static_cast<int32_t>(capability));
104+ }
105+}
106+ 
72std::string DataTypeToString(const rtDataType_t type);107std::string DataTypeToString(const rtDataType_t type);
73 108 
74static inline std::string KernelFlagToString(const uint32_t flag)109static inline std::string KernelFlagToString(const uint32_t flag)
@@ -2190,8 +2190,8 @@ rtError_t ApiErrorDecorator::MemcpyAsync(
2190 checkKind = (configInfo.checkBitmap == WITHOUT_CHECK_KIND) ? false : checkKind;2190 checkKind = (configInfo.checkBitmap == WITHOUT_CHECK_KIND) ? false : checkKind;
2191 COND_RETURN_AND_MSG_OUTER(2191 COND_RETURN_AND_MSG_OUTER(
2192 !checkKind && (kind == RT_MEMCPY_DEFAULT), RT_ERROR_INVALID_VALUE, ErrorCode::EE1011,2192 !checkKind && (kind == RT_MEMCPY_DEFAULT), RT_ERROR_INVALID_VALUE, ErrorCode::EE1011,
2193- "Asynchronous memory copy", "RT_MEMCPY_DEFAULT(7)", "kind",2193+ "Asynchronous memory copy", "MEMCPY_DEFAULT(8)", "kind",
2194- "If parameter checkKind is false, parameter kind cannot be RT_MEMCPY_DEFAULT(7)");2194+ "If parameter checkKind is false, parameter kind cannot be MEMCPY_DEFAULT(8)");
2195 bool isD2HorH2DInvolvePageableMemory = false;2195 bool isD2HorH2DInvolvePageableMemory = false;
2196 Context* curCtx = Runtime::Instance()->CurrentContext();2196 Context* curCtx = Runtime::Instance()->CurrentContext();
2197 CHECK_CONTEXT_VALID_WITH_RETURN(curCtx, RT_ERROR_CONTEXT_NULL);2197 CHECK_CONTEXT_VALID_WITH_RETURN(curCtx, RT_ERROR_CONTEXT_NULL);
@@ -2315,10 +2315,11 @@ rtError_t ApiErrorDecorator::MemcpyAsyncPtr(
2315 ERR_MODULE_GE, error != RT_ERROR_NONE, error,2315 ERR_MODULE_GE, error != RT_ERROR_NONE, error,
2316 "Memory async ptr failed, get pointer attributes failed, retCode=%#x", static_cast<uint32_t>(error));2316 "Memory async ptr failed, get pointer attributes failed, retCode=%#x", static_cast<uint32_t>(error));
2317 const rtMemLocationType srcLocationType = attributes.location.type;2317 const rtMemLocationType srcLocationType = attributes.location.type;
2318- COND_RETURN_AND_MSG_OUTER_WITH_PARAM_DESC(2318+ COND_RETURN_AND_MSG_OUTER_WITH_PARAM_NAME_DESC(
2319 srcLocationType != RT_MEMORY_LOC_DEVICE, RT_ERROR_INVALID_VALUE,2319 srcLocationType != RT_MEMORY_LOC_DEVICE, RT_ERROR_INVALID_VALUE,
2320- "Performing asynchronous memory copy using the address description on the device", srcLocationType,2320+ "Performing asynchronous memory copy using the address description on the device",
2321- std::to_string(RT_MEMORY_LOC_DEVICE));2321+ MemLocationTypeToString(srcLocationType), "srcLocationType",
2322+ MemLocationTypeToString(RT_MEMORY_LOC_DEVICE));
2322 }2323 }
2323 }2324 }
2324 const rtError_t error = impl_->MemcpyAsyncPtr(memcpyAddrInfo, destMax, count, stm, cfgInfo, isMemcpyDesc);2325 const rtError_t error = impl_->MemcpyAsyncPtr(memcpyAddrInfo, destMax, count, stm, cfgInfo, isMemcpyDesc);
@@ -2895,9 +2896,10 @@ rtError_t ApiErrorDecorator::ReduceAsyncV2(
2895 NULL_PTR_RETURN_MSG_OUTER_WITH_FUNC_DESC(2896 NULL_PTR_RETURN_MSG_OUTER_WITH_FUNC_DESC(
2896 overflowAddr, RT_ERROR_INVALID_VALUE, "Asynchronously performing the Reduce operation");2897 overflowAddr, RT_ERROR_INVALID_VALUE, "Asynchronously performing the Reduce operation");
2897 ZERO_RETURN_AND_MSG_OUTER(cnt);2898 ZERO_RETURN_AND_MSG_OUTER(cnt);
2898- COND_RETURN_AND_MSG_OUTER_WITH_PARAM_DESC(2899+ COND_RETURN_AND_MSG_OUTER_WITH_PARAM_NAME_DESC(
2899 (kind != RT_MEMCPY_SDMA_AUTOMATIC_ADD), RT_ERROR_INVALID_VALUE,2900 (kind != RT_MEMCPY_SDMA_AUTOMATIC_ADD), RT_ERROR_INVALID_VALUE,
2900- "Asynchronously performing the Reduce operation", kind, std::to_string(RT_MEMCPY_SDMA_AUTOMATIC_ADD));2901+ "Asynchronously performing the Reduce operation", ReduceKindToString(kind), "kind",
2902+ ReduceKindToString(RT_MEMCPY_SDMA_AUTOMATIC_ADD));
2901 COND_RETURN_AND_MSG_OUTER_WITH_PARAM_DESC(2903 COND_RETURN_AND_MSG_OUTER_WITH_PARAM_DESC(
2902 (cnt > MAX_MEMCPY_SIZE_OF_D2D), RT_ERROR_INVALID_VALUE, "Asynchronously performing the Reduce operation", cnt,2904 (cnt > MAX_MEMCPY_SIZE_OF_D2D), RT_ERROR_INVALID_VALUE, "Asynchronously performing the Reduce operation", cnt,
2903 "(0, " + std::to_string(MAX_MEMCPY_SIZE_OF_D2D) + "]");2905 "(0, " + std::to_string(MAX_MEMCPY_SIZE_OF_D2D) + "]");
@@ -7207,9 +7209,10 @@ rtError_t ApiErrorDecorator::MemWriteValue(
7207 ERR_MODULE_GE, error != RT_ERROR_NONE, error,7209 ERR_MODULE_GE, error != RT_ERROR_NONE, error,
7208 "mem write value failed, get devAddr attributes failed, retCode=%#x", static_cast<uint32_t>(error));7210 "mem write value failed, get devAddr attributes failed, retCode=%#x", static_cast<uint32_t>(error));
7209 7211 
7210- COND_RETURN_AND_MSG_OUTER_WITH_PARAM_DESC(7212+ COND_RETURN_AND_MSG_OUTER_WITH_PARAM_NAME_DESC(
7211 (attributes.location.type != RT_MEMORY_LOC_DEVICE), RT_ERROR_INVALID_VALUE,7213 (attributes.location.type != RT_MEMORY_LOC_DEVICE), RT_ERROR_INVALID_VALUE,
7212- "Writing data to the specified memory", attributes.location.type, std::to_string(RT_MEMORY_LOC_DEVICE));7214+ "Writing data to the specified memory", MemLocationTypeToString(attributes.location.type),
7215+ "attributes.location.type", MemLocationTypeToString(RT_MEMORY_LOC_DEVICE));
7213 7216 
7214 return impl_->MemWriteValue(devAddr, value, flag, stm);7217 return impl_->MemWriteValue(devAddr, value, flag, stm);
7215}7218}
@@ -7232,10 +7235,11 @@ rtError_t ApiErrorDecorator::MemWaitValue(
7232 ERR_MODULE_GE, error != RT_ERROR_NONE, error,7235 ERR_MODULE_GE, error != RT_ERROR_NONE, error,
7233 "mem wait value failed, get devAddr attributes failed, retCode=%#x", static_cast<uint32_t>(error));7236 "mem wait value failed, get devAddr attributes failed, retCode=%#x", static_cast<uint32_t>(error));
7234 7237 
7235- COND_RETURN_AND_MSG_OUTER_WITH_PARAM_DESC(7238+ COND_RETURN_AND_MSG_OUTER_WITH_PARAM_NAME_DESC(
7236 (attributes.location.type != RT_MEMORY_LOC_DEVICE), RT_ERROR_INVALID_VALUE,7239 (attributes.location.type != RT_MEMORY_LOC_DEVICE), RT_ERROR_INVALID_VALUE,
7237- "Unblocking the data in the specified memory when the data meets certain conditions", attributes.location.type,7240+ "Unblocking the data in the specified memory when the data meets certain conditions",
7238- std::to_string(RT_MEMORY_LOC_DEVICE));7241+ MemLocationTypeToString(attributes.location.type), "attributes.location.type",
7242+ MemLocationTypeToString(RT_MEMORY_LOC_DEVICE));
7239 7243 
7240 return impl_->MemWaitValue(devAddr, value, flag, stm);7244 return impl_->MemWaitValue(devAddr, value, flag, stm);
7241}7245}
@@ -8992,10 +8992,11 @@ rtError_t ApiImpl::RepairError(const uint32_t deviceId, const rtErrorInfo* const
8992 break;8992 break;
8993 default:8993 default:
8994 error = RT_ERROR_INVALID_VALUE;8994 error = RT_ERROR_INVALID_VALUE;
8995- RT_LOG_OUTER_MSG_INVALID_PARAM_WITH_DESC(8995+ RT_LOG_OUTER_MSG_WITH_FUNC_DESC(
8996- "Rectifying the device faults", errorInfo->errorType,8996+ ErrorCode::EE1003, "Rectifying the device faults", ErrorTypeToString(errorInfo->errorType),
8997- "{" + std::to_string(RT_NO_ERROR) + ", " + std::to_string(RT_ERROR_MEMORY) + ", " +8997+ "errorInfo->errorType",
8998- std::to_string(RT_ERROR_LINK) + "}");8998+ "{" + ErrorTypeToString(RT_NO_ERROR) + ", " + ErrorTypeToString(RT_ERROR_MEMORY) + ", " +
8999+ ErrorTypeToString(RT_ERROR_LINK) + "}");
8999 break;9000 break;
9000 }9001 }
9001 dev->SetBaseTime();9002 dev->SetBaseTime();
@@ -2155,7 +2155,9 @@ rtError_t ApiImplDavid::RepairError(const uint32_t deviceId, const rtErrorInfo*
2155 break;2155 break;
2156 default:2156 default:
2157 error = RT_ERROR_INVALID_VALUE;2157 error = RT_ERROR_INVALID_VALUE;
2158- RT_LOG(RT_LOG_ERROR, "Does not support current error type [%d]", errorInfo->errorType);2158+ RT_LOG(
2159+ RT_LOG_ERROR, "Does not support current error type [%s]",
2160+ ErrorTypeToString(errorInfo->errorType).c_str());
2159 break;2161 break;
2160 }2162 }
2161 dev->SetBaseTime();2163 dev->SetBaseTime();
@@ -307,8 +307,8 @@ rtError_t NpuDriver::HostMemMapCapabilities(uint32_t deviceId, rtHacType hacType
307 // 将drv_capabilities的值传递给capabilities307 // 将drv_capabilities的值传递给capabilities
308 *capabilities = static_cast<rtHostMemMapCapability>(drv_capabilities);308 *capabilities = static_cast<rtHostMemMapCapability>(drv_capabilities);
309 RT_LOG(309 RT_LOG(
310- RT_LOG_DEBUG, "halHostRegisterCapabilities: device_id=%u, hacType=%s, capabilities=%d!", deviceId,310+ RT_LOG_DEBUG, "halHostRegisterCapabilities: device_id=%u, hacType=%s, capabilities=%s!", deviceId,
311- HacTypeToString(hacType).c_str(), *capabilities);311+ HacTypeToString(hacType).c_str(), HostMemMapCapabilityToString(*capabilities).c_str());
312 return RT_ERROR_NONE;312 return RT_ERROR_NONE;
313}313}
314 314 
@@ -2996,6 +2996,11 @@ TEST_F(UTEST_ACL_Common, EnumDescUsesNameWithoutAclPrefixAndNumericValue)
2996 EXPECT_STREQ(GetErrorTypeDesc(ACL_RT_ERROR_LINK), "RT_ERROR_LINK(4)");2996 EXPECT_STREQ(GetErrorTypeDesc(ACL_RT_ERROR_LINK), "RT_ERROR_LINK(4)");
2997 EXPECT_STREQ(GetErrorTypeDesc(ACL_RT_ERROR_L3_PORT), "RT_ERROR_L3_PORT(5)");2997 EXPECT_STREQ(GetErrorTypeDesc(ACL_RT_ERROR_L3_PORT), "RT_ERROR_L3_PORT(5)");
2998 EXPECT_STREQ(GetErrorTypeDesc(ACL_RT_ERROR_OTHERS), "RT_ERROR_OTHERS(65535)");2998 EXPECT_STREQ(GetErrorTypeDesc(ACL_RT_ERROR_OTHERS), "RT_ERROR_OTHERS(65535)");
2999+ EXPECT_STREQ(GetStreamAttrDesc(ACL_STREAM_ATTR_FAILURE_MODE), "STREAM_ATTR_FAILURE_MODE(1)");
3000+ EXPECT_STREQ(GetStreamAttrDesc(ACL_STREAM_ATTR_FLOAT_OVERFLOW_CHECK), "STREAM_ATTR_FLOAT_OVERFLOW_CHECK(2)");
3001+ EXPECT_STREQ(GetStreamAttrDesc(ACL_STREAM_ATTR_USER_CUSTOM_TAG), "STREAM_ATTR_USER_CUSTOM_TAG(3)");
3002+ EXPECT_STREQ(GetStreamAttrDesc(ACL_STREAM_ATTR_CACHE_OP_INFO), "STREAM_ATTR_CACHE_OP_INFO(4)");
3003+ EXPECT_STREQ(GetStreamAttrDesc(ACL_STREAM_ATTR_PRIORITY), "STREAM_ATTR_PRIORITY(5)");
2999 EXPECT_STREQ(GetConditionDesc(ACL_RT_EQUAL), "RT_EQUAL(0)");3004 EXPECT_STREQ(GetConditionDesc(ACL_RT_EQUAL), "RT_EQUAL(0)");
3000 EXPECT_STREQ(GetConditionDesc(ACL_RT_NOT_EQUAL), "RT_NOT_EQUAL(1)");3005 EXPECT_STREQ(GetConditionDesc(ACL_RT_NOT_EQUAL), "RT_NOT_EQUAL(1)");
3001 EXPECT_STREQ(GetConditionDesc(ACL_RT_GREATER), "RT_GREATER(2)");3006 EXPECT_STREQ(GetConditionDesc(ACL_RT_GREATER), "RT_GREATER(2)");
@@ -3032,6 +3037,7 @@ TEST_F(UTEST_ACL_Common, EnumDescPreservesUnknownNumericValue)
3032 EXPECT_STREQ(GetReduceKindDesc(static_cast<aclrtReduceKind>(92)), "UNKNOWN(92)");3037 EXPECT_STREQ(GetReduceKindDesc(static_cast<aclrtReduceKind>(92)), "UNKNOWN(92)");
3033 EXPECT_STREQ(GetMemLinkTypeDesc(static_cast<aclrtMemLinkType>(93)), "UNKNOWN(93)");3038 EXPECT_STREQ(GetMemLinkTypeDesc(static_cast<aclrtMemLinkType>(93)), "UNKNOWN(93)");
3034 EXPECT_STREQ(GetErrorTypeDesc(static_cast<aclrtErrorType>(94)), "UNKNOWN(94)");3039 EXPECT_STREQ(GetErrorTypeDesc(static_cast<aclrtErrorType>(94)), "UNKNOWN(94)");
3040+ EXPECT_STREQ(GetStreamAttrDesc(static_cast<aclrtStreamAttr>(104)), "UNKNOWN(104)");
3035 EXPECT_STREQ(GetConditionDesc(static_cast<aclrtCondition>(95)), "UNKNOWN(95)");3041 EXPECT_STREQ(GetConditionDesc(static_cast<aclrtCondition>(95)), "UNKNOWN(95)");
3036 EXPECT_STREQ(GetCompareDataTypeDesc(static_cast<aclrtCompareDataType>(96)), "UNKNOWN(96)");3042 EXPECT_STREQ(GetCompareDataTypeDesc(static_cast<aclrtCompareDataType>(96)), "UNKNOWN(96)");
3037 EXPECT_STREQ(GetIpcMemAttrTypeDesc(static_cast<aclrtIpcMemAttrType>(100)), "UNKNOWN(100)");3043 EXPECT_STREQ(GetIpcMemAttrTypeDesc(static_cast<aclrtIpcMemAttrType>(100)), "UNKNOWN(100)");
@@ -34,6 +34,25 @@ TEST(EnumToStringUtilsTest, ReduceKindToStringUnknownValue)
34 EXPECT_EQ(ReduceKindToString(static_cast<rtRecudeKind_t>(100)), "UNKNOWN(100)");34 EXPECT_EQ(ReduceKindToString(static_cast<rtRecudeKind_t>(100)), "UNKNOWN(100)");
35}35}
36 36 
37+TEST(EnumToStringUtilsTest, ErrorTypeToString)
38+{
39+ EXPECT_EQ(ErrorTypeToString(RT_NO_ERROR), "NO_ERROR(0)");
40+ EXPECT_EQ(ErrorTypeToString(RT_ERROR_MEMORY), "ERROR_MEMORY(1)");
41+ EXPECT_EQ(ErrorTypeToString(RT_ERROR_L2), "ERROR_L2(2)");
42+ EXPECT_EQ(ErrorTypeToString(RT_ERROR_AICORE), "ERROR_AICORE(3)");
43+ EXPECT_EQ(ErrorTypeToString(RT_ERROR_LINK), "ERROR_LINK(4)");
44+ EXPECT_EQ(ErrorTypeToString(RT_ERROR_L3_PORT), "ERROR_L3_PORT(5)");
45+ EXPECT_EQ(ErrorTypeToString(RT_ERROR_OTHERS), "ERROR_OTHERS(65535)");
46+ EXPECT_EQ(ErrorTypeToString(static_cast<rtErrType>(100)), "UNKNOWN(100)");
47+}
48+ 
49+TEST(EnumToStringUtilsTest, HostMemMapCapabilityToString)
50+{
51+ EXPECT_EQ(HostMemMapCapabilityToString(RT_HOST_MEM_MAP_NOT_SUPPORTED), "HOST_MEM_MAP_NOT_SUPPORTED(0)");
52+ EXPECT_EQ(HostMemMapCapabilityToString(RT_HOST_MEM_MAP_SUPPORTED), "HOST_MEM_MAP_SUPPORTED(1)");
53+ EXPECT_EQ(HostMemMapCapabilityToString(static_cast<rtHostMemMapCapability>(100)), "UNKNOWN(100)");
54+}
55+ 
37TEST(EnumToStringUtilsTest, DataTypeToStringKnownValue)56TEST(EnumToStringUtilsTest, DataTypeToStringKnownValue)
38{57{
39 EXPECT_EQ(DataTypeToString(RT_DATA_TYPE_FP32), "DATA_TYPE_FP32(0)");58 EXPECT_EQ(DataTypeToString(RT_DATA_TYPE_FP32), "DATA_TYPE_FP32(0)");