diff --git a/BUILD.gn b/BUILD.gn index a8f35279c3411b2270ec26d2a0ae8aacc98c96af..b01dff91d825bf693415e9d51a946e852233d396 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -59,32 +59,10 @@ ohos_executable("syscap_tool_bin") { if (is_mingw) { defines += [ "_POSIX_" ] } - sources = [ "./src/main.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" ] - } 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_" ] + if (defined(ohos_lite) && ohos_kernel_type == "liteos_m") { + cflags = [ "-DPATH_MAX=1024" ] } - - sources = [ "./test/syscap_tool_test.c" ] + sources = [ "./src/main.c" ] sources += sources_platform_common deps = [ "//third_party/bounds_checking_function:libsec_static" ] @@ -99,46 +77,32 @@ ohos_executable("syscap_tool_test") { part_name = "syscap_codec" } -ohos_shared_library("syscap_tool_shared") { - output_name = "syscap_codec" - include_dirs = [ "src" ] - public_configs = [ ":pubilc" ] - - sources = sources_platform_common - - 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" -} - config("syscap_interface_public_config") { include_dirs = [ "./interfaces/inner_api/" ] } if (defined(ohos_lite)) { - shared_library("syscap_interface_shared") { - include_dirs = [ - "include", - "src", - ] - public_configs = [ ":syscap_interface_public_config" ] - sources = [ - "./interfaces/inner_api/syscap_interface.c", - "./src/endian_internal.c", - "./src/syscap_tool.c", - ] - - deps = [ - "//build/lite/config/component/cJSON:cjson_static", - "//third_party/bounds_checking_function:libsec_static", - ] + if (ohos_kernel_type == "liteos_m") { + group("syscap_interface_shared") { + } + } else { + shared_library("syscap_interface_shared") { + include_dirs = [ + "include", + "src", + ] + public_configs = [ ":syscap_interface_public_config" ] + sources = [ + "./interfaces/inner_api/syscap_interface.c", + "./src/endian_internal.c", + "./src/syscap_tool.c", + ] + + deps = [ + "//build/lite/config/component/cJSON:cjson_static", + "//third_party/bounds_checking_function:libsec_static", + ] + } } } else { ohos_shared_library("syscap_interface_shared") { @@ -199,7 +163,6 @@ group("syscap_codec") { ":pcid_sc", ":syscap_define_check", ":syscap_interface_shared", - ":syscap_tool_shared", ] if (support_jsapi && is_standard_system) { deps += [ "napi:systemcapability" ] diff --git a/test/syscap_tool_test.c b/test/syscap_tool_test.c deleted file mode 100644 index acf45d1f3226c35abd497b082e3e60d4c1808713..0000000000000000000000000000000000000000 --- a/test/syscap_tool_test.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include "syscap_tool.h" -#include "create_pcid.h" - -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("./newPCID.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"); - printf("5.test pcid.json encode to new PCID.sc\n"); - ret = CreatePCID("./newPCID.sc", "./"); - if (ret != 0) { - printf(" error: new pcid.sc encode failed\n"); - exit(passCnt); - } - passCnt++; - printf("pass\n"); - printf("6.test new pcid.sc decode to pcid.json\n"); - ret = PCIDDecode("./newPCID.sc", "./"); - if (ret != 0) { - printf(" error: new 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("./newPCID.sc"); - (void)unlink("./rpcid.sc"); - (void)unlink("./rk3568.json"); - - return 0; -} \ No newline at end of file diff --git a/test/unittest/common/BUILD.gn b/test/unittest/common/BUILD.gn index aa33c11abf1ea8532a1e6669b47fdfad36e4307c..4c431f591b40e0a632a58d0fce3379d73854704a 100644 --- a/test/unittest/common/BUILD.gn +++ b/test/unittest/common/BUILD.gn @@ -11,51 +11,55 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/lite/config/component/lite_component.gni") if (defined(ohos_lite)) { - import("//build/lite/config/component/lite_component.gni") import("//build/lite/config/test.gni") - test_output_root = "$root_out_dir/test/unittest/syscap_codec" - executable("test_syscap_napi_unittest") { - output_extension = "bin" - output_dir = test_output_root - - include_dirs = [ - "//commonlibrary/c_utils/base/include", - "//third_party/node/src", - "//third_party/googletest/include", - "//developtools/syscap_codec/src/", - "//developtools/syscap_codec/include/", - "//developtools/syscap_codec/interfaces/inner_api/", - "//developtools/syscap_codec/test/unittest/common/include/", - ] - - cflags = [ "-g3" ] - - sources = [ - "//developtools/syscap_codec/interfaces/inner_api/syscap_interface.c", - "//developtools/syscap_codec/src/create_pcid.c", - "//developtools/syscap_codec/src/endian_internal.c", - "//developtools/syscap_codec/src/syscap_tool.c", - "syscap_codec_test.cpp", - ] - - defines = [ "NAPI_TEST" ] - - deps = [ - "//base//hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", - "//test/testfwk/developer_test/third_party/lib/cpp:gtest_main", - "//third_party/bounds_checking_function:libsec_static", - ] - - deps += [ "//build/lite/config/component/cJSON:cjson_static" ] + if (ohos_kernel_type != "liteos_m") { + test_output_root = "$root_out_dir/test/unittest/syscap_codec" + + executable("test_syscap_napi_unittest") { + output_extension = "bin" + output_dir = test_output_root + + include_dirs = [ + "//commonlibrary/c_utils/base/include", + "//third_party/node/src", + "//third_party/googletest/include", + "//developtools/syscap_codec/src/", + "//developtools/syscap_codec/include/", + "//developtools/syscap_codec/interfaces/inner_api/", + "//developtools/syscap_codec/test/unittest/common/include/", + ] + + cflags = [ "-g3" ] + + sources = [ + "//developtools/syscap_codec/interfaces/inner_api/syscap_interface.c", + "//developtools/syscap_codec/src/create_pcid.c", + "//developtools/syscap_codec/src/endian_internal.c", + "//developtools/syscap_codec/src/syscap_tool.c", + "syscap_codec_test.cpp", + ] + + defines = [ "NAPI_TEST" ] + + deps = [ + "//base//hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//test/testfwk/developer_test/third_party/lib/cpp:gtest_main", + "//third_party/bounds_checking_function:libsec_static", + ] + + deps += [ "//build/lite/config/component/cJSON:cjson_static" ] + } } group("unittest") { - deps = [ ":test_syscap_napi_unittest" ] + if (ohos_kernel_type != "liteos_m") { + deps = [ ":test_syscap_napi_unittest" ] + } } } else { - import("//build/lite/config/component/lite_component.gni") import("//build/ohos.gni") import("//build/test.gni")