!65 解决错误的测试用例。

Merge pull request !65 from chenyude/rpcid
This commit is contained in:
openharmony_ci
2022-06-14 02:02:04 +00:00
committed by Gitee
4 changed files with 7 additions and 23 deletions
+4 -4
View File
@@ -451,7 +451,7 @@ char *DecodeRpcidToStringFormat(char *inputFile)
// malloc for save private syscap string
priSyscapArray = (char *)malloc(sysCapArraySize * SINGLE_FEAT_LENGTH);
if (priSyscapArray == NULL) {
PRINT_ERR("malloc(%u) failed.\n", sysCapArraySize * SINGLE_FEAT_LENGTH);
PRINT_ERR("malloc(%u) failed.\n", (uint32_t)sysCapArraySize * SINGLE_FEAT_LENGTH);
goto FREE_MALLOC_OSSYSCAP;
}
(void)memset_s(priSyscapArray, sysCapArraySize * SINGLE_FEAT_LENGTH,
@@ -462,7 +462,7 @@ char *DecodeRpcidToStringFormat(char *inputFile)
cJSON *cJsonItem = cJSON_GetArrayItem(sysCapArray, i);
cJsonTemp = cJSON_GetObjectItem(sysCapDefine, cJsonItem->valuestring);
if (cJsonTemp != NULL) {
osSysCapIndex[indexOs++] = cJsonTemp->valueint;
osSysCapIndex[indexOs++] = (uint16_t)(cJsonTemp->valueint);
} else {
ret = strncpy_s(priSyscapArray, sysCapArraySize * SINGLE_FEAT_LENGTH,
cJsonItem->valuestring, SINGLE_FEAT_LENGTH - 1);
@@ -483,8 +483,8 @@ char *DecodeRpcidToStringFormat(char *inputFile)
goto FREE_MALLOC_PRISYSCAP;
}
uint16_t outBufferLen = U32_TO_STR_MAX_LEN * RPCID_OUT_BUFFER
+ (SINGLE_FEAT_LENGTH + 1) * sysCapArraySize;
uint32_t outBufferLen = U32_TO_STR_MAX_LEN * RPCID_OUT_BUFFER
+ (SINGLE_FEAT_LENGTH + 1) * (uint32_t)sysCapArraySize;
outBuffer = (char *)malloc(outBufferLen);
if (outBuffer == NULL) {
PRINT_ERR("malloc(%u) failed.\n", outBufferLen);
+2 -2
View File
@@ -80,8 +80,8 @@ int main(int argc, char **argv)
break;
case 'C':
pcidfile = optarg;
if (optind < 0 || optind > argc) {
PRINT_ERR("Input file path too few or too many.\n");
if (argc != 4 || optind < 0 || optind >= argc) { // 4, argc of ./syscap_tool -C f1 f2
PRINT_ERR("Input file too few or too many.\n");
return -1;
}
rpcidfile = argv[optind];
+1 -1
View File
@@ -479,7 +479,7 @@ int32_t DecodeRpcidToString(char *inputFile, char *outDirPath)
// malloc for save private syscap string
priSyscapArray = (char *)malloc(sysCapArraySize * SINGLE_FEAT_LENGTH);
if (priSyscapArray == NULL) {
PRINT_ERR("malloc(%u) failed.\n", sysCapArraySize * SINGLE_FEAT_LENGTH);
PRINT_ERR("malloc(%d) failed.\n", sysCapArraySize * SINGLE_FEAT_LENGTH);
goto FREE_MALLOC_OSSYSCAP;
}
(void)memset_s(priSyscapArray, sysCapArraySize * SINGLE_FEAT_LENGTH,
@@ -100,22 +100,6 @@ HWTEST_F(SyscapCodecTest, DecodePrivateSyscap, TestSize.Level1)
free(priOutput);
}
/*
* @tc.name: DecodeRpcidToStringFormat
* @tc.desc: Check the DecodeRpcidToStringFormat Decoding.
* @tc.type: FUNC
*/
HWTEST_F(SyscapCodecTest, DecodeRpcidToStringFormat, TestSize.Level1)
{
char inputfile[] = "/system/etc/rpcid.sc";
char *out = DecodeRpcidToStringFormat(inputfile);
EXPECT_TRUE(out);
if (out != NULL) {
printf("%s\n", out);
free(out);
}
}
/*
* @tc.name: ComparePcidString
* @tc.desc: Check the DecodeRpcidToStringFormat Decoding.