diff --git a/BUILD.gn b/BUILD.gn index f30ca7fdd9670d89445ed7ff4d29800084bc8fce..bb5b42a3c6861002dfa07da9c7e26052df32a12e 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -148,3 +148,35 @@ config("ark_config") { ] } } + +group("ark_runtime_unittest") { + testonly = true + deps = [] + if (host_os != "mac") { + deps += [ + "$ark_root/assembler:unittest", + "$ark_root/disassembler:unittest", + "$ark_root/libpandabase:unittest", + "$ark_root/libpandafile:unittest", + "$ark_root/libziparchive:unittest", + "$ark_root/runtime:unittest", + "$ark_root/verification/tests/gtest:unittest", + ] + } +} + +group("ark_runtime_host_unittest") { + testonly = true + deps = [] + if (host_os != "mac") { + deps += [ + "$ark_root/assembler:host_unittest", + "$ark_root/disassembler:host_unittest", + "$ark_root/libpandabase:host_unittest", + "$ark_root/libpandafile:host_unittest", + "$ark_root/libziparchive:host_unittest", + "$ark_root/runtime:host_unittest", + "$ark_root/verification/tests/gtest:host_unittest", + ] + } +} diff --git a/ark_config.gni b/ark_config.gni index 057ccd80585292b97a5b1ac484d4e2d878dd9d41..54beb34d66edbfd81601256782ff35bfe82724a9 100644 --- a/ark_config.gni +++ b/ark_config.gni @@ -184,3 +184,25 @@ template("ark_isa_gen") { extra_dependencies = dependencies } } + +template("ark_asm_gen_abc") { + assert(defined(invoker.src), "src is required!") + assert(defined(invoker.dst), "dst is required!") + + extra_dependencies = [] + if (defined(invoker.extra_dependencies)) { + extra_dependencies += invoker.extra_dependencies + } + + action("$target_name") { + _root_out_dir = get_label_info("$ark_root/assembler:ark_asm(${host_toolchain})", "root_out_dir") + script = "${_root_out_dir}/ark/ark/ark_asm" + inputs = [ invoker.src ] + outputs = [ invoker.dst ] + args = [ + rebase_path(inputs[0], root_build_dir), + rebase_path(outputs[0], root_build_dir), + ] + deps = extra_dependencies + } +} diff --git a/assembler/BUILD.gn b/assembler/BUILD.gn index ecf04b5de7c7e241fcce94cab6f041a2863b6470..123e3e07f5760dbcc28752ca2d67a55b8c9c28c6 100644 --- a/assembler/BUILD.gn +++ b/assembler/BUILD.gn @@ -13,6 +13,7 @@ import("//ark/runtime_core/ark_config.gni") import("//build/ohos.gni") +import("$ark_root/tests/test.gni") config("arkassembler_public_config") { include_dirs = [ @@ -150,3 +151,41 @@ ark_gen_file("ark_asm_ecmascript_meta_gen_h") { requires = [ "asm_metadata.rb" ] output_file = "$target_gen_dir/ecmascript_meta_gen.h" } + +ark_unittest_action("assembler_tests") { + module_out_path = "ark/runtime_core/assembler" + + sources = [ + "$ark_root/assembler/tests/lexer_test.cpp", + "$ark_root/assembler/tests/parser_test.cpp", + "$ark_root/assembler/tests/emitter_test.cpp", + "$ark_root/assembler/tests/mangling_tests.cpp", + ] + + include_dirs = [ + "$ark_root/assembler", + "$target_gen_dir", + ] + + configs = libarkassembler_configs + + deps = [ + ":libarkassembler_frontend_static", + "$ark_root/libpandabase:libarkbase_frontend_static", + "$ark_root/libpandafile:libarkfile_frontend_static", + ] +} + +group("unittest") { + testonly = true + deps = [ + ":assembler_tests", + ] +} + +group("host_unittest") { + testonly = true + deps = [ + ":assembler_tests_action(${host_toolchain})", + ] +} diff --git a/assembler/tests/parser_test.cpp b/assembler/tests/parser_test.cpp index dda1343e3a22f7f2a6c5f02126508ce489789bc2..8b967facdd4a56f8d203511eefbbd656c0a23e75 100644 --- a/assembler/tests/parser_test.cpp +++ b/assembler/tests/parser_test.cpp @@ -1843,8 +1843,8 @@ TEST(parsertests, parse_undefined_record_field) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_ID_RECORD); - ASSERT_EQ(e.line_number, 3); - ASSERT_EQ(e.pos, 27); + ASSERT_EQ(e.line_number, 3U); + ASSERT_EQ(e.pos, 27U); ASSERT_EQ(e.message, "This record does not exist."); } @@ -1885,8 +1885,8 @@ TEST(parsertests, parse_undefined_record_field) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_ID_RECORD); - ASSERT_EQ(e.line_number, 3); - ASSERT_EQ(e.pos, 26); + ASSERT_EQ(e.line_number, 3U); + ASSERT_EQ(e.pos, 26U); ASSERT_EQ(e.message, "This record does not exist."); } @@ -1908,8 +1908,8 @@ TEST(parsertests, parse_undefined_record_field) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_ID_FIELD); - ASSERT_EQ(e.line_number, 3); - ASSERT_EQ(e.pos, 34); + ASSERT_EQ(e.line_number, 3U); + ASSERT_EQ(e.pos, 34U); ASSERT_EQ(e.message, "This field does not exist."); } @@ -1973,8 +1973,8 @@ TEST(parsertests, parse_undefined_record_field) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_ID_FIELD); - ASSERT_EQ(e.line_number, 5); - ASSERT_EQ(e.pos, 57); + ASSERT_EQ(e.line_number, 5U); + ASSERT_EQ(e.pos, 57U); ASSERT_EQ(e.message, "This field does not exist."); } @@ -2016,8 +2016,8 @@ TEST(parsertests, parse_undefined_record_field) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_ID_RECORD); - ASSERT_EQ(e.line_number, 3); - ASSERT_EQ(e.pos, 44); + ASSERT_EQ(e.line_number, 3U); + ASSERT_EQ(e.pos, 44U); ASSERT_EQ(e.message, "This record does not exist."); } @@ -2098,7 +2098,7 @@ TEST(parsertests, Num_vregs) auto it_func = program.function_table.find("main"); ASSERT_TRUE(it_func != program.function_table.end()); - ASSERT_EQ(it_func->second.regs_num, 2); + ASSERT_EQ(it_func->second.regs_num, 2U); } { @@ -2124,7 +2124,7 @@ TEST(parsertests, Num_vregs) auto it_func = program.function_table.find("main"); ASSERT_TRUE(it_func != program.function_table.end()); - ASSERT_EQ(it_func->second.regs_num, 2); + ASSERT_EQ(it_func->second.regs_num, 2U); } { @@ -2149,7 +2149,7 @@ TEST(parsertests, Num_vregs) auto it_func = program.function_table.find("main"); ASSERT_TRUE(it_func != program.function_table.end()); - ASSERT_EQ(it_func->second.regs_num, 1); + ASSERT_EQ(it_func->second.regs_num, 1U); } { @@ -2178,7 +2178,7 @@ TEST(parsertests, Num_vregs) auto it_func = program.function_table.find("main"); ASSERT_TRUE(it_func != program.function_table.end()); - ASSERT_EQ(it_func->second.regs_num, 5); + ASSERT_EQ(it_func->second.regs_num, 5U); } } @@ -2226,7 +2226,7 @@ TEST(parsertests, parse_language_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_MULTIPLE_DIRECTIVES); - ASSERT_EQ(e.line_number, 2); + ASSERT_EQ(e.line_number, 2U); ASSERT_EQ(e.message, "Multiple .language directives"); } @@ -2244,7 +2244,7 @@ TEST(parsertests, parse_language_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_MULTIPLE_DIRECTIVES); - ASSERT_EQ(e.line_number, 3); + ASSERT_EQ(e.line_number, 3U); ASSERT_EQ(e.message, "Multiple .language directives"); } @@ -2261,7 +2261,7 @@ TEST(parsertests, parse_language_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_INCORRECT_DIRECTIVE_LOCATION); - ASSERT_EQ(e.line_number, 2); + ASSERT_EQ(e.line_number, 2U); ASSERT_EQ(e.message, ".language directive must be specified before any other declarations"); } @@ -2277,7 +2277,7 @@ TEST(parsertests, parse_language_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_DIRECTIVE_DECLARATION); - ASSERT_EQ(e.line_number, 1); + ASSERT_EQ(e.line_number, 1U); ASSERT_EQ(e.message, "Incorrect .language directive: Expected language"); } @@ -2293,7 +2293,7 @@ TEST(parsertests, parse_language_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_UNKNOWN_LANGUAGE); - ASSERT_EQ(e.line_number, 1); + ASSERT_EQ(e.line_number, 1U); ASSERT_EQ(e.message, "Incorrect .language directive: Unknown language"); } @@ -2309,7 +2309,7 @@ TEST(parsertests, parse_language_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_DIRECTIVE_DECLARATION); - ASSERT_EQ(e.line_number, 1); + ASSERT_EQ(e.line_number, 1U); ASSERT_EQ(e.message, "Incorrect .language directive: Unexpected token"); } @@ -2360,7 +2360,7 @@ TEST(parsertests, parse_metadata) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_METADATA_UNKNOWN_ATTRIBUTE); - ASSERT_EQ(e.line_number, 1); + ASSERT_EQ(e.line_number, 1U); ASSERT_EQ(e.pos, s.find("attr")); ASSERT_EQ(e.message, "Unknown attribute 'attr'"); } @@ -2379,7 +2379,7 @@ TEST(parsertests, parse_metadata) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_METADATA_UNKNOWN_ATTRIBUTE); - ASSERT_EQ(e.line_number, 1); + ASSERT_EQ(e.line_number, 1U); ASSERT_EQ(e.pos, s.find("attr")); ASSERT_EQ(e.message, "Unknown attribute 'attr'"); } @@ -2398,7 +2398,7 @@ TEST(parsertests, parse_metadata) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_METADATA_UNKNOWN_ATTRIBUTE); - ASSERT_EQ(e.line_number, 1); + ASSERT_EQ(e.line_number, 1U); ASSERT_EQ(e.pos, s.find("native")); ASSERT_EQ(e.message, "Unknown attribute 'native'"); } @@ -2417,7 +2417,7 @@ TEST(parsertests, parse_metadata) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_METADATA_UNEXPECTED_VALUE); - ASSERT_EQ(e.line_number, 1); + ASSERT_EQ(e.line_number, 1U); ASSERT_EQ(e.pos, s.find("=")); ASSERT_EQ(e.message, "Attribute 'external' must not have a value"); } @@ -2436,7 +2436,7 @@ TEST(parsertests, parse_metadata) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_METADATA_UNKNOWN_ATTRIBUTE); - ASSERT_EQ(e.line_number, 1); + ASSERT_EQ(e.line_number, 1U); ASSERT_EQ(e.pos, s.find("java")); ASSERT_EQ(e.message, "Unknown attribute 'java.access'"); } @@ -2456,7 +2456,7 @@ TEST(parsertests, parse_metadata) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_METADATA_MULTIPLE_ATTRIBUTE); - ASSERT_EQ(e.line_number, 2); + ASSERT_EQ(e.line_number, 2U); ASSERT_EQ(e.pos, s.find(",") + 2); ASSERT_EQ(e.message, "Attribute 'external' already defined"); } @@ -2500,7 +2500,7 @@ TEST(parsertests, parse_catch_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_INCORRECT_DIRECTIVE_LOCATION); - ASSERT_EQ(e.line_number, 2); + ASSERT_EQ(e.line_number, 2U); ASSERT_EQ(e.message, ".catch directive is outside a function body."); } @@ -2524,8 +2524,8 @@ TEST(parsertests, parse_catch_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_DIRECTIVE_DECLARATION); - ASSERT_EQ(e.line_number, 3); - ASSERT_EQ(e.pos, 0); + ASSERT_EQ(e.line_number, 3U); + ASSERT_EQ(e.pos, 0U); ASSERT_EQ(e.message, "Incorrect catch block declaration. Must be in the format: .catch , " ", , [, ]"); @@ -2549,7 +2549,7 @@ TEST(parsertests, parse_catch_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_RECORD_NAME); - ASSERT_EQ(e.line_number, 3); + ASSERT_EQ(e.line_number, 3U); ASSERT_EQ(e.pos, s.find("$")); ASSERT_EQ(e.message, "Invalid name of the exception record."); } @@ -2582,7 +2582,7 @@ TEST(parsertests, parse_catch_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_DIRECTIVE_DECLARATION) << "Test " << directive; - ASSERT_EQ(e.line_number, 3) << "Test " << directive; + ASSERT_EQ(e.line_number, 3U) << "Test " << directive; ASSERT_EQ(e.pos, directive.find("$")) << "Test " << directive; ASSERT_EQ(e.message, "Expected comma.") << "Test " << directive; } @@ -2608,7 +2608,7 @@ TEST(parsertests, parse_catch_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_LABEL) << "Test " << directive; - ASSERT_EQ(e.line_number, 3) << "Test " << directive; + ASSERT_EQ(e.line_number, 3U) << "Test " << directive; ASSERT_EQ(e.pos, directive.find("$")) << "Test " << directive; ASSERT_EQ(e.message, std::string("Invalid name of the ") + label_names[i] + " label.") << "Test " << directive; @@ -2669,7 +2669,7 @@ TEST(parsertests, parse_catch_directive) auto &program = res.Value(); auto &function = program.function_table.find("main")->second; - ASSERT_EQ(function.catch_blocks.size(), 1); + ASSERT_EQ(function.catch_blocks.size(), 1U); ASSERT_EQ(function.catch_blocks[0].exception_record, "Exception"); ASSERT_EQ(function.catch_blocks[0].try_begin_label, "try_begin"); ASSERT_EQ(function.catch_blocks[0].try_end_label, "try_end"); @@ -2702,7 +2702,7 @@ TEST(parsertests, parse_catch_directive) auto &program = res.Value(); auto &function = program.function_table.find("main")->second; - ASSERT_EQ(function.catch_blocks.size(), 1); + ASSERT_EQ(function.catch_blocks.size(), 1U); ASSERT_EQ(function.catch_blocks[0].exception_record, "Exception"); ASSERT_EQ(function.catch_blocks[0].try_begin_label, "try_begin"); ASSERT_EQ(function.catch_blocks[0].try_end_label, "try_end"); @@ -2725,7 +2725,7 @@ TEST(parsertests, parse_catchall_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_INCORRECT_DIRECTIVE_LOCATION); - ASSERT_EQ(e.line_number, 1); + ASSERT_EQ(e.line_number, 1U); ASSERT_EQ(e.message, ".catchall directive is outside a function body."); } @@ -2747,8 +2747,8 @@ TEST(parsertests, parse_catchall_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_DIRECTIVE_DECLARATION); - ASSERT_EQ(e.line_number, 2); - ASSERT_EQ(e.pos, 0); + ASSERT_EQ(e.line_number, 2U); + ASSERT_EQ(e.pos, 0U); ASSERT_EQ(e.message, "Incorrect catch block declaration. Must be in the format: .catchall , " ", [, ]"); @@ -2784,7 +2784,7 @@ TEST(parsertests, parse_catchall_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_DIRECTIVE_DECLARATION) << "Test " << directive; - ASSERT_EQ(e.line_number, 2) << "Test " << directive; + ASSERT_EQ(e.line_number, 2U) << "Test " << directive; ASSERT_EQ(e.pos, directive.find("$")) << "Test " << directive; ASSERT_EQ(e.message, "Expected comma.") << "Test " << directive; } @@ -2811,7 +2811,7 @@ TEST(parsertests, parse_catchall_directive) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_LABEL) << "Test " << directive; - ASSERT_EQ(e.line_number, 2) << "Test " << directive; + ASSERT_EQ(e.line_number, 2U) << "Test " << directive; ASSERT_EQ(e.pos, directive.find("$")) << "Test " << directive; ASSERT_EQ(e.message, std::string("Invalid name of the ") + label_names[i] + " label.") << "Test " << directive; @@ -2870,7 +2870,7 @@ TEST(parsertests, parse_catchall_directive) auto &program = res.Value(); auto &function = program.function_table.find("main")->second; - ASSERT_EQ(function.catch_blocks.size(), 1); + ASSERT_EQ(function.catch_blocks.size(), 1U); ASSERT_EQ(function.catch_blocks[0].exception_record, ""); ASSERT_EQ(function.catch_blocks[0].try_begin_label, "try_begin"); ASSERT_EQ(function.catch_blocks[0].try_end_label, "try_end"); @@ -3259,7 +3259,7 @@ TEST(parsertests, field_value) Error e = p.ShowError(); ASSERT_EQ(e.err, Error::ErrorType::ERR_BAD_METADATA_INVALID_VALUE); - ASSERT_EQ(e.line_number, 2); + ASSERT_EQ(e.line_number, 2U); ASSERT_EQ(e.pos, s.find("A")); ASSERT_EQ(e.message, "Excepted integer literal"); } diff --git a/disassembler/BUILD.gn b/disassembler/BUILD.gn index fa244bc2038f52911abd3cc0c1a1183557c678ed..66b035862936e0fe1f91335d1c7094df5f42d533 100644 --- a/disassembler/BUILD.gn +++ b/disassembler/BUILD.gn @@ -13,6 +13,7 @@ import("//ark/runtime_core/ark_config.gni") import("//build/ohos.gni") +import("$ark_root/tests/test.gni") config("arkdisassembler_public_config") { defines = [ "PANDA_WITH_ECMASCRIPT" ] @@ -127,3 +128,115 @@ ark_gen_file("type_to_pandasm_type_cpp") { requires = [ "$ark_root/libpandafile/types.rb" ] output_file = "$target_gen_dir/type_to_pandasm_type.cpp" } + +template("ark_disasm_unittest_action") { + _module_out_path = "ark/runtime_core/disassembler" + + _deps = [ + ":arkdisassembler_frontend_static", + "$ark_root/assembler:libarkassembler_frontend_static", + "$ark_root/libpandabase:libarkbase_frontend_static", + "$ark_root/libpandafile:libarkfile_frontend_static", + ] + + if (defined(invoker.extra_dependencies)) { + _deps += invoker.extra_dependencies + } + + if (defined(invoker.ark_asm_sources)) { + foreach(ark_asm_src, invoker.ark_asm_sources) { + _name = get_path_info(ark_asm_src, "name") + _target = "arkdisassembler_test_${_name}_abc" + + ark_asm_gen_abc("${_target}") { + src = ark_asm_src + dst = "${root_out_dir}/tests/unittest/${_module_out_path}/bin/${_name}.bc" + } + + _deps += [ ":${_target}" ] + } + } + + ark_unittest_action("${target_name}") { + forward_variables_from(invoker, + "*", + [ + "target_name", + "module_out_path", + "include_dirs", + "configs", + "deps", + ]) + + module_out_path = _module_out_path + + include_dirs = [ + "$ark_root/disassembler", + "$target_gen_dir", + ] + + configs = arkdisassembler_configs + + deps = _deps + + resource_config_file = "$ark_root/disassembler/tests/ohos_test.xml" + } +} + +ark_disasm_unittest_action("disasm_test_labels") { + sources = [ + "$ark_root/disassembler/tests/labels_test.cpp", + ] + + ark_asm_sources = [ + "$ark_root/disassembler/tests/sources/labels1.pa", + "$ark_root/disassembler/tests/sources/labels2.pa", + "$ark_root/disassembler/tests/sources/exceptions.pa", + ] +} + +ark_disasm_unittest_action("disasm_test_records") { + sources = [ + "$ark_root/disassembler/tests/records_test.cpp", + ] + + ark_asm_sources = [ + "$ark_root/disassembler/tests/sources/empty_record.pa", + "$ark_root/disassembler/tests/sources/record_with_fields.pa", + "$ark_root/disassembler/tests/sources/record_in_record.pa", + ] +} + +ark_disasm_unittest_action("disasm_test_instructions") { + sources = [ + "$ark_root/disassembler/tests/instructions_test.cpp", + ] + + ark_asm_sources = [ + "$ark_root/disassembler/tests/sources/instructions.pa", + "$ark_root/disassembler/tests/sources/calls.pa", + "$ark_root/disassembler/tests/sources/returns.pa", + "$ark_root/disassembler/tests/sources/newarrs.pa", + ] + + # due to empty_record.pa dependency + extra_dependencies = [ ":disasm_test_records" ] +} + +group("unittest") { + testonly = true + deps = [ + ":disasm_test_labels", + ":disasm_test_records", + ":disasm_test_instructions", + ] +} + +group("host_unittest") { + testonly = true + deps = [ + ":disasm_test_labels_action(${host_toolchain})", + ":disasm_test_records_action(${host_toolchain})", + ":disasm_test_instructions_action(${host_toolchain})", + ] +} diff --git a/disassembler/tests/ohos_test.xml b/disassembler/tests/ohos_test.xml new file mode 100644 index 0000000000000000000000000000000000000000..b92cafbab6a16a4a9ad7a3c23085701be43ab91a --- /dev/null +++ b/disassembler/tests/ohos_test.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + diff --git a/libpandabase/BUILD.gn b/libpandabase/BUILD.gn index 7ed37053a3e75bc02e22effdb641ae7404434eca..a7040f280c7dc10c90b31c3e25746763210241d4 100644 --- a/libpandabase/BUILD.gn +++ b/libpandabase/BUILD.gn @@ -13,6 +13,7 @@ import("//ark/runtime_core/ark_config.gni") import("//build/ohos.gni") +import("$ark_root/tests/test.gni") config("arkbase_public_config") { include_dirs = [ @@ -30,6 +31,7 @@ ark_gen_file("events_gen") { if (is_mingw) { libarkbase_sources = [ + "$ark_root/libpandabase/mem/alloc_tracker.cpp", "$ark_root/libpandabase/mem/arena.cpp", "$ark_root/libpandabase/mem/arena_allocator.cpp", "$ark_root/libpandabase/mem/base_mem_stats.cpp", @@ -52,6 +54,7 @@ if (is_mingw) { ] } else { libarkbase_sources = [ + "$ark_root/libpandabase/mem/alloc_tracker.cpp", "$ark_root/libpandabase/mem/arena.cpp", "$ark_root/libpandabase/mem/arena_allocator.cpp", "$ark_root/libpandabase/mem/base_mem_stats.cpp", @@ -135,3 +138,71 @@ ohos_static_library("libarkbase_frontend_static") { deps = libarkbase_deps } + +config("arkbase_tests_config") { + cflags_cc = [ + "-Wno-unused", + "-Wno-sign-compare", + ] +} + +ark_unittest_action("arkbase_tests") { + module_out_path = "ark/runtime_core/libarkbase" + + sources = [ + "$ark_root/libpandabase/tests/list_test.cpp", + "$ark_root/libpandabase/tests/bit_helpers_test.cpp", + "$ark_root/libpandabase/tests/bit_memory_region_test.cpp", + "$ark_root/libpandabase/tests/bit_table_test.cpp", + "$ark_root/libpandabase/tests/bit_utils_test.cpp", + "$ark_root/libpandabase/tests/bit_vector_test.cpp", + "$ark_root/libpandabase/tests/string_helpers_test.cpp", + "$ark_root/libpandabase/tests/type_converter_tests.cpp", + "$ark_root/libpandabase/tests/logger_test.cpp", + "$ark_root/libpandabase/tests/dfx_test.cpp", + "$ark_root/libpandabase/tests/leb128_test.cpp", + "$ark_root/libpandabase/tests/utf_test.cpp", + "$ark_root/libpandabase/tests/arena_test.cpp", + "$ark_root/libpandabase/tests/arena_allocator_test.cpp", + "$ark_root/libpandabase/tests/expected_test.cpp", + "$ark_root/libpandabase/tests/code_allocator_test.cpp", + "$ark_root/libpandabase/tests/small_vector_test.cpp", + "$ark_root/libpandabase/tests/span_test.cpp", + "$ark_root/libpandabase/tests/pandargs_test.cpp", + "$ark_root/libpandabase/tests/pool_map_test.cpp", + "$ark_root/libpandabase/tests/hash_test.cpp", + "$ark_root/libpandabase/tests/math_helpers_test.cpp", + "$ark_root/libpandabase/tests/serializer_test.cpp", + "$ark_root/libpandabase/tests/base_mem_stats_test.cpp", + "$ark_root/libpandabase/tests/unique_fd_test.cpp", + "$ark_root/libpandabase/tests/mem_range_test.cpp", + "$ark_root/libpandabase/tests/mmap_fixed_test.cpp", + "$ark_root/libpandabase/tests/mmap_mem_pool_test.cpp", + "$ark_root/libpandabase/tests/native_bytes_from_mallinfo_test.cpp", + "$ark_root/libpandabase/tests/json_parser_test.cpp", + "$ark_root/libpandabase/tests/alloc_tracker_test.cpp", + ] + + configs = libarkbase_configs + configs += [ ":arkbase_tests_config" ] + + deps = [ + ":libarkbase_frontend_static", + ] + + no_cores = true +} + +group("unittest") { + testonly = true + deps = [ + ":arkbase_tests", + ] +} + +group("host_unittest") { + testonly = true + deps = [ + ":arkbase_tests_action(${host_toolchain})", + ] +} diff --git a/libpandafile/BUILD.gn b/libpandafile/BUILD.gn index ee9080e488c6f115c947d8cd7198167a5a25e69a..4893127bf46c4794fd34b7a742944add868c170a 100644 --- a/libpandafile/BUILD.gn +++ b/libpandafile/BUILD.gn @@ -13,6 +13,7 @@ import("//ark/runtime_core/ark_config.gni") import("//build/ohos.gni") +import("$ark_root/tests/test.gni") config("arkfile_public_config") { include_dirs = [ @@ -118,3 +119,57 @@ ark_isa_gen("isa_gen_libarkfile") { destination = "$target_gen_dir/include" ## target_gen_dir/include requires = [ "pandafile_isapi.rb" ] } + +config("arkfile_tests_config") { + cflags_cc = [ + "-Wno-sign-compare", + ] + + _target_gen_dir = get_label_info(":libarkfile_frontend_static", "target_gen_dir") + + include_dirs = [ + "${_target_gen_dir}/include/tests", + ] +} + +ark_unittest_action("arkfile_tests") { + module_out_path = "ark/runtime_core/libarkfile" + + sources = [ + "$ark_root/libpandafile/tests/bytecode_instruction_tests.cpp", + "$ark_root/libpandafile/tests/file_test.cpp", + "$ark_root/libpandafile/tests/file_item_container_test.cpp", + "$ark_root/libpandafile/tests/file_items_test.cpp", + "$ark_root/libpandafile/tests/bytecode_emitter_tests.cpp", + "$ark_root/libpandafile/tests/debug_info_extractor_test.cpp", + "$ark_root/libpandafile/tests/panda_cache_test.cpp", + "$ark_root/libpandafile/tests/file_format_version_test.cpp", + ] + + configs = libarkfile_configs + configs += [ + ":arkfile_tests_config", + "$ark_root/assembler:arkassembler_public_config", + ] + + deps = [ + ":isa_gen_libarkfile_tests_bytecode_emitter_tests_gen_h", + ":libarkfile_frontend_static", + "$ark_root/assembler:libarkassembler_frontend_static", + "//third_party/googletest:gmock", + ] +} + +group("unittest") { + testonly = true + deps = [ + ":arkfile_tests", + ] +} + +group("host_unittest") { + testonly = true + deps = [ + ":arkfile_tests_action(${host_toolchain})", + ] +} diff --git a/libziparchive/BUILD.gn b/libziparchive/BUILD.gn index b5108d0062cb233758ba3ae2aa961e8f7168a987..3d90efc2391a983b00e2904c72a9c0e0ee6a98b7 100644 --- a/libziparchive/BUILD.gn +++ b/libziparchive/BUILD.gn @@ -13,6 +13,7 @@ import("//ark/runtime_core/ark_config.gni") import("//build/ohos.gni") +import("$ark_root/tests/test.gni") config("arkziparchive_config") { include_dirs = [ @@ -73,3 +74,46 @@ ohos_static_library("libarkziparchive_frontend_static") { deps += [ "$ark_third_party_root/miniz:libminiz" ] } } + +config("arkziparchive_tests_config") { + cflags_cc = [ + "-Wno-sign-compare", + ] +} + +ark_unittest_action("arkziparchive_tests") { + module_out_path = "ark/runtime_core/libziparchive" + + sources = [ + "$ark_root/libziparchive/tests/libziparchive_tests.cpp", + ] + + configs = [ + ":arkziparchive_config", + "$ark_root:ark_config", + sdk_libc_secshared_config, + "$ark_root/assembler:arkassembler_public_config", + "$ark_root/libpandafile:arkfile_public_config", + ] + configs += [ ":arkziparchive_tests_config" ] + + deps = [ + ":libarkziparchive_frontend_static", + "$ark_root/assembler:libarkassembler_frontend_static", + "$ark_root/libpandafile:libarkfile_frontend_static", + ] +} + +group("unittest") { + testonly = true + deps = [ + ":arkziparchive_tests", + ] +} + +group("host_unittest") { + testonly = true + deps = [ + ":arkziparchive_tests_action(${host_toolchain})", + ] +} diff --git a/ohos.build b/ohos.build index 8fcb68ccf004ebef4a8993d2302be0deef36d545..234f4c9940ff4b4be704a54cb489ae8c3e8ce15a 100644 --- a/ohos.build +++ b/ohos.build @@ -11,7 +11,9 @@ ], "inner_kits": [], "system_kits": [], - "test_list": [] + "test_list": [ + "//ark/runtime_core:ark_runtime_unittest" + ] } } } diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index e4d9aee1afb9fd2f460cf32f5d5dd5f47ba3b246..f4ad37800650f16cd386934b77af089f4dce84dc 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -14,9 +14,11 @@ import("//ark/runtime_core/ark_config.gni") import("//build/ohos.gni") import("$ark_root/verification/verification.gni") +import("$ark_root/tests/test.gni") config("arkruntime_public_config") { include_dirs = [ + "$ark_root", "$ark_root/runtime", "$target_gen_dir", "$target_gen_dir/generated", @@ -433,3 +435,351 @@ ark_gen_file("libarkruntime_shorty_values_h") { requires = [ "../libpandafile/types.rb" ] output_file = "$target_gen_dir/generated/shorty_values.h" } + +config("arkruntime_tests_config") { + cflags_cc = [ + "-Wno-sign-compare", + ] + ldflags = [ + "-Wl,-rpath,\$ORIGIN/resource/ark/ark" + ] +} + +ohos_unittest("arkruntime_unittest") { + module_out_path = "ark/runtime_core/arkruntime" + resource_config_file = "$ark_root/runtime/tests/ohos_test.xml" +} + +template("arkruntime_unittest_action") { + _deps = [ + ":arkruntime_unittest", + ":libarkruntime_static", + "$ark_root/assembler:libarkassembler_frontend_static", + ] + + if (defined(invoker.extra_dependencies)) { + _deps += invoker.extra_dependencies + } + + _configs = [ + "$ark_root:ark_config", + "$ark_root/assembler:arkassembler_public_config", + "$ark_root/libpandabase:arkbase_public_config", + "$ark_root/libpandafile:arkfile_public_config", + ":arkruntime_public_config", + ":arkruntime_config", + sdk_libc_secshared_config, + ] + + if (defined(invoker.extra_configs)) { + _configs += invoker.extra_configs + } + + ark_unittest_action("${target_name}") { + forward_variables_from(invoker, + "*", + [ + "target_name", + "module_out_path", + "configs", + "deps", + ]) + + module_out_path = "ark/runtime_core/arkruntime" + + configs = _configs + + # should be last to override already passed parameters + configs += [ ":arkruntime_tests_config" ] + + deps = _deps + + no_cores = true + } +} + +arkruntime_unittest_action("arkruntime_multithreaded_test") { + sources = [ + "$ark_root/runtime/tests/multithreaded_intern_string_table_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_bitmap_clear_range_test") { + sources = [ + "$ark_root/runtime/tests/bitmap_clear_range_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_bitmap_order_object_alignment_test") { + sources = [ + "$ark_root/runtime/tests/bitmap_order_object_alignment_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_bitmap_visitor_object_alignment_test") { + sources = [ + "$ark_root/runtime/tests/bitmap_visitor_object_alignment_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_bitmap_page_alignment_test") { + sources = [ + "$ark_root/runtime/tests/bitmap_page_alignment_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_core_layout_test") { + sources = [ + "$ark_root/runtime/tests/array_test.cpp", + "$ark_root/runtime/tests/mark_word_test.cpp", + "$ark_root/runtime/tests/method_test.cpp", + "$ark_root/runtime/tests/mock_queue_thread_pool.cpp", + "$ark_root/runtime/tests/string_table_test.cpp", + "$ark_root/runtime/tests/string_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_mem_leak_test") { + sources = [ + "$ark_root/runtime/tests/mem_leak_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_statistic_test") { + sources = [ + "$ark_root/runtime/tests/histogram_test.cpp", + "$ark_root/runtime/tests/mem_stats_additional_info_test.cpp", + "$ark_root/runtime/tests/mem_stats_gc_test.cpp", + "$ark_root/runtime/tests/mem_stats_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_bump_allocator_test") { + sources = [ + "$ark_root/runtime/tests/bump_allocator_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_frame_allocator_test") { + sources = [ + "$ark_root/runtime/tests/frame_allocator_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_freelist_allocator_test") { + sources = [ + "$ark_root/runtime/tests/freelist_allocator_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_humongous_obj_allocator_test") { + sources = [ + "$ark_root/runtime/tests/humongous_obj_allocator_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_internal_allocator_test") { + sources = [ + "$ark_root/runtime/tests/internal_allocator_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_malloc_proxy_allocator_test") { + sources = [ + "$ark_root/runtime/tests/malloc-proxy-allocator-test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_pygote_space_allocator_gen_test") { + sources = [ + "$ark_root/runtime/tests/pygote_space_allocator_gen_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_pygote_space_allocator_stw_test") { + sources = [ + "$ark_root/runtime/tests/pygote_space_allocator_stw_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_region_allocator_test") { + sources = [ + "$ark_root/runtime/tests/region_allocator_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_rem_set_test") { + sources = [ + "$ark_root/runtime/tests/rem_set_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_runslots_allocator_test") { + sources = [ + "$ark_root/runtime/tests/runslots_allocator_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_memory_management_test_2") { + sources = [ + "$ark_root/runtime/tests/card_table_test.cpp", + "$ark_root/runtime/tests/crossing_map_test.cpp", + "$ark_root/runtime/tests/panda_smart_pointers_test.cpp", + "$ark_root/runtime/tests/tlab_test.cpp", + "$ark_root/runtime/tests/gc_task_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_multithreading_test") { + sources = [ + "$ark_root/runtime/tests/monitor_test.cpp", + "$ark_root/runtime/tests/thread_test.cpp", + ] +} + +arkruntime_unittest_action("arkruntime_options_test") { + sources = [ + "$ark_root/runtime/tests/options_test.cpp", + ] +} + +ohos_static_library("arkruntime_test_interpreter_impl") { + sources = [ "tests/interpreter/test_interpreter_impl.cpp" ] + + configs = [ + "$ark_root:ark_config", + "$ark_root/libpandabase:arkbase_public_config", + "$ark_root/libpandafile:arkfile_public_config", + "$ark_root/verification/gen:verification_public_config", + sdk_libc_secshared_config, + ":arkruntime_interpreter_impl_config", + ] + + deps = [ + ":arkruntime_gen_intrinsics_intrinsics_gen_h", + ":arkruntime_gen_intrinsics_intrinsics_h", + ":arkruntime_gen_intrinsics_unimplemented_intrinsics-inl_cpp", + ":arkruntime_gen_intrinsics_yaml", + ":isa_gen_libarkruntime_interpreter-inl_gen_h", + ":isa_gen_libarkruntime_isa_constants_gen_h", + ":isa_gen_libarkruntime_unimplemented_handlers-inl_h", + ":libarkruntime_options_gen_h", + ":libarkruntime_shorty_values_h", + "$ark_root/libpandabase:libarkbase", + "$ark_root/libpandafile:libarkfile", + "$ark_root/verification/gen:verification_verifier_messages_h", + ] +} + +arkruntime_unittest_action("arkruntime_interpreter_test") { + sources = [ + "$ark_root/runtime/tests/c2i_bridge_test.cpp", + "$ark_root/runtime/tests/class_linker_test.cpp", + "$ark_root/runtime/tests/class_linker_test_extension.cpp", + "$ark_root/runtime/tests/hybrid_object_allocator_test.cpp", + "$ark_root/runtime/tests/interpreter/test_interpreter.cpp", + "$ark_root/runtime/tests/interpreter/test_runtime_interface.cpp", + "$ark_root/runtime/tests/interpreter_test.cpp", + "$ark_root/runtime/tests/invokation_helper.cpp", + ] + + if (current_cpu == "arm") { + sources += [ + "$ark_root/runtime/tests/arch/arm/invokation_helper.S", + ] + } else if (current_cpu == "arm64") { + sources += [ + "$ark_root/runtime/tests/arch/aarch64/invokation_helper.S", + ] + } else if (current_cpu == "x86") { + sources += [ + "$ark_root/runtime/tests/arch/x86/invokation_helper.S", + ] + } else if (current_cpu == "amd64" || current_cpu == "x64" || + current_cpu == "x86_64") { + sources += [ + "$ark_root/runtime/tests/arch/amd64/invokation_helper.S", + ] + } + + extra_configs = [ + "$ark_root/runtime/asm_defines:asmdefines_public_config", + ] + + extra_dependencies = [ + ":arkruntime_test_interpreter_impl", + "$ark_root/runtime/asm_defines:asm_defines_generator", + ] +} + +arkruntime_unittest_action("arkruntime_utils_test") { + sources = [ + "$ark_root/runtime/tests/class_size_test.cpp", + "$ark_root/runtime/tests/debugger_test.cpp", + "$ark_root/runtime/tests/frame_test.cpp", + "$ark_root/runtime/tests/i2c_bridge_test.cpp", + "$ark_root/runtime/tests/math_helpers_test.cpp", + "$ark_root/runtime/tests/offsets_test.cpp", + "$ark_root/runtime/tests/time_utils_test.cpp", + ] +} + +group("unittest") { + testonly = true + deps = [ + ":arkruntime_multithreaded_test", + ":arkruntime_bitmap_clear_range_test", + ":arkruntime_bitmap_order_object_alignment_test", + ":arkruntime_bitmap_visitor_object_alignment_test", + ":arkruntime_bitmap_page_alignment_test", + ":arkruntime_core_layout_test", + ":arkruntime_memory_mem_leak_test", + ":arkruntime_memory_statistic_test", + ":arkruntime_memory_management_bump_allocator_test", + ":arkruntime_memory_management_frame_allocator_test", + ":arkruntime_memory_management_freelist_allocator_test", + ":arkruntime_memory_management_humongous_obj_allocator_test", + ":arkruntime_memory_management_internal_allocator_test", + ":arkruntime_memory_management_malloc_proxy_allocator_test", + ":arkruntime_memory_management_pygote_space_allocator_gen_test", + ":arkruntime_memory_management_pygote_space_allocator_stw_test", + ":arkruntime_memory_management_region_allocator_test", + ":arkruntime_memory_management_rem_set_test", + ":arkruntime_memory_management_runslots_allocator_test", + ":arkruntime_memory_management_test_2", + ":arkruntime_multithreading_test", + ":arkruntime_options_test", + ":arkruntime_interpreter_test", + ":arkruntime_utils_test", + ] +} + +group("host_unittest") { + testonly = true + deps = [ + ":arkruntime_multithreaded_test_action(${host_toolchain})", + ":arkruntime_bitmap_clear_range_test_action(${host_toolchain})", + ":arkruntime_bitmap_order_object_alignment_test_action(${host_toolchain})", + ":arkruntime_bitmap_visitor_object_alignment_test_action(${host_toolchain})", + ":arkruntime_bitmap_page_alignment_test_action(${host_toolchain})", + ":arkruntime_core_layout_test_action(${host_toolchain})", + ":arkruntime_memory_mem_leak_test_action(${host_toolchain})", + ":arkruntime_memory_statistic_test_action(${host_toolchain})", + ":arkruntime_memory_management_bump_allocator_test_action(${host_toolchain})", + ":arkruntime_memory_management_frame_allocator_test_action(${host_toolchain})", + ":arkruntime_memory_management_freelist_allocator_test_action(${host_toolchain})", + ":arkruntime_memory_management_humongous_obj_allocator_test_action(${host_toolchain})", + ":arkruntime_memory_management_internal_allocator_test_action(${host_toolchain})", + ":arkruntime_memory_management_malloc_proxy_allocator_test_action(${host_toolchain})", + ":arkruntime_memory_management_pygote_space_allocator_gen_test_action(${host_toolchain})", + ":arkruntime_memory_management_pygote_space_allocator_stw_test_action(${host_toolchain})", + ":arkruntime_memory_management_region_allocator_test_action(${host_toolchain})", + ":arkruntime_memory_management_rem_set_test_action(${host_toolchain})", + ":arkruntime_memory_management_runslots_allocator_test_action(${host_toolchain})", + ":arkruntime_memory_management_test_2_action(${host_toolchain})", + ":arkruntime_multithreading_test_action(${host_toolchain})", + ":arkruntime_options_test_action(${host_toolchain})", + ":arkruntime_interpreter_test_action(${host_toolchain})", + ":arkruntime_utils_test_action(${host_toolchain})", + ] +} diff --git a/runtime/tests/ohos_test.xml b/runtime/tests/ohos_test.xml new file mode 100644 index 0000000000000000000000000000000000000000..1f8e6c91e2767d35392b848e7a3e991560d816d4 --- /dev/null +++ b/runtime/tests/ohos_test.xml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/tests/run_unittest.sh b/tests/run_unittest.sh new file mode 100755 index 0000000000000000000000000000000000000000..cf69a52bcfc832a683555469654429a9845b812a --- /dev/null +++ b/tests/run_unittest.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# 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. + +set -e + +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi + +prlimit_prefix="" +timeout_prefix="timeout --preserve-status --signal=USR1 --kill-after=10s 20m" + +while getopts "ct:" arg +do + case $arg in + c) + prlimit_prefix="prlimit --core=0" + ;; + t) + test=${OPTARG} + ;; + *) + echo "unknown argument" >&2 + exit 1 + ;; + esac +done +shift $(($OPTIND - 1)) + +${prlimit_prefix} ${timeout_prefix} ${test} --gtest_shuffle --gtest_death_test_style=threadsafe diff --git a/tests/test.gni b/tests/test.gni new file mode 100644 index 0000000000000000000000000000000000000000..e3237298d456abe7fe3a8b678068ff2845e3f18a --- /dev/null +++ b/tests/test.gni @@ -0,0 +1,65 @@ +# 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("//ark/runtime_core/ark_config.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +template("ark_unittest_action") { + _target_name = "${target_name}" + _deps = [] + + if (defined(invoker.deps)) { + _deps += invoker.deps + } + + ohos_unittest(_target_name) { + forward_variables_from(invoker, + "*", + [ + "target_name", + "deps", + "no_cores", + ]) + deps = _deps + } + + is_host_test = get_label_info(_target_name, "toolchain") == host_toolchain + if (is_host_test) { + _module_out_path = invoker.module_out_path + + # unittest for host running + action("${_target_name}_action") { + testonly = true + + deps = [ ":${_target_name}(${host_toolchain})" ] + + script = "$ark_root/tests/run_unittest.sh" + + args = [ + "-t", + rebase_path("$root_out_dir/tests/unittest/${_module_out_path}/${_target_name}", root_build_dir) + ] + + if (defined(invoker.no_cores)) { + if (invoker.no_cores) { + args += [ + "-c" + ] + } + } + + outputs = [ "$target_out_dir/${_target_name}/" ] + } + } +} diff --git a/verification/tests/gtest/BUILD.gn b/verification/tests/gtest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fd4630b451d561d5bb04592694d42c32c1929bc4 --- /dev/null +++ b/verification/tests/gtest/BUILD.gn @@ -0,0 +1,80 @@ +# 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("//ark/runtime_core/ark_config.gni") +import("//build/ohos.gni") +import("$ark_root/tests/test.gni") + +config("arkverificatio_tests_config") { + cflags_cc = [ + "-Wno-sign-compare", + ] + ldflags = [ + "-Wl,-rpath,\$ORIGIN/resource/ark/ark" + ] +} + +ark_unittest_action("arkverification_tests") { + module_out_path = "ark/runtime_core/verificator" + + sources = [ + "$ark_root/verification/util/tests/environment.cpp", + "$ark_root/verification/util/tests/addr_map_test.cpp", + "$ark_root/verification/util/tests/tagged_index.cpp", + "$ark_root/verification/util/tests/flags.cpp", + "$ark_root/verification/util/tests/lazy_test.cpp", + "$ark_root/verification/util/tests/relation_test.cpp", + "$ark_root/verification/util/tests/equiv_classes_test.cpp", + "$ark_root/verification/util/tests/obj_pool_test.cpp", + "$ark_root/verification/absint/tests/reg_context_test.cpp", + "$ark_root/verification/absint/tests/exec_context_test.cpp", + "$ark_root/verification/cflow/tests/jumps_map_test.cpp", + "$ark_root/verification/cflow/tests/instructions_map_test.cpp", + "$ark_root/verification/value/tests/abstract_typed_value_test.cpp", + "$ark_root/verification/value/tests/variables_test.cpp", + "$ark_root/verification/type/tests/type_system_test.cpp", + ] + + configs = [ + "$ark_root:ark_config", + "$ark_root/runtime:arkruntime_public_config", + "$ark_root/libpandabase:arkbase_public_config", + "$ark_root/libpandafile:arkfile_public_config", + "$ark_root/verification/gen:verification_public_config", + sdk_libc_secshared_config, + ] + + configs += [ ":arkverificatio_tests_config" ] + + deps = [ + "$ark_root/runtime:libarkruntime_static", + ] + + no_cores = true + + resource_config_file = "$ark_root/verification/tests/gtest/ohos_test.xml" +} + +group("unittest") { + testonly = true + deps = [ + ":arkverification_tests", + ] +} + +group("host_unittest") { + testonly = true + deps = [ + ":arkverification_tests_action(${host_toolchain})", + ] +} diff --git a/verification/tests/gtest/ohos_test.xml b/verification/tests/gtest/ohos_test.xml new file mode 100644 index 0000000000000000000000000000000000000000..e54315f8b0563f3e43dc296c383b3ef50b9658e9 --- /dev/null +++ b/verification/tests/gtest/ohos_test.xml @@ -0,0 +1,23 @@ + + + + + + + +