From c20a060ab5a052284dfd9daf2473fbea2f485732 Mon Sep 17 00:00:00 2001 From: adstraw Date: Tue, 10 May 2022 09:27:47 -0700 Subject: [PATCH] pass back gtest error code along with gtest output --- tests/cpp-runtime/hexagon/run_unit_tests.cc | 8 ++++++-- ...exagon_unit_tests.py => test_run_unit_tests.py} | 14 ++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) rename tests/python/contrib/test_hexagon/{test_hexagon_unit_tests.py => test_run_unit_tests.py} (81%) diff --git a/tests/cpp-runtime/hexagon/run_unit_tests.cc b/tests/cpp-runtime/hexagon/run_unit_tests.cc index e409c441343e..6ad770da3326 100644 --- a/tests/cpp-runtime/hexagon/run_unit_tests.cc +++ b/tests/cpp-runtime/hexagon/run_unit_tests.cc @@ -108,8 +108,12 @@ TVM_REGISTER_GLOBAL("hexagon.run_unit_tests").set_body([](TVMArgs args, TVMRetVa testing::TestEventListeners& listeners = testing::UnitTest::GetInstance()->listeners(); listeners.Append(gprinter); - RUN_ALL_TESTS(); - *rv = gprinter->GetOutput(); + int gtest_error_code = RUN_ALL_TESTS(); + std::string gtest_output = gprinter->GetOutput(); + std::stringstream gtest_error_code_and_output; + gtest_error_code_and_output << gtest_error_code << std::endl; + gtest_error_code_and_output << gtest_output; + *rv = gtest_error_code_and_output.str(); delete gprinter; }); diff --git a/tests/python/contrib/test_hexagon/test_hexagon_unit_tests.py b/tests/python/contrib/test_hexagon/test_run_unit_tests.py similarity index 81% rename from tests/python/contrib/test_hexagon/test_hexagon_unit_tests.py rename to tests/python/contrib/test_hexagon/test_run_unit_tests.py index 7e80d8057961..efb87fea1e9e 100644 --- a/tests/python/contrib/test_hexagon/test_hexagon_unit_tests.py +++ b/tests/python/contrib/test_hexagon/test_run_unit_tests.py @@ -22,7 +22,7 @@ @requires_hexagon_toolchain -def test_hexagon_unit_tests(hexagon_session): +def test_run_unit_tests(hexagon_session): # arguments to pass to gtest # e.g. # 1) to run all tests use: @@ -32,13 +32,15 @@ def test_hexagon_unit_tests(hexagon_session): gtest_args = "" try: func = hexagon_session._rpc.get_function("hexagon.run_unit_tests") - result = func(gtest_args) - print(result) + gtest_error_code_and_output = func(gtest_args) + gtest_error_code = int(gtest_error_code_and_output.splitlines()[0]) + gtest_output = gtest_error_code_and_output.split("\n", 1)[-1] + print(gtest_output) + except: + gtest_error_code = 1 print( "This test requires the USE_HEXAGON_GTEST cmake flag to be specified with a path to a Hexagon gtest version normally located at /path/to/hexagon/sdk/utils/googletest/gtest" ) - result = "FAILED" - # check if the unit tests "FAILED" - assert result.find("FAILED") == -1 + np.testing.assert_equal(gtest_error_code, 0)