Skip to content

Commit

Permalink
Replaced nlunit-test with pw_unit_test in src/access/tests/ (#29682)
Browse files Browse the repository at this point in the history
* Rewritten src/access/tests/ to use pw_unit_test

* Fix building issue

* Revert unnecessary changes

* Replace EXPECT_TRUE to EXPECT_EQ

---------

Co-authored-by: Jakub Latusek <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed May 14, 2024
1 parent 1236fd1 commit d0e3996
Show file tree
Hide file tree
Showing 5 changed files with 522 additions and 576 deletions.
18 changes: 15 additions & 3 deletions build/chip/chip_test_suite.gni
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ assert(chip_build_tests)
#
# public_deps = [
# "${chip_root}/src/lib/foo", # add dependencies here
# "${nlunit_test_root}:nlunit-test",
# ]
# }
#
Expand All @@ -57,7 +56,6 @@ assert(chip_build_tests)
#
# public_deps = [
# "${chip_root}/src/lib/foo", # add dependencies here
# "${nlunit_test_root}:nlunit-test",
# ]
#
# tests = [
Expand Down Expand Up @@ -94,6 +92,8 @@ template("chip_test_suite") {
public_deps = []
}

deps = [ dir_pw_unit_test ]

if (current_os != "zephyr" && current_os != "mbed") {
# Depend on stdio logging, and have it take precedence over the default platform backend
public_deps += [ "${chip_root}/src/platform/logging:force_stdio" ]
Expand All @@ -106,6 +106,11 @@ template("chip_test_suite") {
foreach(_test, invoker.test_sources) {
_test_name = string_replace(_test, ".cpp", "")

_test_output_dir = "${root_out_dir}/tests"
if (defined(invoker.output_dir)) {
_test_output_dir = invoker.output_dir
}

pw_test(_test_name) {
forward_variables_from(invoker,
[
Expand All @@ -116,13 +121,19 @@ template("chip_test_suite") {
])
public_deps += [ ":${_suite_name}.lib" ]
sources = [ _test ]
output_dir = _test_output_dir
}
tests += [ _test_name ]
}
}

if (defined(invoker.tests)) {
foreach(_test, invoker.tests) {
_test_output_dir = "${root_out_dir}/tests"
if (defined(invoker.output_dir)) {
_test_output_dir = invoker.output_dir
}

pw_test(_test) {
forward_variables_from(invoker,
[
Expand All @@ -137,6 +148,7 @@ template("chip_test_suite") {
"${_test}.cpp",
"${_test}Driver.cpp",
]
output_dir = _test_output_dir
}
tests += [ _test ]
}
Expand Down Expand Up @@ -164,7 +176,7 @@ template("chip_test_suite") {
}
}

# TODO: remove this once transition away from nlunit-test is completed
# TODO [PW_MIGRATION]: remove this once transition away from nlunit-test is completed
template("chip_test_suite_using_nltest") {
_suite_name = target_name

Expand Down
9 changes: 3 additions & 6 deletions src/access/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@

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

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

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

test_sources = [ "TestAccessControl.cpp" ]

cflags = [ "-Wconversion" ]

public_deps = [
"${chip_root}/src/access",
"${chip_root}/src/lib/support:test_utils",
"${chip_root}/src/lib/support:testing_nlunit",
"${nlunit_test_root}:nlunit-test",
"${dir_pw_unit_test}",
]
}
Loading

0 comments on commit d0e3996

Please sign in to comment.