diff --git a/CMakeLists.txt b/CMakeLists.txt index a25186d1c558..9161314f54d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -394,6 +394,15 @@ if(USE_PROFILER) list(APPEND RUNTIME_SRCS ${RUNTIME_VM_PROFILER_SRCS}) endif(USE_PROFILER) +# Enable ctest if gtest is available +find_path(GTEST_INCLUDE_DIR gtest/gtest.h) +find_library(GTEST_LIB gtest "$ENV{GTEST_LIB}") +if(GTEST_INCLUDE_DIR AND GTEST_LIB) + enable_testing() + include(CTest) + include(GoogleTest) +endif() + # Module rules include(cmake/modules/VTA.cmake) include(cmake/modules/StandaloneCrt.cmake) @@ -579,26 +588,16 @@ if (HIDE_PRIVATE_SYMBOLS AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") target_compile_definitions(tvm_allvisible PUBLIC DMLC_USE_LOGGING_LIBRARY=) endif() -# Tests -set(TEST_EXECS "") -file(GLOB TEST_SRCS tests/cpp/*.cc) -find_path(GTEST_INCLUDE_DIR gtest/gtest.h) -find_library(GTEST_LIB gtest "$ENV{GTEST_LIB}") - # Create the `cpptest` target if we can find GTest. If not, we create dummy # targets that give the user an informative error message. if(GTEST_INCLUDE_DIR AND GTEST_LIB) - foreach(__srcpath ${TEST_SRCS}) - get_filename_component(__srcname ${__srcpath} NAME) - string(REPLACE ".cc" "" __execname ${__srcname}) - add_executable(${__execname} ${__srcpath}) - list(APPEND TEST_EXECS ${__execname}) - target_include_directories(${__execname} SYSTEM PUBLIC ${GTEST_INCLUDE_DIR}) - target_link_libraries(${__execname} PRIVATE ${TVM_TEST_LIBRARY_NAME} ${GTEST_LIB} pthread dl) - set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_ALL 1) - set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) - endforeach() - add_custom_target(cpptest DEPENDS ${TEST_EXECS}) + file(GLOB TEST_SRCS tests/cpp/*.cc) + add_executable(cpptest ${TEST_SRCS}) + target_include_directories(cpptest SYSTEM PUBLIC ${GTEST_INCLUDE_DIR}) + target_link_libraries(cpptest PRIVATE ${TVM_TEST_LIBRARY_NAME} ${GTEST_LIB} gtest_main pthread dl) + set_target_properties(cpptest PROPERTIES EXCLUDE_FROM_ALL 1) + set_target_properties(cpptest PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) + gtest_discover_tests(cpptest) elseif(NOT GTEST_INCLUDE_DIR) add_custom_target(cpptest COMMAND echo "Missing Google Test headers in include path" diff --git a/cmake/modules/StandaloneCrt.cmake b/cmake/modules/StandaloneCrt.cmake index 072cba073189..5ed5f5ead088 100644 --- a/cmake/modules/StandaloneCrt.cmake +++ b/cmake/modules/StandaloneCrt.cmake @@ -132,26 +132,16 @@ if(USE_MICRO) PUBLIC_HEADER "${crt_headers}") endforeach() - # Standalone CRT tests - file(GLOB TEST_SRCS ${CMAKE_SOURCE_DIR}/tests/crt/*_test.cc) - find_path(GTEST_INCLUDE_DIR gtest/gtest.h) - find_library(GTEST_LIB gtest "$ENV{GTEST_LIB}") - # Create the `crttest` target if we can find GTest. If not, we create dummy # targets that give the user an informative error message. if(GTEST_INCLUDE_DIR AND GTEST_LIB) - foreach(__srcpath ${TEST_SRCS}) - get_filename_component(__srcname ${__srcpath} NAME) - string(REPLACE ".cc" "" __execname ${__srcname}) - add_executable(${__execname} ${__srcpath}) - list(APPEND TEST_EXECS ${__execname}) - target_include_directories(${__execname} PUBLIC ${GTEST_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/standalone_crt/include ${CMAKE_SOURCE_DIR}/src/runtime/micro) - target_compile_options(${__execname} PRIVATE -pthread) - target_link_libraries(${__execname} ${cmake_crt_libraries} ${GTEST_LIB} pthread) - set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_ALL 1) - set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) - endforeach() - add_custom_target(crttest DEPENDS ${TEST_EXECS}) + file(GLOB TEST_SRCS ${CMAKE_SOURCE_DIR}/tests/crt/*_test.cc) + add_executable(crttest ${TEST_SRCS}) + target_include_directories(crttest SYSTEM PUBLIC ${GTEST_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/standalone_crt/include ${CMAKE_SOURCE_DIR}/src/runtime/micro) + target_link_libraries(crttest PRIVATE ${cmake_crt_libraries} ${GTEST_LIB} gtest_main pthread dl) + set_target_properties(crttest PROPERTIES EXCLUDE_FROM_ALL 1) + set_target_properties(crttest PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) + gtest_discover_tests(crttest) elseif(NOT GTEST_INCLUDE_DIR) add_custom_target(crttest COMMAND echo "Missing Google Test headers in include path" diff --git a/tests/cpp/arith_simplify_test.cc b/tests/cpp/arith_simplify_test.cc index 829e2689887e..a3e9bdfa56bd 100644 --- a/tests/cpp/arith_simplify_test.cc +++ b/tests/cpp/arith_simplify_test.cc @@ -53,8 +53,3 @@ TEST(Simplify, Mod) { auto es = ana.canonical_simplify(mod - x); ICHECK(tvm::tir::is_zero(es)); } -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/attrs_test.cc b/tests/cpp/attrs_test.cc index 4d6de60b9706..2c9560bf077f 100644 --- a/tests/cpp/attrs_test.cc +++ b/tests/cpp/attrs_test.cc @@ -80,10 +80,4 @@ TEST(Attrs, Basic) { n->PrintDocString(os); LOG(INFO) << "docstring\n" << os.str(); ICHECK(os.str().find("expr : PrimExpr, default=1") != std::string::npos); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/auto_scheduler_test.cc b/tests/cpp/auto_scheduler_test.cc index 16dfd56a69ea..cca87ce1bd16 100644 --- a/tests/cpp/auto_scheduler_test.cc +++ b/tests/cpp/auto_scheduler_test.cc @@ -169,10 +169,4 @@ TEST(ComputeDAG, AccessAnalyzer) { } } } -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/build_module_test.cc b/tests/cpp/build_module_test.cc index 204a824f9248..f774fc01a5f4 100644 --- a/tests/cpp/build_module_test.cc +++ b/tests/cpp/build_module_test.cc @@ -199,9 +199,3 @@ TEST(BuildModule, Heterogeneous) { ICHECK_LT(std::fabs(p_out[i] - (i + (i + 1.0) - (i - 1.0))), 1e-5); } } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/container_test.cc b/tests/cpp/container_test.cc index 7d1fa790146e..ad0632c063d2 100644 --- a/tests/cpp/container_test.cc +++ b/tests/cpp/container_test.cc @@ -694,10 +694,4 @@ TEST(Optional, PackedCall) { test_ffi(Optional(s), static_cast(kTVMObjectRValueRefArg)); test_ffi(s, static_cast(kTVMObjectHandle)); test_ffi(String(s), static_cast(kTVMObjectRValueRefArg)); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/dataflow_pattern_test.cc b/tests/cpp/dataflow_pattern_test.cc index bdccaaa2e6ba..81c4c4f03f9f 100644 --- a/tests/cpp/dataflow_pattern_test.cc +++ b/tests/cpp/dataflow_pattern_test.cc @@ -191,10 +191,4 @@ TEST(DFPattern, HasShape) { ICHECK(node); ICHECK(node->pattern == a); ICHECK(node->shape == shape); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/expr_test.cc b/tests/cpp/expr_test.cc index 99ff26dc0b58..bf8579cc16c2 100644 --- a/tests/cpp/expr_test.cc +++ b/tests/cpp/expr_test.cc @@ -41,10 +41,4 @@ TEST(ExprNodeRef, Basic) { PrimExpr z = max(x + 1 + 2, 100); const tir::MaxNode* op = z.as(); ICHECK(GetRef(op).same_as(z)); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/ir_functor_test.cc b/tests/cpp/ir_functor_test.cc index 9e8595d6809c..a3c5e4d6be40 100644 --- a/tests/cpp/ir_functor_test.cc +++ b/tests/cpp/ir_functor_test.cc @@ -323,10 +323,4 @@ TEST(IRF, StmtMutator) { ICHECK(new_block->writes[0]->region[0]->min.same_as(x)); ICHECK(new_block->match_buffers[0]->source->region[0]->min.same_as(x)); } -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/microtvm_runtime_standalone_test.cc b/tests/cpp/microtvm_runtime_standalone_test.cc index ee324f89b48f..764bbeaf1f38 100644 --- a/tests/cpp/microtvm_runtime_standalone_test.cc +++ b/tests/cpp/microtvm_runtime_standalone_test.cc @@ -127,10 +127,4 @@ TEST(MicroStandaloneRuntime, BuildModule) { } #endif -#endif - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +#endif \ No newline at end of file diff --git a/tests/cpp/object_protocol_test.cc b/tests/cpp/object_protocol_test.cc index aaf9ee4af271..eba69d98cf62 100644 --- a/tests/cpp/object_protocol_test.cc +++ b/tests/cpp/object_protocol_test.cc @@ -94,10 +94,4 @@ TEST(ObjectHierachy, Basic) { ICHECK(refB.as() == nullptr); ICHECK(refB.as() == nullptr); ICHECK(refB.as() != nullptr); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/packed_func_test.cc b/tests/cpp/packed_func_test.cc index f993f9605c91..46183f4c9156 100644 --- a/tests/cpp/packed_func_test.cc +++ b/tests/cpp/packed_func_test.cc @@ -305,10 +305,4 @@ TEST(TypedPackedFunc, RValue) { // auto conversion. tf(1, true); } -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/parallel_for_test.cc b/tests/cpp/parallel_for_test.cc index a4549344bd11..c1e568e4cede 100644 --- a/tests/cpp/parallel_for_test.cc +++ b/tests/cpp/parallel_for_test.cc @@ -118,9 +118,3 @@ TEST(ParallelFor, Exception) { } ICHECK(exception); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/pattern_match_test.cc b/tests/cpp/pattern_match_test.cc index dfe09406ba52..c5234d8f6509 100644 --- a/tests/cpp/pattern_match_test.cc +++ b/tests/cpp/pattern_match_test.cc @@ -137,10 +137,4 @@ TEST(Pattern, IntImm) { ICHECK(!(v * c).Match(tx * ty)); // cannot match tx + 1 to v ICHECK(!(v * c).Match((tx + 1) * 3)); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/profiling_test.cc b/tests/cpp/profiling_test.cc index f770bfda8e5b..d2fc0e95db2c 100644 --- a/tests/cpp/profiling_test.cc +++ b/tests/cpp/profiling_test.cc @@ -39,9 +39,3 @@ TEST(DefaultTimer, Basic) { } } // namespace runtime } // namespace tvm - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/random_engine_test.cc b/tests/cpp/random_engine_test.cc index 6435d5dc3c1c..6ccb7eb05c57 100644 --- a/tests/cpp/random_engine_test.cc +++ b/tests/cpp/random_engine_test.cc @@ -62,10 +62,4 @@ TEST(RandomEngine, Serialization) { rand_state_b = rand_state_a; for (int i = 0; i < 100000; i++) ICHECK_EQ(rng_a(), rng_b()); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/tests/cpp/relay_build_module_test.cc b/tests/cpp/relay_build_module_test.cc index 37e9e6f9c42c..ccfba1efb969 100644 --- a/tests/cpp/relay_build_module_test.cc +++ b/tests/cpp/relay_build_module_test.cc @@ -180,10 +180,4 @@ TEST(Relay, GetExprRefCount) { ICHECK(ref_count[x.get()] == 2); ICHECK(ref_count[y.get()] == 1); ICHECK(ref_count[z.get()] == 1); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/relay_dismantler_test.cc b/tests/cpp/relay_dismantler_test.cc index 8c74d4151818..37b44524e770 100644 --- a/tests/cpp/relay_dismantler_test.cc +++ b/tests/cpp/relay_dismantler_test.cc @@ -143,9 +143,3 @@ TEST(Relay, TupleiGetItemSharedTuple) { .as() ->args.size()); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/relay_pass_type_infer_test.cc b/tests/cpp/relay_pass_type_infer_test.cc index 38ac906c6dac..6db595281813 100644 --- a/tests/cpp/relay_pass_type_infer_test.cc +++ b/tests/cpp/relay_pass_type_infer_test.cc @@ -41,9 +41,3 @@ TEST(Relay, SelfReference) { auto expected = relay::FuncType(tvm::Array{tensor_type}, tensor_type, {}, {}); ICHECK(tvm::StructuralEqual()(type_fx->checked_type(), expected)); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/relay_text_printer_test.cc b/tests/cpp/relay_text_printer_test.cc index ed8029064720..58fa228f8a46 100644 --- a/tests/cpp/relay_text_printer_test.cc +++ b/tests/cpp/relay_text_printer_test.cc @@ -56,9 +56,3 @@ TEST(Relay, LargeGraphPrint) { }; ASSERT_EXIT((foo(), exit(0)), ::testing::ExitedWithCode(0), ".*"); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/relay_transform_sequential_test.cc b/tests/cpp/relay_transform_sequential_test.cc index 6d38e1017042..ae1a546e5ddf 100644 --- a/tests/cpp/relay_transform_sequential_test.cc +++ b/tests/cpp/relay_transform_sequential_test.cc @@ -128,9 +128,3 @@ TEST(PassContextListConfigs, Basic) { auto config = configs["relay.backend.use_auto_scheduler"]; ICHECK_EQ(config["type"], "IntImm"); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/support_test.cc b/tests/cpp/support_test.cc index 7d523fe8d537..df9271f4b49c 100644 --- a/tests/cpp/support_test.cc +++ b/tests/cpp/support_test.cc @@ -58,9 +58,3 @@ TEST(HashTests, HashStability) { } // namespace test } // namespace tvm - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/target_test.cc b/tests/cpp/target_test.cc index 8dba462132ac..2e8ba11c0262 100644 --- a/tests/cpp/target_test.cc +++ b/tests/cpp/target_test.cc @@ -157,9 +157,3 @@ TEST(TargetKindRegistryListTargetKinds, Basic) { ICHECK_EQ(names.empty(), false); ICHECK_EQ(std::count(std::begin(names), std::end(names), "llvm"), 1); } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/tensor_test.cc b/tests/cpp/tensor_test.cc index ea02ca656dce..8d2a52e2dd67 100644 --- a/tests/cpp/tensor_test.cc +++ b/tests/cpp/tensor_test.cc @@ -48,10 +48,4 @@ TEST(Tensor, Reduce) { auto C = te::compute( {m, n}, [&](Var i, Var j) { return sum(max(1 + A[i][rv] + 1, B[j][rv]), {rv}); }, "C"); LOG(INFO) << C->op.as()->body; -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/texture_copy_test.cc b/tests/cpp/texture_copy_test.cc index 688bcab758ca..92c12bafdd9a 100644 --- a/tests/cpp/texture_copy_test.cc +++ b/tests/cpp/texture_copy_test.cc @@ -134,9 +134,3 @@ TEST(TextureCopy, OverwritePoolSubview) { } } } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/threading_backend_test.cc b/tests/cpp/threading_backend_test.cc index cf7434b4b036..948838971796 100644 --- a/tests/cpp/threading_backend_test.cc +++ b/tests/cpp/threading_backend_test.cc @@ -63,9 +63,3 @@ TEST(ThreadingBackend, TVMBackendParallelLaunchMultipleThreads) { } } } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/cpp/tir_analysis_side_effect.cc b/tests/cpp/tir_analysis_side_effect.cc index 022f2cffeda8..0fbe8cc8dde1 100644 --- a/tests/cpp/tir_analysis_side_effect.cc +++ b/tests/cpp/tir_analysis_side_effect.cc @@ -32,10 +32,4 @@ TEST(SimplePasses, SideEffect) { ICHECK(tir::SideEffect(exp(tir::Cast(DataType::Float(32), i + 1))) == tir::CallEffectKind::kPure); ICHECK(tir::SideEffect(tir::Call(DataType::Handle(), tir::builtin::tvm_storage_sync(), {})) == tir::CallEffectKind::kUpdateState); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/cpp/topi_ewise_test.cc b/tests/cpp/topi_ewise_test.cc index e5ba92a89058..9f4457de5192 100644 --- a/tests/cpp/topi_ewise_test.cc +++ b/tests/cpp/topi_ewise_test.cc @@ -31,9 +31,3 @@ TEST(Tensor, Basic) { } } // namespace topi } // namespace tvm - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/crt/aot_memory_test.cc b/tests/crt/aot_memory_test.cc index 06565dda68d1..3fce7909deba 100644 --- a/tests/crt/aot_memory_test.cc +++ b/tests/crt/aot_memory_test.cc @@ -21,7 +21,6 @@ #include #include "../../src/runtime/crt/memory/stack_allocator.c" -#include "platform.cc" // Check with LIFO checks enabled for stack allocator #define TVM_CRT_STACK_ALLOCATOR_ENABLE_LIFO_CHECK @@ -199,10 +198,4 @@ TEST(AOTMemory, InitialMemoryMisAlignment) { ASSERT_EQ(tvm_runtime_workspace.next_alloc, &model_memory_ptr[alignment_offset]); ASSERT_EQ(tvm_runtime_workspace.workspace_size, sizeof(model_memory) - offset - alignment_offset); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/crt/framing_test.cc b/tests/crt/framing_test.cc index 0161afe31696..c6dd2c098dd0 100644 --- a/tests/crt/framing_test.cc +++ b/tests/crt/framing_test.cc @@ -27,7 +27,6 @@ #include "buffer_write_stream.h" #include "crt_config.h" -#include "platform.cc" using ::tvm::runtime::micro_rpc::Escape; using ::tvm::runtime::micro_rpc::FrameBuffer; @@ -62,16 +61,6 @@ class TestPacket { std::string wire; }; -void PrintTo(const TestPacket* p, std::ostream* os) { - *os << "TestPacket(\"" << p->name << "\", ...)"; -} - -void PrintTo(tvm_crt_error_t p, std::ostream* os) { - std::ios_base::fmtflags f(os->flags()); - *os << "tvm_crt_error_t(0x" << std::hex << std::setw(8) << std::setfill('0') << p << ")"; - os->flags(f); -} - std::vector TestPacket::instances; #define TEST_PACKET(name, payload, wire) \ @@ -308,10 +297,4 @@ TEST_P(UnframerTestParameterized, TestArbitraryPacketReset) { #pragma GCC diagnostic ignored "-Wdeprecated-declarations" INSTANTIATE_TEST_CASE_P(UnframerTests, UnframerTestParameterized, ::testing::ValuesIn(TestPacket::instances)); -#pragma GCC diagnostic pop - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +#pragma GCC diagnostic pop \ No newline at end of file diff --git a/tests/crt/func_registry_test.cc b/tests/crt/func_registry_test.cc index 2889f7b899a7..7a40c27f6765 100644 --- a/tests/crt/func_registry_test.cc +++ b/tests/crt/func_registry_test.cc @@ -22,8 +22,6 @@ #include #include -#include "platform.cc" - typedef struct { const char* a; const char* b; @@ -231,10 +229,4 @@ TEST(MutableFuncRegistry, Create) { EXPECT_EQ(kTvmErrorFunctionRegistryFull, TVMMutableFuncRegistry_Set(®, test_function_name, TestFunctionHandle(0x03), 0)); } -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/crt/memory_test.cc b/tests/crt/memory_test.cc index d8465c8e8743..609c51953f31 100644 --- a/tests/crt/memory_test.cc +++ b/tests/crt/memory_test.cc @@ -80,9 +80,3 @@ TEST_F(MemoryManagerTest, AllocFreeFifo) { } } } - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} diff --git a/tests/crt/session_test.cc b/tests/crt/session_test.cc index 14de3089fb34..48d7475334c2 100644 --- a/tests/crt/session_test.cc +++ b/tests/crt/session_test.cc @@ -27,7 +27,6 @@ #include "buffer_write_stream.h" #include "crt_config.h" -#include "platform.cc" using ::tvm::runtime::micro_rpc::Framer; using ::tvm::runtime::micro_rpc::MessageType; @@ -107,16 +106,6 @@ void TestSessionMessageReceivedThunk(void* context, MessageType message_type, Fr } } -void PrintTo(tvm_crt_error_t p, std::ostream* os) { - std::ios_base::fmtflags f(os->flags()); - *os << "tvm_crt_error_t(0x" << std::hex << std::setw(8) << std::setfill('0') << p << ")"; - os->flags(f); -} - -void PrintTo(ReceivedMessage msg, std::ostream* os) { - *os << "ReceivedMessage(" << int(msg.type) << ", \"" << msg.message << "\")"; -} - class SessionTest : public ::testing::Test { public: static constexpr const uint8_t kAliceNonce = 0x3c; @@ -258,10 +247,4 @@ TEST_F(SessionTest, DoubleStart) { bob_.ClearBuffers(); alice_.WriteTo(&bob_); EXPECT_TRUE(bob_.sess.IsEstablished()); -} - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - testing::FLAGS_gtest_death_test_style = "threadsafe"; - return RUN_ALL_TESTS(); -} +} \ No newline at end of file diff --git a/tests/scripts/task_cpp_unittest.sh b/tests/scripts/task_cpp_unittest.sh index 62c563b2610d..3df7b580d79d 100755 --- a/tests/scripts/task_cpp_unittest.sh +++ b/tests/scripts/task_cpp_unittest.sh @@ -30,9 +30,7 @@ export VTA_HW_PATH=`pwd`/3rdparty/vta-hw export TVM_BIND_THREADS=0 export OMP_NUM_THREADS=1 -# Remove existing testcases -rm -f build/*_test - +# Build cpptest suite make cpptest -j2 # "make crttest" requires USE_MICRO to be enabled, which is not always the case. @@ -40,9 +38,7 @@ if grep crttest build/Makefile > /dev/null; then make crttest # NOTE: don't parallelize, due to issue with build deps. fi -for test in build/*_test; do - ./$test -done +cd build && ctest --gtest_death_test_style=threadsafe && cd .. # Test MISRA-C runtime cd apps/bundle_deploy