Skip to content

Commit

Permalink
Descope less relevant unit tests from unified build variants
Browse files Browse the repository at this point in the history
Switch to more targeted testing of just crypto oriented tests for the
MbedTLS build and just tests that need the fake platform for the fake
platform build.

This reduces the blowup in execution time from running the cartesian
product of builds x tests and saves about 30% of default work done by
gn_build.sh.
  • Loading branch information
mspang committed Jul 19, 2022
1 parent 4cdecc9 commit cb6a676
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
16 changes: 15 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
enable_host_gcc_build = enable_default_builds && host_os != "win"

# Enable building chip with gcc & mbedtls.
enable_host_gcc_mbedtls_build = enable_default_builds && host_os != "win"
enable_host_gcc_mbedtls_build = false

# Enable limited testing with gcc & mbedtls.
enable_host_gcc_mbedtls_crypto_tests =
enable_default_builds && host_os != "win"

# Build the chip-cert tool.
enable_standalone_chip_cert_build =
Expand Down Expand Up @@ -349,6 +353,15 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
builds += [ ":host_gcc_mbedtls" ]
}

if (enable_host_gcc_mbedtls_crypto_tests) {
chip_build("host_gcc_mbedtls_crypto_tests") {
test_group = "//src:crypto_tests"
toolchain = "${chip_root}/config/mbedtls/toolchain:${host_os}_${host_cpu}_gcc_mbedtls"
}

builds += [ ":host_gcc_mbedtls_crypto_tests" ]
}

if (enable_android_builds) {
chip_build("android_arm") {
toolchain = "${build_root}/toolchain/android:android_arm"
Expand Down Expand Up @@ -376,6 +389,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {

if (enable_fake_tests) {
chip_build("fake_platform") {
test_group = "//src:fake_platform_tests"
toolchain = "${build_root}/toolchain/fake:fake_${host_cpu}_gcc"
}

Expand Down
13 changes: 11 additions & 2 deletions build/chip/chip_build.gni
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@ template("chip_build") {
_build_name = target_name
_toolchain = invoker.toolchain

if (defined(invoker.test_group)) {
_build_target = invoker.test_group
_check_target = get_label_info(invoker.test_group, "dir") + ":" +
get_label_info(invoker.test_group, "name") + "_run"
} else {
_build_target = ":default"
_check_target = ":check"
}

group("${_build_name}") {
deps = [ ":default(${_toolchain})" ]
deps = [ "${_build_target}(${_toolchain})" ]
}

group("check_${_build_name}") {
deps = [ ":check(${_toolchain})" ]
deps = [ "${_check_target}(${_toolchain})" ]
}
}
4 changes: 2 additions & 2 deletions build/chip/chip_test_group.gni
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ template("chip_test_group") {
}
}

if (chip_link_tests) {
group("${_test_group_name}_run") {
group("${_test_group_name}_run") {
if (chip_link_tests) {
deps = []
foreach(_test, invoker.deps) {
deps += [ get_label_info(_test, "label_no_toolchain") + "_run" ]
Expand Down
8 changes: 8 additions & 0 deletions src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,12 @@ if (chip_build_tests) {
chip_test_group("fake_platform_tests") {
deps = [ "${chip_root}/src/lib/dnssd/platform/tests" ]
}

# Tests to run with each Crypto PAL
chip_test_group("crypto_tests") {
deps = [
"${chip_root}/src/crypto/tests",
"${chip_root}/src/credentials/tests",
]
}
}

0 comments on commit cb6a676

Please sign in to comment.