Skip to content

Commit

Permalink
Add testing_pw library (#31550)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jlatusek authored Jan 23, 2024
1 parent 9bde938 commit 9c93583
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 18 deletions.
13 changes: 10 additions & 3 deletions build/chip/chip_test_group.gni
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ template("chip_test_group") {
[
"build_monolithic_library",
"deps",
"tests",
])

deps = []
foreach(_test, invoker.deps) {
if (defined(invoker.deps)) {
deps = invoker.deps
}
foreach(_test, invoker.tests) {
deps += [ get_label_info(_test, "label_no_toolchain") + ".lib" ]
}

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

group("${_test_group_name}") {
deps = []
data_deps = invoker.deps
data_deps = invoker.tests

if (_build_monolithic_library) {
deps += [ ":${_lib_target_name}" ]
Expand All @@ -64,7 +68,10 @@ template("chip_test_group") {
group("${_test_group_name}_run") {
if (chip_link_tests) {
deps = []
foreach(_test, invoker.deps) {
if (defined(invoker.deps)) {
deps = invoker.deps
}
foreach(_test, invoker.tests) {
deps += [ get_label_info(_test, "label_no_toolchain") + "_run" ]
}
}
Expand Down
1 change: 1 addition & 0 deletions scripts/build/builders/tizen.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def __init__(self,

if app == TizenApp.TESTS:
self.extra_gn_options.append('chip_build_tests=true')
self.build_command = 'check'

if not enable_ble:
self.extra_gn_options.append('chip_config_network_layer_ble=false')
Expand Down
34 changes: 20 additions & 14 deletions src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ if (chip_build_tests) {
import("${chip_root}/build/chip/chip_test_group.gni")

chip_test_group("tests") {
deps = [
deps = []
tests = [
"${chip_root}/src/access/tests",
"${chip_root}/src/crypto/tests",
"${chip_root}/src/inet/tests",
Expand All @@ -72,7 +73,7 @@ if (chip_build_tests) {

# Skip DNSSD tests for Mbed platform due to flash memory size limitations
if (current_os != "mbed") {
deps += [
tests += [
"${chip_root}/src/lib/dnssd/minimal_mdns/core/tests",
"${chip_root}/src/lib/dnssd/minimal_mdns/responders/tests",
"${chip_root}/src/lib/dnssd/minimal_mdns/tests",
Expand All @@ -81,19 +82,19 @@ if (chip_build_tests) {
}

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

if (current_os != "zephyr" && current_os != "mbed" &&
chip_device_platform != "efr32") {
deps += [
tests += [
"${chip_root}/src/setup_payload/tests",
"${chip_root}/src/transport/raw/tests",
]
}

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

if (matter_enable_tracing_support &&
matter_trace_config == "multiplexed") {
deps += [ "${chip_root}/src/tracing/tests" ]
tests += [ "${chip_root}/src/tracing/tests" ]
}
}

if (chip_device_platform != "none") {
deps += [ "${chip_root}/src/lib/dnssd/minimal_mdns/tests" ]
tests += [ "${chip_root}/src/lib/dnssd/minimal_mdns/tests" ]
}

if (chip_device_platform != "esp32" && chip_device_platform != "efr32" &&
chip_device_platform != "ameba") {
deps += [ "${chip_root}/src/platform/tests" ]
tests += [ "${chip_root}/src/platform/tests" ]
}

if (chip_config_network_layer_ble) {
deps += [ "${chip_root}/src/ble/tests" ]
tests += [ "${chip_root}/src/ble/tests" ]
}

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

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

if (current_os != "zephyr" && current_os != "mbed" &&
chip_device_platform != "esp32" && chip_device_platform != "ameba") {
deps += [ "${chip_root}/src/lib/shell/tests" ]
tests += [ "${chip_root}/src/lib/shell/tests" ]
}

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

chip_test_group("fake_platform_tests") {
deps = [ "${chip_root}/src/lib/dnssd/platform/tests" ]
tests = [ "${chip_root}/src/lib/dnssd/platform/tests" ]
}

# Tests to run with each Crypto PAL
chip_test_group("crypto_tests") {
deps = [
tests = [
"${chip_root}/src/credentials/tests",
"${chip_root}/src/crypto/tests",
]
Expand Down
18 changes: 18 additions & 0 deletions src/lib/support/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import("//build_overrides/nlassert.gni")
import("//build_overrides/nlfaultinjection.gni")
import("//build_overrides/nlio.gni")
import("//build_overrides/nlunit_test.gni")
import("//build_overrides/pigweed.gni")

import("$dir_pw_build/target_types.gni")
import("${chip_root}/build/chip/chip_version.gni")
import("${chip_root}/build/chip/java/config.gni")
import("${chip_root}/build/chip/tests.gni")
Expand Down Expand Up @@ -309,6 +311,22 @@ static_library("test_utils") {
]
}

pw_static_library("pw_tests_wrapper") {
if (chip_device_platform == "esp32") {
complete_static_lib = true
}
output_name = "libPWTestsWrapper"
output_dir = "${root_out_dir}/lib"
public_deps = [
"$dir_pw_log:impl",
"$dir_pw_unit_test",
]
sources = [
"UnitTest.cpp",
"UnitTest.h",
]
}

static_library("testing_nlunit") {
output_name = "libSupportTesting"
output_dir = "${root_out_dir}/lib"
Expand Down
14 changes: 14 additions & 0 deletions src/lib/support/UnitTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "UnitTest.h"

#include "pw_unit_test/framework.h"

namespace chip {
namespace test {

int RunAllTests()
{
return RUN_ALL_TESTS();
}

} // namespace test
} // namespace chip
9 changes: 9 additions & 0 deletions src/lib/support/UnitTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

namespace chip {
namespace test {

int RunAllTests();

} // namespace test
} // namespace chip
2 changes: 1 addition & 1 deletion src/platform/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ if (chip_device_platform != "none" && chip_device_platform != "fake") {
} else {
import("${chip_root}/build/chip/chip_test_group.gni")
chip_test_group("tests") {
deps = []
tests = []
}
}

0 comments on commit 9c93583

Please sign in to comment.