Skip to content

Commit b5d13a7

Browse files
authored
Replace nl-unit-test with pigweed for messaging (#33500)
* Test changing an order of tests execution * Increase size of stack * update import * Messaging to pigweed * Fix variable shadowing error * Remove old error handler * Refactor MockProtocolInitiator constructor parameters for better readability * IoT SDK update tests list * Revert change * Include reorder * Add todo * Update pw_unit_test BUILD.gn file with Apache License header
1 parent 350e537 commit b5d13a7

13 files changed

+1059
-1389
lines changed

.gn

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ script_executable = "python3"
2525

2626
default_args = {
2727
pw_unit_test_AUTOMATIC_RUNNER = "$dir_pigweed/targets/host/run_test"
28+
pw_unit_test_CONFIG = "//config/pw_unit_test:define_overrides"
2829

2930
pw_build_PIP_CONSTRAINTS = [ "//scripts/setup/constraints.txt" ]
3031
pw_build_PIP_REQUIREMENTS = [ "//scripts/setup/requirements.build.txt" ]

config/pw_unit_test/BUILD.gn

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/chip.gni")
17+
import("//build_overrides/pigweed.gni")
18+
19+
import("${chip_root}/build/chip/tests.gni")
20+
21+
import("$dir_pw_build/target_types.gni")
22+
pw_source_set("define_overrides") {
23+
public_configs = [ ":define_options" ]
24+
}
25+
26+
config("define_options") {
27+
if (chip_fake_platform && chip_link_tests) {
28+
defines = [ "PW_UNIT_TEST_CONFIG_MEMORY_POOL_SIZE=65536" ]
29+
} else {
30+
defines = [ "PW_UNIT_TEST_CONFIG_MEMORY_POOL_SIZE=16384" ]
31+
}
32+
}

src/messaging/tests/BUILD.gn

+1-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import("//build_overrides/build.gni")
1616
import("//build_overrides/chip.gni")
17-
import("//build_overrides/nlunit_test.gni")
1817

1918
import("${chip_root}/build/chip/chip_test_suite.gni")
2019
import("${chip_root}/src/app/icd/icd.gni")
@@ -38,15 +37,9 @@ static_library("helpers") {
3837
"${chip_root}/src/transport",
3938
"${chip_root}/src/transport/tests:helpers",
4039
]
41-
42-
# MessagingContext exposes nl-test compatible setup/teardown functions, specifically
43-
# they return nltest specific SUCCESS/FAILURE constants hence this dependency.
44-
#
45-
# Once all tests are moved to pw_unittest/gtest, this dependency should be removed
46-
public_deps = [ "${nlunit_test_root}:nlunit-test" ]
4740
}
4841

49-
chip_test_suite_using_nltest("tests") {
42+
chip_test_suite("tests") {
5043
output_name = "libMessagingLayerTests"
5144

5245
test_sources = [
@@ -73,12 +66,10 @@ chip_test_suite_using_nltest("tests") {
7366
"${chip_root}/src/lib/core",
7467
"${chip_root}/src/lib/support",
7568
"${chip_root}/src/lib/support:test_utils",
76-
"${chip_root}/src/lib/support:testing_nlunit",
7769
"${chip_root}/src/messaging",
7870
"${chip_root}/src/protocols",
7971
"${chip_root}/src/transport",
8072
"${chip_root}/src/transport/raw/tests:helpers",
81-
"${nlunit_test_root}:nlunit-test",
8273
]
8374

8475
if (chip_enable_icd_server) {

src/messaging/tests/MessagingContext.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#include <transport/tests/LoopbackTransportManager.h>
3333
#include <transport/tests/UDPTransportManager.h>
3434

35-
#include <nlunit-test.h>
36-
3735
#include <vector>
3836

3937
namespace chip {
@@ -98,6 +96,8 @@ class MessagingContext : public PlatformMemoryUser
9896
mInitialized(false), mAliceAddress(Transport::PeerAddress::UDP(GetAddress(), CHIP_PORT + 1)),
9997
mBobAddress(Transport::PeerAddress::UDP(GetAddress(), CHIP_PORT))
10098
{}
99+
// TODO Replace VerifyOrDie with Pigweed assert after transition app/tests to Pigweed.
100+
// TODO Currently src/app/icd/server/tests is using MessagingConetext as dependency.
101101
~MessagingContext() { VerifyOrDie(mInitialized == false); }
102102

103103
// Whether Alice and Bob are initialized, must be called before Init

0 commit comments

Comments
 (0)