# 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.

import("//build/lite/config/component/lite_component.gni")
import("../../../config.gni")

if (defined(ohos_lite)) {
  import("//build/lite/config/test.gni")

  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 = [
        "//third_party/node/src",
        "../../../src/",
        "../../../include/",
        "../../../interfaces/inner_api/",
        "include/",
      ]
      include_dirs += [ syscap_codec_config_path ]

      cflags = [ "-g3" ]

      sources = [
        "../../../interfaces/inner_api/syscap_interface.c",
        "../../../src/context_tool.c",
        "../../../src/create_pcid.c",
        "../../../src/endian_internal.c",
        "../../../src/syscap_tool.c",
        "../../../src/common_method.c",
        "syscap_codec_test.cpp",
      ]

      defines = [ "NAPI_TEST" ]

      deps = [
        "//test/testfwk/developer_test/third_party/lib/cpp:gtest_main",
        "//build/lite/config/component/cJSON:cjson_static"
      ]

      external_deps = [
        "bounds_checking_function:libsec_shared",
    ]
    }
  }

  group("unittest") {
    if (ohos_kernel_type != "liteos_m") {
      deps = [ ":test_syscap_napi_unittest" ]
    }
  }
} else {
  import("//build/ohos.gni")
  import("//build/test.gni")

  module_output_path = "syscap_codec/syscap_codec"

  ohos_unittest("syscap_codec_test") {
    module_out_path = module_output_path

    include_dirs = [
      "../../../src",
      "../../../include",
      "../../../interfaces/inner_api",
      "../../../test/unittest/common/include",
    ]
    include_dirs += [ syscap_codec_config_path ]

    sources = [
      "../../../interfaces/inner_api/syscap_interface.c",
      "../../../src/context_tool.c",
      "../../../src/create_pcid.c",
      "../../../src/endian_internal.c",
      "../../../src/syscap_tool.c",
      "../../../src/common_method.c",
      "syscap_codec_test.cpp",
    ]

    external_deps = [
      "bounds_checking_function:libsec_static",
      "cJSON:cjson_static",
      "googletest:gtest_main",
    ]
  }

  group("unittest") {
    testonly = true
    deps = [ ":syscap_codec_test" ]
  }
}