Skip to content

Commit 9c93583

Browse files
authored
Add testing_pw library (project-chip#31550)
* Add unity test run method * Add if statement with list of supported platform in pigweed * Make Tizen build only targets related to unit tests * Update library name
1 parent 9bde938 commit 9c93583

File tree

7 files changed

+73
-18
lines changed

7 files changed

+73
-18
lines changed

build/chip/chip_test_group.gni

+10-3
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ template("chip_test_group") {
3939
[
4040
"build_monolithic_library",
4141
"deps",
42+
"tests",
4243
])
4344

4445
deps = []
45-
foreach(_test, invoker.deps) {
46+
if (defined(invoker.deps)) {
47+
deps = invoker.deps
48+
}
49+
foreach(_test, invoker.tests) {
4650
deps += [ get_label_info(_test, "label_no_toolchain") + ".lib" ]
4751
}
4852

@@ -53,7 +57,7 @@ template("chip_test_group") {
5357

5458
group("${_test_group_name}") {
5559
deps = []
56-
data_deps = invoker.deps
60+
data_deps = invoker.tests
5761

5862
if (_build_monolithic_library) {
5963
deps += [ ":${_lib_target_name}" ]
@@ -64,7 +68,10 @@ template("chip_test_group") {
6468
group("${_test_group_name}_run") {
6569
if (chip_link_tests) {
6670
deps = []
67-
foreach(_test, invoker.deps) {
71+
if (defined(invoker.deps)) {
72+
deps = invoker.deps
73+
}
74+
foreach(_test, invoker.tests) {
6875
deps += [ get_label_info(_test, "label_no_toolchain") + "_run" ]
6976
}
7077
}

scripts/build/builders/tizen.py

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def __init__(self,
116116

117117
if app == TizenApp.TESTS:
118118
self.extra_gn_options.append('chip_build_tests=true')
119+
self.build_command = 'check'
119120

120121
if not enable_ble:
121122
self.extra_gn_options.append('chip_config_network_layer_ble=false')

src/BUILD.gn

+20-14
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ if (chip_build_tests) {
5656
import("${chip_root}/build/chip/chip_test_group.gni")
5757

5858
chip_test_group("tests") {
59-
deps = [
59+
deps = []
60+
tests = [
6061
"${chip_root}/src/access/tests",
6162
"${chip_root}/src/crypto/tests",
6263
"${chip_root}/src/inet/tests",
@@ -72,7 +73,7 @@ if (chip_build_tests) {
7273

7374
# Skip DNSSD tests for Mbed platform due to flash memory size limitations
7475
if (current_os != "mbed") {
75-
deps += [
76+
tests += [
7677
"${chip_root}/src/lib/dnssd/minimal_mdns/core/tests",
7778
"${chip_root}/src/lib/dnssd/minimal_mdns/responders/tests",
7879
"${chip_root}/src/lib/dnssd/minimal_mdns/tests",
@@ -81,19 +82,19 @@ if (chip_build_tests) {
8182
}
8283

8384
if (current_os != "zephyr" && current_os != "mbed") {
84-
deps += [ "${chip_root}/src/lib/dnssd/minimal_mdns/records/tests" ]
85+
tests += [ "${chip_root}/src/lib/dnssd/minimal_mdns/records/tests" ]
8586
}
8687

8788
if (current_os != "zephyr" && current_os != "mbed" &&
8889
chip_device_platform != "efr32") {
89-
deps += [
90+
tests += [
9091
"${chip_root}/src/setup_payload/tests",
9192
"${chip_root}/src/transport/raw/tests",
9293
]
9394
}
9495

9596
if (chip_device_platform != "efr32") {
96-
deps += [
97+
tests += [
9798
# TODO(#10447): App test has HF on EFR32.
9899
"${chip_root}/src/app/tests",
99100
"${chip_root}/src/credentials/tests",
@@ -106,56 +107,61 @@ if (chip_build_tests) {
106107

107108
if (matter_enable_tracing_support &&
108109
matter_trace_config == "multiplexed") {
109-
deps += [ "${chip_root}/src/tracing/tests" ]
110+
tests += [ "${chip_root}/src/tracing/tests" ]
110111
}
111112
}
112113

113114
if (chip_device_platform != "none") {
114-
deps += [ "${chip_root}/src/lib/dnssd/minimal_mdns/tests" ]
115+
tests += [ "${chip_root}/src/lib/dnssd/minimal_mdns/tests" ]
115116
}
116117

117118
if (chip_device_platform != "esp32" && chip_device_platform != "efr32" &&
118119
chip_device_platform != "ameba") {
119-
deps += [ "${chip_root}/src/platform/tests" ]
120+
tests += [ "${chip_root}/src/platform/tests" ]
120121
}
121122

122123
if (chip_config_network_layer_ble) {
123-
deps += [ "${chip_root}/src/ble/tests" ]
124+
tests += [ "${chip_root}/src/ble/tests" ]
124125
}
125126

126127
# On nrfconnect, the controller tests run into
127128
# https://github.com/project-chip/connectedhomeip/issues/9630
128129
if (chip_device_platform != "nrfconnect" &&
129130
chip_device_platform != "efr32") {
130131
# TODO(#10447): Controller test has HF on EFR32.
131-
deps += [ "${chip_root}/src/controller/tests/data_model" ]
132+
tests += [ "${chip_root}/src/controller/tests/data_model" ]
132133

133134
# Skip controller test for Open IoT SDK
134135
# https://github.com/project-chip/connectedhomeip/issues/23747
135136
if (chip_device_platform != "openiotsdk") {
136-
deps += [ "${chip_root}/src/controller/tests" ]
137+
tests += [ "${chip_root}/src/controller/tests" ]
137138
}
138139
}
139140

140141
if (current_os != "zephyr" && current_os != "mbed" &&
141142
chip_device_platform != "esp32" && chip_device_platform != "ameba") {
142-
deps += [ "${chip_root}/src/lib/shell/tests" ]
143+
tests += [ "${chip_root}/src/lib/shell/tests" ]
143144
}
144145

145146
if (chip_monolithic_tests) {
147+
# TODO [PW_MIGRATION] Remove this if after migartion to PW_TEST is completed for all platforms
148+
# TODO [PW_MIGRATION] There will be a list of already migrated platforms
149+
if (false) {
150+
deps += [ "${chip_root}/src/lib/support:pw_tests_wrapper" ]
151+
}
146152
build_monolithic_library = true
147153
output_name = "libCHIP_tests"
148154
output_dir = "${root_out_dir}/lib"
149155
}
150156
}
151157

152158
chip_test_group("fake_platform_tests") {
153-
deps = [ "${chip_root}/src/lib/dnssd/platform/tests" ]
159+
tests = [ "${chip_root}/src/lib/dnssd/platform/tests" ]
154160
}
155161

156162
# Tests to run with each Crypto PAL
157163
chip_test_group("crypto_tests") {
158-
deps = [
164+
tests = [
159165
"${chip_root}/src/credentials/tests",
160166
"${chip_root}/src/crypto/tests",
161167
]

src/lib/support/BUILD.gn

+18
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import("//build_overrides/nlassert.gni")
1818
import("//build_overrides/nlfaultinjection.gni")
1919
import("//build_overrides/nlio.gni")
2020
import("//build_overrides/nlunit_test.gni")
21+
import("//build_overrides/pigweed.gni")
2122

23+
import("$dir_pw_build/target_types.gni")
2224
import("${chip_root}/build/chip/chip_version.gni")
2325
import("${chip_root}/build/chip/java/config.gni")
2426
import("${chip_root}/build/chip/tests.gni")
@@ -309,6 +311,22 @@ static_library("test_utils") {
309311
]
310312
}
311313

314+
pw_static_library("pw_tests_wrapper") {
315+
if (chip_device_platform == "esp32") {
316+
complete_static_lib = true
317+
}
318+
output_name = "libPWTestsWrapper"
319+
output_dir = "${root_out_dir}/lib"
320+
public_deps = [
321+
"$dir_pw_log:impl",
322+
"$dir_pw_unit_test",
323+
]
324+
sources = [
325+
"UnitTest.cpp",
326+
"UnitTest.h",
327+
]
328+
}
329+
312330
static_library("testing_nlunit") {
313331
output_name = "libSupportTesting"
314332
output_dir = "${root_out_dir}/lib"

src/lib/support/UnitTest.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "UnitTest.h"
2+
3+
#include "pw_unit_test/framework.h"
4+
5+
namespace chip {
6+
namespace test {
7+
8+
int RunAllTests()
9+
{
10+
return RUN_ALL_TESTS();
11+
}
12+
13+
} // namespace test
14+
} // namespace chip

src/lib/support/UnitTest.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
namespace chip {
4+
namespace test {
5+
6+
int RunAllTests();
7+
8+
} // namespace test
9+
} // namespace chip

src/platform/tests/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ if (chip_device_platform != "none" && chip_device_platform != "fake") {
9898
} else {
9999
import("${chip_root}/build/chip/chip_test_group.gni")
100100
chip_test_group("tests") {
101-
deps = []
101+
tests = []
102102
}
103103
}

0 commit comments

Comments
 (0)