# Copyright (c) 2021 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("//arkcompiler/ets_runtime/js_runtime_config.gni")
import("//arkcompiler/ets_runtime/test/test_helper.gni")

module_output_path = "ets_runtime/ets_runtime"

host_unittest_action("JSHelper_ArrayHelper_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "array_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JSHelper_AtomicHelper_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "atomic_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JSHelper_BitHelper_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "bit_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("Builtins_Base_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "builtins_base_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JSHelper_ErrorHelper_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "error_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JS_Ason_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "ason_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JSHelper_FilePathHelper_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "file_path_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("GC_RingBuffer_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "gc_ring_buffer_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JS_JsonParser_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "json_parser_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JS_JsonStringIfier_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "json_stringifier_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JSHelper_MathHelper_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "math_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JSHelper_DtoaHelper_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "dtoa_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JSHelper_NumberHelper_Test") {
  module_out_path = module_output_path
  if (ark_standalone_build && is_ohos && run_with_qemu) {
    defines = [ "RUN_WITH_QEMU" ]
  }
  sources = [
    # test file
    "number_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JSHelper_StringHelper_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "string_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JSHelper_TypedArrayHelper_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "typed_array_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JSHelper_UtfHelper_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "utf_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

host_unittest_action("JSHelper_JsonHelper_Test") {
  module_out_path = module_output_path

  sources = [
    # test file
    "json_helper_test.cpp",
  ]

  configs = [
    "../../../:ecma_test_config",
    "../../../:icu_path_test_config",
  ]

  deps = [ "../../../:libark_jsruntime_test" ]

  # hiviewdfx libraries
  external_deps = hiviewdfx_ext_deps
  external_deps += [
    "icu:shared_icui18n",
    "icu:shared_icuuc",
    "runtime_core:libarkassembler_static",
    "zlib:libz",

    #sdk_libc_secshared_dep,
  ]
  deps += hiviewdfx_deps
}

group("unittest") {
  testonly = true

  # deps file
  deps = [
    ":Builtins_Base_Test",
    ":GC_RingBuffer_Test",
    ":JSHelper_ArrayHelper_Test",
    ":JSHelper_AtomicHelper_Test",
    ":JSHelper_BitHelper_Test",
    ":JSHelper_DtoaHelper_Test",
    ":JSHelper_ErrorHelper_Test",
    ":JSHelper_FilePathHelper_Test",
    ":JSHelper_JsonHelper_Test",
    ":JSHelper_MathHelper_Test",
    ":JSHelper_NumberHelper_Test",
    ":JSHelper_StringHelper_Test",
    ":JSHelper_TypedArrayHelper_Test",
    ":JSHelper_UtfHelper_Test",
    ":JS_Ason_Test",
    ":JS_JsonParser_Test",
    ":JS_JsonStringIfier_Test",
  ]
}

group("host_unittest") {
  testonly = true

  # deps file
  deps = [
    ":Builtins_Base_TestAction",
    ":GC_RingBuffer_TestAction",
    ":JSHelper_ArrayHelper_TestAction",
    ":JSHelper_AtomicHelper_TestAction",
    ":JSHelper_BitHelper_TestAction",
    ":JSHelper_DtoaHelper_TestAction",
    ":JSHelper_ErrorHelper_TestAction",
    ":JSHelper_FilePathHelper_TestAction",
    ":JSHelper_JsonHelper_TestAction",
    ":JSHelper_MathHelper_TestAction",
    ":JSHelper_NumberHelper_TestAction",
    ":JSHelper_StringHelper_TestAction",
    ":JSHelper_TypedArrayHelper_TestAction",
    ":JSHelper_UtfHelper_TestAction",
    ":JS_Ason_TestAction",
    ":JS_JsonParser_TestAction",
    ":JS_JsonStringIfier_TestAction",
  ]
  if (is_mac) {
    deps -= [
      ":Builtins_Base_TestAction",
      ":GC_RingBuffer_TestAction",
      ":JSHelper_ArrayHelper_TestAction",
      ":JSHelper_AtomicHelper_TestAction",
      ":JSHelper_BitHelper_TestAction",
      ":JSHelper_DtoaHelper_TestAction",
      ":JSHelper_ErrorHelper_TestAction",
      ":JSHelper_FilePathHelper_TestAction",
      ":JSHelper_JsonHelper_TestAction",
      ":JSHelper_MathHelper_TestAction",
      ":JSHelper_NumberHelper_TestAction",
      ":JSHelper_StringHelper_TestAction",
      ":JSHelper_TypedArrayHelper_TestAction",
      ":JSHelper_UtfHelper_TestAction",
      ":JS_Ason_TestAction",
      ":JS_JsonParser_TestAction",
      ":JS_JsonStringIfier_TestAction",
    ]
  }
}