Skip to content

Commit a09d089

Browse files
committed
CMake: unittests: Show all tests in CTest report
Previously a test executable was recognised as a single test by CTest. However, test executables usually contain multiple test cases, the results of the test cases should be individually reported. With our previous setup we could miss test case failures that didn't cause the executable to return an error code. This commit uses gtest_discover_test to discover all test cases in a test executable. This enables CTest to match test passes and failures from the googletest binary output.
1 parent 1e48a61 commit a09d089

File tree

46 files changed

+138
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+138
-138
lines changed

connectivity/cellular/tests/UNITTESTS/framework/common/list/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
include(GoogleTest)
5+
46
set(TEST_NAME cellular-framework-common-list-unittest)
57

68
add_executable(${TEST_NAME})
@@ -16,6 +18,4 @@ target_link_libraries(${TEST_NAME}
1618
gmock_main
1719
)
1820

19-
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
20-
21-
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular")
21+
gtest_discover_tests(${TEST_NAME} PROPERTIES LABELS "cellular")

connectivity/cellular/tests/UNITTESTS/framework/common/util/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
include(GoogleTest)
5+
46
set(TEST_NAME cellular-framework-common-util-unittest)
57

68
add_executable(${TEST_NAME})
@@ -19,6 +21,4 @@ target_link_libraries(${TEST_NAME}
1921
gmock_main
2022
)
2123

22-
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
23-
24-
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular")
24+
gtest_discover_tests(${TEST_NAME} PROPERTIES LABELS "cellular")

connectivity/cellular/tests/UNITTESTS/framework/device/athandler/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
include(GoogleTest)
5+
46
set(TEST_NAME cellular-framework-device-athandler-unittest)
57

68
add_executable(${TEST_NAME})
@@ -39,6 +41,4 @@ target_link_libraries(${TEST_NAME}
3941
gmock_main
4042
)
4143

42-
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
43-
44-
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular")
44+
gtest_discover_tests(${TEST_NAME} PROPERTIES LABELS "cellular")

connectivity/cellular/tests/UNITTESTS/framework/device/cellularcontext/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
include(GoogleTest)
5+
46
set(TEST_NAME cellular-framework-device-cellular-context-unittest)
57

68
add_executable(${TEST_NAME})
@@ -45,6 +47,4 @@ target_link_libraries(${TEST_NAME}
4547
gmock_main
4648
)
4749

48-
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
49-
50-
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular")
50+
gtest_discover_tests(${TEST_NAME} PROPERTIES LABELS "cellular")

connectivity/cellular/tests/UNITTESTS/framework/device/cellulardevice/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
include(GoogleTest)
5+
46
set(TEST_NAME cellular-framework-device-cellular-device-unittest)
57

68
add_executable(${TEST_NAME})
@@ -41,6 +43,4 @@ target_link_libraries(${TEST_NAME}
4143
gmock_main
4244
)
4345

44-
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
45-
46-
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular")
46+
gtest_discover_tests(${TEST_NAME} PROPERTIES LABELS "cellular")

connectivity/cellular/tests/UNITTESTS/framework/device/cellularstatemachine/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
include(GoogleTest)
5+
46
set(TEST_NAME cellular-framework-device-cellular-state-machine-unittest)
57

68
add_executable(${TEST_NAME})
@@ -43,6 +45,4 @@ target_link_libraries(${TEST_NAME}
4345
gmock_main
4446
)
4547

46-
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
47-
48-
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "cellular")
48+
gtest_discover_tests(${TEST_NAME} PROPERTIES LABELS "cellular")

connectivity/lorawan/tests/UNITTESTS/features/lorawan/loramac/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
include(GoogleTest)
5+
46
set(TEST_NAME lorawan-loramac-unittest)
57

68
add_executable(${TEST_NAME})
@@ -45,6 +47,4 @@ target_link_libraries(${TEST_NAME}
4547
gmock_main
4648
)
4749

48-
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
49-
50-
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "lorawan")
50+
gtest_discover_tests(${TEST_NAME} PROPERTIES LABELS "lorawan")

connectivity/lorawan/tests/UNITTESTS/features/lorawan/loramacchannelplan/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
include(GoogleTest)
5+
46
set(TEST_NAME lorawan-loramac-channel-plan-unittest)
57

68
add_executable(${TEST_NAME})
@@ -29,6 +31,4 @@ target_link_libraries(${TEST_NAME}
2931
gmock_main
3032
)
3133

32-
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
33-
34-
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "lorawan")
34+
gtest_discover_tests(${TEST_NAME} PROPERTIES LABELS "lorawan")

connectivity/lorawan/tests/UNITTESTS/features/lorawan/loramaccommand/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
include(GoogleTest)
5+
46
set(TEST_NAME lorawan-loramac-command-unittest)
57

68
add_executable(${TEST_NAME})
@@ -30,6 +32,4 @@ target_link_libraries(${TEST_NAME}
3032
gmock_main
3133
)
3234

33-
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
34-
35-
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "lorawan")
35+
gtest_discover_tests(${TEST_NAME} PROPERTIES LABELS "lorawan")

connectivity/lorawan/tests/UNITTESTS/features/lorawan/loramaccrypto/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) 2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
include(GoogleTest)
5+
46
set(TEST_NAME lorawan-loramac-crypto-unittest)
57

68
add_executable(${TEST_NAME})
@@ -28,6 +30,4 @@ target_link_libraries(${TEST_NAME}
2830
gmock_main
2931
)
3032

31-
add_test(NAME "${TEST_NAME}" COMMAND ${TEST_NAME})
32-
33-
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "lorawan")
33+
gtest_discover_tests(${TEST_NAME} PROPERTIES LABELS "lorawan")

0 commit comments

Comments
 (0)