summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Barry <liam.barry@arm.com>2023-11-03 15:49:34 +0000
committerLiam Barry <liam.barry@arm.com>2023-11-20 15:24:42 +0000
commitcca34a93798c52bffd41b07ead3595f398005e14 (patch)
tree052cd8ceb1faa7d1b6e35bdf6b735c5f3a81a040
parent4865c4fc171d6b0eb6e2b470f123ff81e45a34f8 (diff)
downloadml-embedded-evaluation-kit-cca34a93798c52bffd41b07ead3595f398005e14.tar.gz
MLECO-4490: Upgrade MLEK Catch Unit tests
*Removed default behaviour of unit-test executables to redirect output to file. *Accompanying change made to CI script to generate xml files there instead. *Switched to newer minor version of Catch. *Note: Support for simultaneous output to console and file is available in new major version (Catch 3). Other unit test cleanup: * Redundant warnings about common tests output removed * Static cast added to silence compiler warning * Removed additional printing in RNNoiseModelTests Signed-off-by: Liam Barry <liam.barry@arm.com> Change-Id: If9d7f366ec205a7cd49a45198a15867ef7b75afd
-rw-r--r--scripts/cmake/platforms/native/build_configuration.cmake11
-rw-r--r--tests/common/ClassifierTests.cc8
-rw-r--r--tests/common/ProfilerTests.cc7
-rw-r--r--tests/common/SlidingWindowTests.cc6
-rw-r--r--tests/use_case/inference_runner/InferenceTestInferenceRunner.cc6
-rw-r--r--tests/use_case/noise_reduction/RNNoiseModelTests.cc26
6 files changed, 12 insertions, 52 deletions
diff --git a/scripts/cmake/platforms/native/build_configuration.cmake b/scripts/cmake/platforms/native/build_configuration.cmake
index d0b4dfb..0519ec1 100644
--- a/scripts/cmake/platforms/native/build_configuration.cmake
+++ b/scripts/cmake/platforms/native/build_configuration.cmake
@@ -1,5 +1,5 @@
#----------------------------------------------------------------------------
-# SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
+# SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,16 +21,15 @@ function(set_platform_global_defaults)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_DIR}/native-gcc.cmake
CACHE FILEPATH "Toolchain file")
endif()
-
set(PLATFORM_DRIVERS_DIR "${HAL_PLATFORM_DIR}/native" PARENT_SCOPE)
set(TEST_TPIP ${DOWNLOAD_DEP_DIR}/test)
file(MAKE_DIRECTORY ${TEST_TPIP})
set(TEST_TPIP_INCLUDE ${TEST_TPIP}/include)
file(MAKE_DIRECTORY ${TEST_TPIP_INCLUDE})
- set(CATCH_HEADER_URL "https://github.com/catchorg/Catch2/releases/download/v2.11.1/catch.hpp")
- set(CATCH_HEADER_MD5 dc6bb8ce282ad134476b37275804c44c)
+ set(CATCH_HEADER_URL "https://github.com/catchorg/Catch2/releases/download/v2.13.5/catch.hpp")
+ set(CATCH_HEADER_MD5 b43c586fe617aefdee3e480e9fa8f370)
include(FetchContent)
FetchContent_Declare(catch2-header-download
@@ -116,6 +115,6 @@ function(platform_custom_post_build)
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE
"ACTIVATION_BUF_SZ=${${use_case}_ACTIVATION_BUF_SZ}"
TESTS)
- add_test(NAME "${use_case}-tests" COMMAND ${TEST_TARGET_NAME} -r junit -o ${TEST_TARGET_NAME}.xml)
+ add_test(NAME "${use_case}-tests" COMMAND ${TEST_TARGET_NAME})
endif ()
-endfunction() \ No newline at end of file
+endfunction()
diff --git a/tests/common/ClassifierTests.cc b/tests/common/ClassifierTests.cc
index 7df4242..b15ffd4 100644
--- a/tests/common/ClassifierTests.cc
+++ b/tests/common/ClassifierTests.cc
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: Copyright 2021, 2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
+ * SPDX-FileCopyrightText: Copyright 2021,2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +18,6 @@
#include <catch.hpp>
-
template<typename T>
void test_classifier_result(std::vector<std::pair<uint32_t, T>>& selectedResults, T defaultTensorValue) {
int dimArray[] = {1, 1001};
@@ -47,15 +46,10 @@ TEST_CASE("Common classifier")
{
SECTION("Test invalid classifier")
{
- /* Note: Errors or warnings generated by this test will appear in output of any subsequent
- * failing tests causing misleading output. Give warning until solution is found */
- printf("Invalid classifier common test output:\n");
TfLiteTensor* outputTens = nullptr;
std::vector <arm::app::ClassificationResult> resultVec;
arm::app::Classifier classifier;
REQUIRE(!classifier.GetClassificationResults(outputTens, resultVec, {}, 5, true));
- printf("End of invalid classifier common test output. \nERROR messages above this line are "
- "expected and can be ignored.\n\n");
}
SECTION("Test classification results")
diff --git a/tests/common/ProfilerTests.cc b/tests/common/ProfilerTests.cc
index 0b487e5..0af8d65 100644
--- a/tests/common/ProfilerTests.cc
+++ b/tests/common/ProfilerTests.cc
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: Copyright 2021, 2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
+ * SPDX-FileCopyrightText: Copyright 2021,2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,14 +44,11 @@ TEST_CASE("Common: Test Profiler")
/* Improper usage should cause failure.
* Note: Errors or warnings generated by this test will appear in output of any subsequent
- * failing tests causing misleading output. Give warning until solution is found */
- printf("Invalid profiler usage common test output:\n");
+ * failing tests causing misleading output unless logging is disabled.*/
REQUIRE(false == profilerValid.StopProfiling()); /* We need to start it first */
REQUIRE(true == profilerValid.StartProfiling()); /* Should be able to start it fine */
REQUIRE(false == profilerValid.StartProfiling()); /* Can't restart it without resetting */
- printf("End of Invalid profiler usage common test output. \nERROR messages above this line "
- "are expected and can be ignored.\n\n");
profilerValid.Reset();
REQUIRE(true == profilerValid.StartProfiling()); /* Can start it again now.. */
REQUIRE(true == profilerValid.StopProfiling());
diff --git a/tests/common/SlidingWindowTests.cc b/tests/common/SlidingWindowTests.cc
index 33fe65e..b856e16 100644
--- a/tests/common/SlidingWindowTests.cc
+++ b/tests/common/SlidingWindowTests.cc
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <open-source-office@arm.com>
+ * SPDX-FileCopyrightText: Copyright 2021,2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -175,12 +175,12 @@ TEST_CASE("Common: Slide Index")
REQUIRE(slider.Index() == 0);
for (int i = 0; i < 5; i++) {
slider.Next();
- REQUIRE(slider.Index() == i);
+ REQUIRE(static_cast<int>(slider.Index()) == i);
}
}
-TEST_CASE("Common: Total strides")
+TEST_CASE("Common: Total strides")
{
std::vector<int> test{1, 2, 3, 4, 5};
diff --git a/tests/use_case/inference_runner/InferenceTestInferenceRunner.cc b/tests/use_case/inference_runner/InferenceTestInferenceRunner.cc
index 7988ae1..974d2c8 100644
--- a/tests/use_case/inference_runner/InferenceTestInferenceRunner.cc
+++ b/tests/use_case/inference_runner/InferenceTestInferenceRunner.cc
@@ -33,9 +33,6 @@ namespace app {
TEST_CASE("Testing Init failure due to insufficient tensor arena inf runner", "[inf runner]")
{
- /* Note: Errors or warnings generated by this test will appear in output of any subsequent
- * failing tests causing misleading output. Give warning until solution is found */
- printf("Insufficient tensor arena test output:\n");
arm::app::TestModel model{};
REQUIRE_FALSE(model.IsInited());
size_t insufficientTensorArenaSz = 1000;
@@ -43,8 +40,5 @@ TEST_CASE("Testing Init failure due to insufficient tensor arena inf runner", "[
insufficientTensorArenaSz,
arm::app::inference_runner::GetModelPointer(),
arm::app::inference_runner::GetModelLen()));
-
- printf("End of insufficient tensor arena test output. \nERROR messages above this line are "
- "expected and can be ignored.\n\n");
REQUIRE_FALSE(model.IsInited());
}
diff --git a/tests/use_case/noise_reduction/RNNoiseModelTests.cc b/tests/use_case/noise_reduction/RNNoiseModelTests.cc
index 7262275..d08c5f3 100644
--- a/tests/use_case/noise_reduction/RNNoiseModelTests.cc
+++ b/tests/use_case/noise_reduction/RNNoiseModelTests.cc
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <open-source-office@arm.com>
+ * SPDX-FileCopyrightText: Copyright 2021,2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -104,26 +104,6 @@ public:
};
-template <class T>
-void printArray(size_t dataSz, T data){
- char strhex[8];
- std::string strdump;
-
- for (size_t i = 0; i < dataSz; ++i) {
- if (0 == i % 8) {
- printf("%s\n\t", strdump.c_str());
- strdump.clear();
- }
- snprintf(strhex, sizeof(strhex) - 1,
- "0x%02x, ", data[i]);
- strdump += std::string(strhex);
- }
-
- if (!strdump.empty()) {
- printf("%s\n", strdump.c_str());
- }
-}
-
/* This is true for gcc x86 platform, not guaranteed for other compilers and platforms. */
TEST_CASE("Test initial GRU out state is 0", "[RNNoise]")
{
@@ -134,14 +114,10 @@ TEST_CASE("Test initial GRU out state is 0", "[RNNoise]")
arm::app::rnn::GetModelLen());
auto map = model.GetStateMap();
-
for(auto& mapping: map) {
TfLiteTensor* gruOut = model.GetOutputTensor(mapping.first);
auto* outGruState = tflite::GetTensorData<uint8_t>(gruOut);
- printf("gru out state:");
- printArray(gruOut->bytes, outGruState);
-
for (size_t tIndex = 0; tIndex < gruOut->bytes; tIndex++) {
REQUIRE(outGruState[tIndex] == 0);
}