From 2b36ca0d25b5080e857ff9819979335e466c188b Mon Sep 17 00:00:00 2001 From: adstraw Date: Thu, 5 May 2022 14:39:39 -0700 Subject: [PATCH 01/10] [Hexagon] capture gtest output and return over FFI --- tests/cpp-runtime/hexagon/run_all_tests.cc | 60 --------- tests/cpp-runtime/hexagon/run_unit_tests.cc | 118 ++++++++++++++++++ .../python/contrib/test_hexagon/unit_tests.py | 10 +- 3 files changed, 124 insertions(+), 64 deletions(-) delete mode 100644 tests/cpp-runtime/hexagon/run_all_tests.cc create mode 100644 tests/cpp-runtime/hexagon/run_unit_tests.cc diff --git a/tests/cpp-runtime/hexagon/run_all_tests.cc b/tests/cpp-runtime/hexagon/run_all_tests.cc deleted file mode 100644 index 166d89b63566..000000000000 --- a/tests/cpp-runtime/hexagon/run_all_tests.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -#include -#include -#include - -#include -#include - -#include "../src/support/utils.h" - -namespace tvm { -namespace runtime { -namespace hexagon { - -TVM_REGISTER_GLOBAL("hexagon.run_all_tests").set_body([](TVMArgs args, TVMRetValue* rv) { - // gtest args are passed into this packed func as a singular string - // split gtest args using delimiter and build argument vector - std::vector parsed_args = tvm::support::Split(args[0], ' '); - std::vector argv; - - // add executable name - argv.push_back(const_cast("hexagon_run_all_tests")); - - // add parsed arguments - for (int i = 0; i < parsed_args.size(); ++i) { - argv.push_back(const_cast(parsed_args[i].data())); - } - - // end of parsed arguments - argv.push_back(nullptr); - - // set argument count - int argc = argv.size() - 1; - - // initialize gtest with arguments and run - ::testing::InitGoogleTest(&argc, argv.data()); - *rv = RUN_ALL_TESTS(); -}); - -} // namespace hexagon -} // namespace runtime -} // namespace tvm diff --git a/tests/cpp-runtime/hexagon/run_unit_tests.cc b/tests/cpp-runtime/hexagon/run_unit_tests.cc new file mode 100644 index 000000000000..e409c441343e --- /dev/null +++ b/tests/cpp-runtime/hexagon/run_unit_tests.cc @@ -0,0 +1,118 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +#include +#include +#include + +#include +#include + +#include "../src/support/utils.h" + +namespace tvm { +namespace runtime { +namespace hexagon { + +class GtestPrinter : public testing::EmptyTestEventListener { + void OnTestProgramStart(const testing::UnitTest& unit_test) override { + gtest_out_ << "[==========] Running " << unit_test.test_to_run_count() << " test(s) from " + << unit_test.test_suite_to_run_count() << " test suite(s).\n"; + } + + void OnTestProgramEnd(const testing::UnitTest& unit_test) override { + gtest_out_ << "[==========] " << unit_test.test_to_run_count() << " test(s) from " + << unit_test.test_suite_to_run_count() << " test suite(s) ran. (" + << unit_test.elapsed_time() << " ms total)\n"; + gtest_out_ << "[ PASSED ] " << unit_test.successful_test_count() << " test(s)\n"; + + if (unit_test.failed_test_count()) { + gtest_out_ << "[ FAILED ] " << unit_test.failed_test_count() << " test(s)\n"; + } + } + + void OnTestSuiteStart(const testing::TestSuite& test_suite) override { + gtest_out_ << "[----------] " << test_suite.test_to_run_count() << " test(s) from " + << test_suite.name() << "\n"; + } + + void OnTestSuiteEnd(const testing::TestSuite& test_suite) override { + gtest_out_ << "[----------] " << test_suite.test_to_run_count() << " test(s) from " + << test_suite.name() << " (" << test_suite.elapsed_time() << " ms total)\n"; + } + + void OnTestStart(const testing::TestInfo& test_info) override { + gtest_out_ << "[ RUN ] " << test_info.test_suite_name() << "." << test_info.name() << "\n"; + } + + void OnTestEnd(const testing::TestInfo& test_info) override { + for (int i = 0; i < test_info.result()->total_part_count(); ++i) { + gtest_out_ << test_info.result()->GetTestPartResult(i).message() << "\n"; + } + if (test_info.result()->Passed()) { + gtest_out_ << "[ OK ]"; + } else { + gtest_out_ << "[ FAILED ]"; + } + gtest_out_ << " " << test_info.test_suite_name() << "." << test_info.name() << " (" + << test_info.result()->elapsed_time() << " ms)\n"; + } + + std::stringstream gtest_out_; + + public: + std::string GetOutput() { return gtest_out_.str(); } +}; + +TVM_REGISTER_GLOBAL("hexagon.run_unit_tests").set_body([](TVMArgs args, TVMRetValue* rv) { + // gtest args are passed into this packed func as a singular string + // split gtest args using delimiter and build argument vector + std::vector parsed_args = tvm::support::Split(args[0], ' '); + std::vector argv; + + // add executable name + argv.push_back(const_cast("hexagon_run_unit_tests")); + + // add parsed arguments + for (int i = 0; i < parsed_args.size(); ++i) { + argv.push_back(const_cast(parsed_args[i].data())); + } + + // end of parsed arguments + argv.push_back(nullptr); + + // set argument count + int argc = argv.size() - 1; + + // initialize gtest with arguments and run + ::testing::InitGoogleTest(&argc, argv.data()); + + // add printer to capture gtest output in a string + GtestPrinter* gprinter = new GtestPrinter(); + testing::TestEventListeners& listeners = testing::UnitTest::GetInstance()->listeners(); + listeners.Append(gprinter); + + RUN_ALL_TESTS(); + *rv = gprinter->GetOutput(); + delete gprinter; +}); + +} // namespace hexagon +} // namespace runtime +} // namespace tvm diff --git a/tests/python/contrib/test_hexagon/unit_tests.py b/tests/python/contrib/test_hexagon/unit_tests.py index d340cba5b150..7e80d8057961 100644 --- a/tests/python/contrib/test_hexagon/unit_tests.py +++ b/tests/python/contrib/test_hexagon/unit_tests.py @@ -22,7 +22,7 @@ @requires_hexagon_toolchain -def test_cache_read_write_2d(hexagon_session): +def test_hexagon_unit_tests(hexagon_session): # arguments to pass to gtest # e.g. # 1) to run all tests use: @@ -31,12 +31,14 @@ def test_cache_read_write_2d(hexagon_session): # gtest_args = "--gtest_repeat=2 --gtest_filter=*foo*" gtest_args = "" try: - func = hexagon_session._rpc.get_function("hexagon.run_all_tests") + func = hexagon_session._rpc.get_function("hexagon.run_unit_tests") result = func(gtest_args) + print(result) except: 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 = 1 + result = "FAILED" - np.testing.assert_equal(result, 0) + # check if the unit tests "FAILED" + assert result.find("FAILED") == -1 From cf5704b5a9b55b947cc9b50df1612244a44ce89b Mon Sep 17 00:00:00 2001 From: adstraw Date: Mon, 9 May 2022 16:16:46 -0700 Subject: [PATCH 02/10] rename to test_hexagon_unit_tests.py so it will run in CI --- tests/cpp-runtime/hexagon/{run_unit_tests.cc => run_all_tests.cc} | 0 .../test_hexagon/{unit_tests.py => test_hexagon_unit_tests.py} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/cpp-runtime/hexagon/{run_unit_tests.cc => run_all_tests.cc} (100%) rename tests/python/contrib/test_hexagon/{unit_tests.py => test_hexagon_unit_tests.py} (100%) diff --git a/tests/cpp-runtime/hexagon/run_unit_tests.cc b/tests/cpp-runtime/hexagon/run_all_tests.cc similarity index 100% rename from tests/cpp-runtime/hexagon/run_unit_tests.cc rename to tests/cpp-runtime/hexagon/run_all_tests.cc diff --git a/tests/python/contrib/test_hexagon/unit_tests.py b/tests/python/contrib/test_hexagon/test_hexagon_unit_tests.py similarity index 100% rename from tests/python/contrib/test_hexagon/unit_tests.py rename to tests/python/contrib/test_hexagon/test_hexagon_unit_tests.py From 69c56ceca41dbb5c87042839e6e60067cdb42376 Mon Sep 17 00:00:00 2001 From: adstraw Date: Mon, 9 May 2022 16:17:40 -0700 Subject: [PATCH 03/10] rename to run_unit_tests.cc --- tests/cpp-runtime/hexagon/{run_all_tests.cc => run_unit_tests.cc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/cpp-runtime/hexagon/{run_all_tests.cc => run_unit_tests.cc} (100%) diff --git a/tests/cpp-runtime/hexagon/run_all_tests.cc b/tests/cpp-runtime/hexagon/run_unit_tests.cc similarity index 100% rename from tests/cpp-runtime/hexagon/run_all_tests.cc rename to tests/cpp-runtime/hexagon/run_unit_tests.cc From c20a060ab5a052284dfd9daf2473fbea2f485732 Mon Sep 17 00:00:00 2001 From: adstraw Date: Tue, 10 May 2022 09:27:47 -0700 Subject: [PATCH 04/10] 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) From cc09fc3f1e83551661240c6388784878b098d74e Mon Sep 17 00:00:00 2001 From: adstraw Date: Tue, 10 May 2022 11:49:33 -0700 Subject: [PATCH 05/10] skip Hexagon unit tests if gtest not enabled --- .../test_hexagon/test_run_unit_tests.py | 23 ++++++++----------- tests/scripts/task_build_hexagon_api.sh | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/python/contrib/test_hexagon/test_run_unit_tests.py b/tests/python/contrib/test_hexagon/test_run_unit_tests.py index efb87fea1e9e..c7457b270aa1 100644 --- a/tests/python/contrib/test_hexagon/test_run_unit_tests.py +++ b/tests/python/contrib/test_hexagon/test_run_unit_tests.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +import os import pytest import numpy as np from tvm.contrib.hexagon.build import HexagonLauncher @@ -22,6 +23,10 @@ @requires_hexagon_toolchain +@pytest.mark.skipif( + os.environ.get("USE_HEXAGON_GTEST") == None, + reason="This test requires the USE_HEXAGON_GTEST to be specified with a path to a Hexagon gtest version normally located at /path/to/hexagon/sdk/utils/googletest/gtest", +) def test_run_unit_tests(hexagon_session): # arguments to pass to gtest # e.g. @@ -30,17 +35,9 @@ def test_run_unit_tests(hexagon_session): # 2) to run all tests with "foo" in their name twice use: # gtest_args = "--gtest_repeat=2 --gtest_filter=*foo*" gtest_args = "" - try: - func = hexagon_session._rpc.get_function("hexagon.run_unit_tests") - 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" - ) - + func = hexagon_session._rpc.get_function("hexagon.run_unit_tests") + 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) np.testing.assert_equal(gtest_error_code, 0) diff --git a/tests/scripts/task_build_hexagon_api.sh b/tests/scripts/task_build_hexagon_api.sh index 5a6a859ef1a5..403c44661419 100755 --- a/tests/scripts/task_build_hexagon_api.sh +++ b/tests/scripts/task_build_hexagon_api.sh @@ -45,6 +45,6 @@ cmake -DANDROID_ABI=arm64-v8a \ -DUSE_HEXAGON_TOOLCHAIN="${HEXAGON_TOOLCHAIN}" \ -DUSE_OUTPUT_BINARY_DIR="${output_binary_directory}" .. # TODO(hexagon-team): enable this once https://github.com/apache/tvm/issues/11237 is fixed. - # -DUSE_HEXAGON_GTEST="${HEXAGON_SDK_PATH}/utils/googletest/gtest" .. + # -DUSE_HEXAGON_GTEST="${USE_HEXAGON_GTEST}" .. make -j$(nproc) From 04fc4fe78b27b38c29cd6fa22b3d1a7331c5627c Mon Sep 17 00:00:00 2001 From: adstraw Date: Tue, 10 May 2022 12:54:38 -0700 Subject: [PATCH 06/10] pass gtest_args as pytest argument --- tests/python/contrib/test_hexagon/conftest.py | 10 ++++++++++ .../contrib/test_hexagon/test_run_unit_tests.py | 13 +++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/python/contrib/test_hexagon/conftest.py b/tests/python/contrib/test_hexagon/conftest.py index 7a90317d5506..e09329b76b20 100644 --- a/tests/python/contrib/test_hexagon/conftest.py +++ b/tests/python/contrib/test_hexagon/conftest.py @@ -218,3 +218,13 @@ def aot_target(aot_host_target): yield aot_host_target else: assert False, "Incorrect AoT host target: {aot_host_target}. Options are [c, llvm]." + + +def pytest_addoption(parser): + parser.addoption("--gtest_args", action="store", default="") + + +def pytest_generate_tests(metafunc): + option_value = metafunc.config.option.gtest_args + if "gtest_args" in metafunc.fixturenames and option_value is not None: + metafunc.parametrize("gtest_args", [option_value]) diff --git a/tests/python/contrib/test_hexagon/test_run_unit_tests.py b/tests/python/contrib/test_hexagon/test_run_unit_tests.py index c7457b270aa1..2e4dac3ac8dc 100644 --- a/tests/python/contrib/test_hexagon/test_run_unit_tests.py +++ b/tests/python/contrib/test_hexagon/test_run_unit_tests.py @@ -22,19 +22,16 @@ from .conftest import requires_hexagon_toolchain +# use pytest -sv to observe gtest output +# use --gtest_args to pass arguments to gtest +# for example to run all "foo" tests twice and observe gtest output run +# pytest -sv --gtests_args="--gtest_filter=*foo* --gtest_repeat=2" @requires_hexagon_toolchain @pytest.mark.skipif( os.environ.get("USE_HEXAGON_GTEST") == None, reason="This test requires the USE_HEXAGON_GTEST to be specified with a path to a Hexagon gtest version normally located at /path/to/hexagon/sdk/utils/googletest/gtest", ) -def test_run_unit_tests(hexagon_session): - # arguments to pass to gtest - # e.g. - # 1) to run all tests use: - # gtest_args = "" - # 2) to run all tests with "foo" in their name twice use: - # gtest_args = "--gtest_repeat=2 --gtest_filter=*foo*" - gtest_args = "" +def test_run_unit_tests(hexagon_session, gtest_args): func = hexagon_session._rpc.get_function("hexagon.run_unit_tests") gtest_error_code_and_output = func(gtest_args) gtest_error_code = int(gtest_error_code_and_output.splitlines()[0]) From 7b05b2173b5403160c6d559b802e45643e85df45 Mon Sep 17 00:00:00 2001 From: adstraw Date: Tue, 10 May 2022 13:14:46 -0700 Subject: [PATCH 07/10] change env variable to HEXAGON_GTEST --- tests/python/contrib/test_hexagon/test_run_unit_tests.py | 4 ++-- tests/scripts/task_build_hexagon_api.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/python/contrib/test_hexagon/test_run_unit_tests.py b/tests/python/contrib/test_hexagon/test_run_unit_tests.py index 2e4dac3ac8dc..78cc3b0a480a 100644 --- a/tests/python/contrib/test_hexagon/test_run_unit_tests.py +++ b/tests/python/contrib/test_hexagon/test_run_unit_tests.py @@ -28,8 +28,8 @@ # pytest -sv --gtests_args="--gtest_filter=*foo* --gtest_repeat=2" @requires_hexagon_toolchain @pytest.mark.skipif( - os.environ.get("USE_HEXAGON_GTEST") == None, - reason="This test requires the USE_HEXAGON_GTEST to be specified with a path to a Hexagon gtest version normally located at /path/to/hexagon/sdk/utils/googletest/gtest", + os.environ.get("HEXAGON_GTEST") == None, + reason="This test requires the HEXAGON_GTEST to be specified with a path to a Hexagon gtest version normally located at /path/to/hexagon/sdk/utils/googletest/gtest", ) def test_run_unit_tests(hexagon_session, gtest_args): func = hexagon_session._rpc.get_function("hexagon.run_unit_tests") diff --git a/tests/scripts/task_build_hexagon_api.sh b/tests/scripts/task_build_hexagon_api.sh index 403c44661419..ee3655653362 100755 --- a/tests/scripts/task_build_hexagon_api.sh +++ b/tests/scripts/task_build_hexagon_api.sh @@ -45,6 +45,6 @@ cmake -DANDROID_ABI=arm64-v8a \ -DUSE_HEXAGON_TOOLCHAIN="${HEXAGON_TOOLCHAIN}" \ -DUSE_OUTPUT_BINARY_DIR="${output_binary_directory}" .. # TODO(hexagon-team): enable this once https://github.com/apache/tvm/issues/11237 is fixed. - # -DUSE_HEXAGON_GTEST="${USE_HEXAGON_GTEST}" .. + # -DUSE_HEXAGON_GTEST="${HEXAGON_GTEST}" .. make -j$(nproc) From 453e188c6e16fd6558a127f78f3541f40e88c116 Mon Sep 17 00:00:00 2001 From: adstraw Date: Tue, 10 May 2022 15:42:54 -0700 Subject: [PATCH 08/10] trigger ci From 38a6ea26a1e81a96ec22d74ce8c1ead12400eabb Mon Sep 17 00:00:00 2001 From: adstraw Date: Wed, 11 May 2022 09:21:06 -0700 Subject: [PATCH 09/10] set HEXAGON_GTEST in the environment to enable Hexagon unit tests --- docker/Dockerfile.ci_hexagon | 1 + tests/scripts/task_build_hexagon_api.sh | 8 +++++--- tests/scripts/task_python_hexagon.sh | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile.ci_hexagon b/docker/Dockerfile.ci_hexagon index 3dc9752c9b1a..6ff922468ad0 100644 --- a/docker/Dockerfile.ci_hexagon +++ b/docker/Dockerfile.ci_hexagon @@ -62,6 +62,7 @@ RUN bash /install/ubuntu_install_hexagon.sh ENV CLANG_LLVM_HOME /opt/clang-llvm ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/clang-llvm/lib ENV HEXAGON_TOOLCHAIN "${HEXAGON_SDK_PATH}/tools/HEXAGON_Tools/8.5.08/Tools" +ENV HEXAGON_GTEST "${HEXAGON_SDK_PATH}/utils/googletest/gtest" # sccache COPY install/ubuntu_install_sccache.sh /install/ubuntu_install_sccache.sh diff --git a/tests/scripts/task_build_hexagon_api.sh b/tests/scripts/task_build_hexagon_api.sh index ee3655653362..c5d05eaad80c 100755 --- a/tests/scripts/task_build_hexagon_api.sh +++ b/tests/scripts/task_build_hexagon_api.sh @@ -37,14 +37,16 @@ cd build output_binary_directory=$(realpath ${PWD}/../../../build/hexagon_api_output) rm -rf ${output_binary_directory} +# should be removed after Hexagon Docker update +export HEXAGON_GTEST="${HEXAGON_SDK_PATH}/utils/googletest/gtest" + cmake -DANDROID_ABI=arm64-v8a \ -DANDROID_PLATFORM=android-28 \ -DUSE_ANDROID_TOOLCHAIN="${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake" \ -DUSE_HEXAGON_ARCH=v68 \ -DUSE_HEXAGON_SDK="${HEXAGON_SDK_PATH}" \ -DUSE_HEXAGON_TOOLCHAIN="${HEXAGON_TOOLCHAIN}" \ - -DUSE_OUTPUT_BINARY_DIR="${output_binary_directory}" .. - # TODO(hexagon-team): enable this once https://github.com/apache/tvm/issues/11237 is fixed. - # -DUSE_HEXAGON_GTEST="${HEXAGON_GTEST}" .. + -DUSE_OUTPUT_BINARY_DIR="${output_binary_directory}" \ + -DUSE_HEXAGON_GTEST="${HEXAGON_GTEST}" .. make -j$(nproc) diff --git a/tests/scripts/task_python_hexagon.sh b/tests/scripts/task_python_hexagon.sh index 274b348f0935..b639ac02a695 100755 --- a/tests/scripts/task_python_hexagon.sh +++ b/tests/scripts/task_python_hexagon.sh @@ -43,6 +43,9 @@ if [[ "${device_serial}" == "simulator" ]]; then export HEXAGON_SDK_ROOT=${HEXAGON_SDK_PATH} fi +# should be removed after Hexagon Docker update +export HEXAGON_GTEST="${HEXAGON_SDK_PATH}/utils/googletest/gtest" + export ANDROID_SERIAL_NUMBER=${device_serial} run_pytest ctypes python-contrib-hexagon tests/python/contrib/test_hexagon From 0c0ba2a348dd731688beece2c14268dd23b98f4f Mon Sep 17 00:00:00 2001 From: adstraw Date: Wed, 11 May 2022 11:44:33 -0700 Subject: [PATCH 10/10] add back try / except around get_function --- .../contrib/test_hexagon/test_run_unit_tests.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/python/contrib/test_hexagon/test_run_unit_tests.py b/tests/python/contrib/test_hexagon/test_run_unit_tests.py index 78cc3b0a480a..3a383d30e5f4 100644 --- a/tests/python/contrib/test_hexagon/test_run_unit_tests.py +++ b/tests/python/contrib/test_hexagon/test_run_unit_tests.py @@ -29,10 +29,17 @@ @requires_hexagon_toolchain @pytest.mark.skipif( os.environ.get("HEXAGON_GTEST") == None, - reason="This test requires the HEXAGON_GTEST to be specified with a path to a Hexagon gtest version normally located at /path/to/hexagon/sdk/utils/googletest/gtest", + reason="Test requires environment variable HEXAGON_GTEST set with a path to a Hexagon gtest version normally located at /path/to/hexagon/sdk/utils/googletest/gtest", ) def test_run_unit_tests(hexagon_session, gtest_args): - func = hexagon_session._rpc.get_function("hexagon.run_unit_tests") + try: + func = hexagon_session._rpc.get_function("hexagon.run_unit_tests") + except: + print( + "Test requires TVM Runtime to be built with a Hexagon gtest version using Hexagon API cmake flag -DUSE_HEXAGON_GTEST=${HEXAGON_GTEST}" + ) + raise + 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]