Skip to content

Commit

Permalink
pass back gtest error code along with gtest output
Browse files Browse the repository at this point in the history
  • Loading branch information
adstraw committed May 10, 2022
1 parent 69c56ce commit c20a060
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
8 changes: 6 additions & 2 deletions tests/cpp-runtime/hexagon/run_unit_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

0 comments on commit c20a060

Please sign in to comment.