mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-27 20:29:57 -04:00
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -14,9 +14,7 @@
|
||||
import("//build/ohos.gni")
|
||||
|
||||
config("pubilc") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
]
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
|
||||
sources_platform_common = [
|
||||
@@ -24,7 +22,8 @@ sources_platform_common = [
|
||||
"./src/endian_internal.c",
|
||||
]
|
||||
|
||||
ohos_executable("syscap_tool") {
|
||||
ohos_executable("syscap_tool_bin") {
|
||||
output_name = "syscap_tool"
|
||||
install_enable = true
|
||||
include_dirs = [ "src" ]
|
||||
public_configs = [ ":pubilc" ]
|
||||
@@ -37,9 +36,32 @@ ohos_executable("syscap_tool") {
|
||||
sources = [ "./src/main.c" ]
|
||||
sources += sources_platform_common
|
||||
|
||||
deps = [
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
deps = [ "//third_party/bounds_checking_function:libsec_static" ]
|
||||
|
||||
if (defined(ohos_lite)) {
|
||||
deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
|
||||
} else {
|
||||
deps += [ "//third_party/cJSON:cjson_static" ]
|
||||
}
|
||||
|
||||
subsystem_name = "developtools"
|
||||
part_name = "syscap_codec"
|
||||
}
|
||||
|
||||
ohos_executable("syscap_tool_test") {
|
||||
install_enable = true
|
||||
include_dirs = [ "src" ]
|
||||
public_configs = [ ":pubilc" ]
|
||||
defines = []
|
||||
|
||||
if (is_mingw) {
|
||||
defines += [ "_POSIX_" ]
|
||||
}
|
||||
|
||||
sources = [ "./test/syscap_tool_test.c" ]
|
||||
sources += sources_platform_common
|
||||
|
||||
deps = [ "//third_party/bounds_checking_function:libsec_static" ]
|
||||
|
||||
if (defined(ohos_lite)) {
|
||||
deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
|
||||
@@ -72,4 +94,4 @@ ohos_shared_library("syscap_tool_shared") {
|
||||
|
||||
group("syscap_codec") {
|
||||
deps = [ ":syscap_tool_shared" ]
|
||||
}
|
||||
}
|
||||
|
||||
+10
-25
@@ -1,31 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _SYSCAP_TOOL_H
|
||||
|
||||
+12
-25
@@ -1,31 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "endian_internal.h"
|
||||
@@ -35,6 +20,8 @@
|
||||
#define B_L_SWAP32(A) ((((uint32_t)(A) & 0xff000000) >> 24) | (((uint32_t)(A) & 0x00ff0000) >> 8) | \
|
||||
(((uint32_t)(A) & 0x0000ff00) << 8) | (((uint32_t)(A) & 0x000000ff) << 24))
|
||||
|
||||
int32_t CheckEndian(void);
|
||||
|
||||
int32_t CheckEndian()
|
||||
{
|
||||
union {
|
||||
|
||||
+10
-25
@@ -1,31 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _ENDIAN_INTERNAL_H
|
||||
|
||||
+11
-26
@@ -1,31 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "syscap_tool.h"
|
||||
@@ -112,7 +97,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
printf("ERROR: in file %s at line %d -> ", __FILE__, __LINE__);
|
||||
printf("ERROR: in file %s at line %d -> ", __FILE__, __LINE__);
|
||||
printf("input file(%s) prase failed\n", inputfile);
|
||||
}
|
||||
|
||||
|
||||
+20
-35
@@ -1,47 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "syscap_tool.h"
|
||||
#include "endian_internal.h"
|
||||
#include "cJSON.h"
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <libgen.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <securec.h>
|
||||
#include "endian_internal.h"
|
||||
#include "cJSON.h"
|
||||
#include "syscap_tool.h"
|
||||
|
||||
typedef struct ProductCompatibilityIDHead {
|
||||
uint16_t apiVersion : 15;
|
||||
@@ -62,7 +47,7 @@ typedef struct RequiredProductCompatibilityIDHead {
|
||||
do { \
|
||||
printf("ERROR: in file %s at line %d -> ", __FILE__, __LINE__); \
|
||||
printf(__VA_ARGS__); \
|
||||
} while (0);
|
||||
} while (0)
|
||||
|
||||
static void FreeContextBuffer(char *contextBuffer)
|
||||
{
|
||||
@@ -100,11 +85,11 @@ static uint32_t GetFileContext(char *inputFile, char **contextBufPtr, uint32_t *
|
||||
if (ret != 1) {
|
||||
PRINT_ERR("read file(%s) failed, errno = %d\n", inputFile, errno);
|
||||
FreeContextBuffer(contextBuffer);
|
||||
fclose(fp);
|
||||
(void)fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
contextBuffer[statBuf.st_size] = '\0';
|
||||
fclose(fp);
|
||||
(void)fclose(fp);
|
||||
|
||||
*contextBufPtr = contextBuffer;
|
||||
*bufferLen = statBuf.st_size + 1;
|
||||
@@ -144,11 +129,11 @@ static int32_t ConvertedContextSaveAsFile(char *outDirPath, char *filename, char
|
||||
ret = fwrite(convertedBuffer, bufferLen, 1, fp);
|
||||
if (ret != 1) {
|
||||
PRINT_ERR("can`t write file(%s),errno = %d\n", fileFullPath, errno);
|
||||
fclose(fp);
|
||||
(void)fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
(void)fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Executable
+126
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "syscap_tool.h"
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <wait.h>
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
char *g_testFilePcid = "{\n \"api_version\": 0,\n \"manufacturer_id\": 0,\n \"product\": \"rk3568\",\n" \
|
||||
" \"syscap\": {\n \"os\": [\n \"SystemCapability.Account.AppAccount\",\n" \
|
||||
" \"SystemCapability.Account.OsAccount\"\n ]\n },\n" \
|
||||
" \"system_type\": \"standard\"\n}";
|
||||
char *g_testFileRpcid = "{\n \"api_version\": 7,\n \"syscap\": [\n \"SystemCapability.hiviewdfx.hilog\",\n" \
|
||||
" \"SystemCapability.communication.softbus\",\n \"SystemCapability.hisicon.flashlight\"\n ]\n}";
|
||||
|
||||
int32_t PrepareTestFile(char *fileName, char *fileContext)
|
||||
{
|
||||
int32_t ret;
|
||||
FILE *fp = fopen(fileName, "wb");
|
||||
if (fp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
size_t len = fwrite(fileContext, 1, strlen(fileContext), fp);
|
||||
if (len != strlen(fileContext)) {
|
||||
(void)fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
ret = fclose(fp);
|
||||
if (ret != 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int32_t status;
|
||||
|
||||
char *pcidFileName = "SystemCapability.json";
|
||||
char *rpcidFileName = "rpcid.json";
|
||||
printf("###start syscap tool test###\n");
|
||||
|
||||
(void)unlink(pcidFileName);
|
||||
(void)unlink(rpcidFileName);
|
||||
(void)unlink("./rk3568.sc");
|
||||
(void)unlink("./rpcid.sc");
|
||||
(void)unlink("./rk3568.json");
|
||||
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
printf("prepare test file...\n");
|
||||
int32_t passCnt = 0;
|
||||
int32_t ret = PrepareTestFile(pcidFileName, g_testFilePcid);
|
||||
if (ret != 0) {
|
||||
printf(" error: prepare pcid file failed\n");
|
||||
exit(passCnt);
|
||||
}
|
||||
ret = PrepareTestFile(rpcidFileName, g_testFileRpcid);
|
||||
if (ret != 0) {
|
||||
printf(" error: prepare rpcid file failed\n");
|
||||
exit(passCnt);
|
||||
}
|
||||
printf("1.test rpcid.json encode to rpcid.sc\n");
|
||||
ret = RPCIDEncode(rpcidFileName, "./");
|
||||
if (ret != 0) {
|
||||
printf(" error: rpcid.json encode failed\n");
|
||||
exit(passCnt);
|
||||
}
|
||||
passCnt++;
|
||||
printf("pass\n");
|
||||
printf("2.test rpcid.sc decode to rpcid.json\n");
|
||||
ret = RPCIDDecode("rpcid.sc", "./");
|
||||
if (ret != 0) {
|
||||
printf(" error: rpcid.sc decode failed\n");
|
||||
exit(passCnt);
|
||||
}
|
||||
passCnt++;
|
||||
printf("pass\n");
|
||||
printf("3.test pcid.json encode to pcid.sc\n");
|
||||
ret = PCIDEncode(pcidFileName, "./");
|
||||
if (ret != 0) {
|
||||
printf(" error: pcid.json encode failed\n");
|
||||
exit(passCnt);
|
||||
}
|
||||
passCnt++;
|
||||
printf("pass\n");
|
||||
printf("4.test pcid.sc decode to pcid.json\n");
|
||||
ret = PCIDDecode("./rk3568.sc", "./");
|
||||
if (ret != 0) {
|
||||
printf(" error: pcid.sc decode failed\n");
|
||||
exit(passCnt);
|
||||
}
|
||||
passCnt++;
|
||||
printf("pass\n");
|
||||
exit(passCnt);
|
||||
}
|
||||
(void)wait(&status);
|
||||
printf("summary: total 4 passed %d\n", WEXITSTATUS(status));
|
||||
(void)unlink(pcidFileName);
|
||||
(void)unlink(rpcidFileName);
|
||||
(void)unlink("./rk3568.sc");
|
||||
(void)unlink("./rpcid.sc");
|
||||
(void)unlink("./rk3568.json");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user