Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace nl-unit-test with pigweed for messaging #33500

Merged
merged 12 commits into from
May 22, 2024
1 change: 1 addition & 0 deletions .gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ script_executable = "python3"

default_args = {
pw_unit_test_AUTOMATIC_RUNNER = "$dir_pigweed/targets/host/run_test"
pw_unit_test_CONFIG = "//config/pw_unit_test:define_overrides"

pw_build_PIP_CONSTRAINTS = [ "//scripts/setup/constraints.txt" ]
pw_build_PIP_REQUIREMENTS = [ "//scripts/setup/requirements.build.txt" ]
Expand Down
32 changes: 32 additions & 0 deletions config/pw_unit_test/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed 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.

import("//build_overrides/build.gni")
jlatusek marked this conversation as resolved.
Show resolved Hide resolved
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

import("${chip_root}/build/chip/tests.gni")

import("$dir_pw_build/target_types.gni")
pw_source_set("define_overrides") {
public_configs = [ ":define_options" ]
}

config("define_options") {
if (chip_fake_platform && chip_link_tests) {
defines = [ "PW_UNIT_TEST_CONFIG_MEMORY_POOL_SIZE=65536" ]
} else {
defines = [ "PW_UNIT_TEST_CONFIG_MEMORY_POOL_SIZE=16384" ]
}
}
11 changes: 1 addition & 10 deletions src/messaging/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/nlunit_test.gni")

import("${chip_root}/build/chip/chip_test_suite.gni")
import("${chip_root}/src/app/icd/icd.gni")
Expand All @@ -38,15 +37,9 @@ static_library("helpers") {
"${chip_root}/src/transport",
"${chip_root}/src/transport/tests:helpers",
]

# MessagingContext exposes nl-test compatible setup/teardown functions, specifically
# they return nltest specific SUCCESS/FAILURE constants hence this dependency.
#
# Once all tests are moved to pw_unittest/gtest, this dependency should be removed
public_deps = [ "${nlunit_test_root}:nlunit-test" ]
}

chip_test_suite_using_nltest("tests") {
chip_test_suite("tests") {
output_name = "libMessagingLayerTests"

test_sources = [
Expand All @@ -73,12 +66,10 @@ chip_test_suite_using_nltest("tests") {
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
"${chip_root}/src/lib/support:test_utils",
"${chip_root}/src/lib/support:testing_nlunit",
"${chip_root}/src/messaging",
"${chip_root}/src/protocols",
"${chip_root}/src/transport",
"${chip_root}/src/transport/raw/tests:helpers",
"${nlunit_test_root}:nlunit-test",
]

if (chip_enable_icd_server) {
Expand Down
4 changes: 2 additions & 2 deletions src/messaging/tests/MessagingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#include <transport/tests/LoopbackTransportManager.h>
#include <transport/tests/UDPTransportManager.h>

#include <nlunit-test.h>

#include <vector>

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

// Whether Alice and Bob are initialized, must be called before Init
Expand Down
Loading
Loading