blob: 65614c682308900edb4c0624995bbbf5ecf641c3 [file] [log] [blame]
Marc Lepaged3e76ec2021-10-27 18:03:28 -04001# Copyright (c) 2020-2021 Project CHIP Authors
Robert Szewczyk38cf7312020-06-29 09:07:49 -07002#
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#
Michael Spangefa630b2020-07-08 22:23:08 -04007# http://www.apache.org/licenses/LICENSE-2.0
Robert Szewczyk38cf7312020-06-29 09:07:49 -07008#
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.
Robert Szewczyk38cf7312020-06-29 09:07:49 -070014
Łukasz Duda4e1faf22021-01-27 17:47:25 +010015import("//build_overrides/build.gni")
Michael Spangefa630b2020-07-08 22:23:08 -040016import("//build_overrides/chip.gni")
Michael Spang871ce0b2020-06-26 11:47:03 -040017
Sharad Binjola2937f1a2021-08-24 14:25:16 -070018import("${build_root}/config/compiler/compiler.gni")
Andrei Litvind0b9eb42023-05-29 15:24:10 -040019import("${chip_root}/build/chip/java/config.gni")
Michael Spang09611bf2021-03-02 16:31:57 -050020import("${chip_root}/build/chip/tests.gni")
Damian Królik56ea6a52020-10-14 21:10:08 +020021import("${chip_root}/src/ble/ble.gni")
Michael Spangdf712982020-09-18 10:39:35 -040022import("${chip_root}/src/platform/device.gni")
Andrei Litvin42425262023-06-08 18:29:54 -040023import("${chip_root}/src/tracing/tracing_args.gni")
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +020024
Michael Spang9928b522021-03-29 13:34:14 -040025declare_args() {
26 # Build monolithic test library.
27 chip_monolithic_tests = false
28}
29
Karsten Sperling5927a9a2023-04-05 22:40:35 +120030# chip_root relative to root_build_dir for macro-prefix-map.
31# "/." avoids trailing "/" in result when chip_root is "//"
32build_relative_chip_root = rebase_path("${chip_root}/.", root_build_dir)
33
Michael Spangefa630b2020-07-08 22:23:08 -040034config("includes") {
Michael Spang1fcb6dd2020-08-24 11:19:04 -040035 include_dirs = [
36 "include",
37 ".",
38 "${root_gen_dir}/include",
39 ]
Michael Spangefa630b2020-07-08 22:23:08 -040040
Wang Qixiang8686f212024-01-04 15:52:35 +080041 if (chip_device_platform == "external" &&
42 chip_external_platform_include_dir != "") {
43 include_dirs += [ "${chip_external_platform_include_dir}" ]
44 }
45
Michael Spangf6a6c1b2020-10-22 19:45:40 -040046 defines = [ "CHIP_HAVE_CONFIG_H=1" ]
Karsten Sperling5927a9a2023-04-05 22:40:35 +120047
48 # Make __FILE__ and related macros relative to chip_root
49 cflags = [ "-fmacro-prefix-map=${build_relative_chip_root}/=" ]
Michael Spangefa630b2020-07-08 22:23:08 -040050}
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +020051
52if (chip_build_tests) {
Michael Spang09611bf2021-03-02 16:31:57 -050053 import("${chip_root}/build/chip/chip_test_group.gni")
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +020054
55 chip_test_group("tests") {
Jakub Latusek9c935832024-01-23 12:55:15 +010056 deps = []
57 tests = [
Marc Lepaged3e76ec2021-10-27 18:03:28 -040058 "${chip_root}/src/access/tests",
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +020059 "${chip_root}/src/crypto/tests",
60 "${chip_root}/src/inet/tests",
Vivien Nicolasb5904312022-12-14 22:49:56 +010061 "${chip_root}/src/lib/address_resolve/tests",
Andrei Litvin2f169042020-12-01 10:58:43 -050062 "${chip_root}/src/lib/asn1/tests",
63 "${chip_root}/src/lib/core/tests",
Yufeng Wang4fc19f12020-10-22 16:14:32 -070064 "${chip_root}/src/messaging/tests",
Trevor Holbrook934f89c2020-11-18 15:34:14 -080065 "${chip_root}/src/protocols/bdx/tests",
Tennessee Carmel-Veilleuxf7cd2d62023-12-20 14:26:07 -050066 "${chip_root}/src/protocols/interaction_model/tests",
chrisdecenzo31c62492021-08-10 11:47:15 -070067 "${chip_root}/src/protocols/user_directed_commissioning/tests",
Andrei Litvin992775c2020-10-01 20:20:52 -040068 "${chip_root}/src/transport/retransmit/tests",
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +020069 ]
70
Artur Tynecki19034012021-11-15 22:57:36 +010071 # Skip DNSSD tests for Mbed platform due to flash memory size limitations
72 if (current_os != "mbed") {
Jakub Latusek9c935832024-01-23 12:55:15 +010073 tests += [
Artur Tynecki19034012021-11-15 22:57:36 +010074 "${chip_root}/src/lib/dnssd/minimal_mdns/core/tests",
75 "${chip_root}/src/lib/dnssd/minimal_mdns/responders/tests",
76 "${chip_root}/src/lib/dnssd/minimal_mdns/tests",
77 "${chip_root}/src/lib/dnssd/tests",
78 ]
79 }
80
Artur Tynecki35fb13e2021-10-12 18:23:45 +020081 if (current_os != "zephyr" && current_os != "mbed") {
Jakub Latusek9c935832024-01-23 12:55:15 +010082 tests += [ "${chip_root}/src/lib/dnssd/minimal_mdns/records/tests" ]
rgoliverd9393932021-08-11 15:59:23 -040083 }
84
Artur Tynecki35fb13e2021-10-12 18:23:45 +020085 if (current_os != "zephyr" && current_os != "mbed" &&
86 chip_device_platform != "efr32") {
Jakub Latusek9c935832024-01-23 12:55:15 +010087 tests += [
Michael Spang9928b522021-03-29 13:34:14 -040088 "${chip_root}/src/setup_payload/tests",
89 "${chip_root}/src/transport/raw/tests",
90 ]
91 }
92
rgoliverd9393932021-08-11 15:59:23 -040093 if (chip_device_platform != "efr32") {
Jakub Latusek9c935832024-01-23 12:55:15 +010094 tests += [
rgoliver2ea9fbc2021-11-04 10:08:32 -040095 # TODO(#10447): App test has HF on EFR32.
96 "${chip_root}/src/app/tests",
rgoliverd9393932021-08-11 15:59:23 -040097 "${chip_root}/src/credentials/tests",
Andrei Litvin39560922023-07-11 09:13:57 -040098 "${chip_root}/src/lib/format/tests",
rgoliverd9393932021-08-11 15:59:23 -040099 "${chip_root}/src/lib/support/tests",
100 "${chip_root}/src/protocols/secure_channel/tests",
101 "${chip_root}/src/system/tests",
102 "${chip_root}/src/transport/tests",
103 ]
Andrei Litvin42425262023-06-08 18:29:54 -0400104
Andrei Litvind3564842023-06-23 12:30:50 -0400105 if (matter_enable_tracing_support &&
106 matter_trace_config == "multiplexed") {
Jakub Latusek9c935832024-01-23 12:55:15 +0100107 tests += [ "${chip_root}/src/tracing/tests" ]
Andrei Litvin42425262023-06-08 18:29:54 -0400108 }
rgoliverd9393932021-08-11 15:59:23 -0400109 }
110
Michael Spang56970432020-11-30 17:44:42 -0500111 if (chip_device_platform != "none") {
Jakub Latusek9c935832024-01-23 12:55:15 +0100112 tests += [ "${chip_root}/src/lib/dnssd/minimal_mdns/tests" ]
Michael Spang56970432020-11-30 17:44:42 -0500113 }
114
pankore544da73c2021-10-19 02:51:16 +0800115 if (chip_device_platform != "esp32" && chip_device_platform != "efr32" &&
116 chip_device_platform != "ameba") {
Jakub Latusek9c935832024-01-23 12:55:15 +0100117 tests += [ "${chip_root}/src/platform/tests" ]
Michael Spangdf712982020-09-18 10:39:35 -0400118 }
119
Andrei Litvin2f169042020-12-01 10:58:43 -0500120 if (chip_config_network_layer_ble) {
Jakub Latusek9c935832024-01-23 12:55:15 +0100121 tests += [ "${chip_root}/src/ble/tests" ]
Damian Królik56ea6a52020-10-14 21:10:08 +0200122 }
123
Boris Zbarskybc2d74b2021-09-13 16:14:23 -0400124 # On nrfconnect, the controller tests run into
125 # https://github.com/project-chip/connectedhomeip/issues/9630
rgoliver2ea9fbc2021-11-04 10:08:32 -0400126 if (chip_device_platform != "nrfconnect" &&
127 chip_device_platform != "efr32") {
128 # TODO(#10447): Controller test has HF on EFR32.
Jakub Latusek9c935832024-01-23 12:55:15 +0100129 tests += [ "${chip_root}/src/controller/tests/data_model" ]
Artur Tynecki0efd3182022-12-05 20:18:32 +0100130
131 # Skip controller test for Open IoT SDK
132 # https://github.com/project-chip/connectedhomeip/issues/23747
133 if (chip_device_platform != "openiotsdk") {
Jakub Latusek9c935832024-01-23 12:55:15 +0100134 tests += [ "${chip_root}/src/controller/tests" ]
Artur Tynecki0efd3182022-12-05 20:18:32 +0100135 }
Sharad Binjola2937f1a2021-08-24 14:25:16 -0700136 }
137
Artur Tynecki35fb13e2021-10-12 18:23:45 +0200138 if (current_os != "zephyr" && current_os != "mbed" &&
pankore544da73c2021-10-19 02:51:16 +0800139 chip_device_platform != "esp32" && chip_device_platform != "ameba") {
Jakub Latusek9c935832024-01-23 12:55:15 +0100140 tests += [ "${chip_root}/src/lib/shell/tests" ]
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +0200141 }
Michael Spang9928b522021-03-29 13:34:14 -0400142
143 if (chip_monolithic_tests) {
Jakub Latusek9c935832024-01-23 12:55:15 +0100144 # TODO [PW_MIGRATION] Remove this if after migartion to PW_TEST is completed for all platforms
145 # TODO [PW_MIGRATION] There will be a list of already migrated platforms
Jakub Latusekc2f58e42024-03-07 13:25:18 +0100146 if (chip_device_platform == "esp32" ||
Jakub Latusek11c0af32024-03-13 20:59:07 +0100147 chip_device_platform == "nrfconnect" ||
148 chip_device_platform == "openiotsdk") {
Jakub Latusek9c935832024-01-23 12:55:15 +0100149 deps += [ "${chip_root}/src/lib/support:pw_tests_wrapper" ]
150 }
Michael Spang9928b522021-03-29 13:34:14 -0400151 build_monolithic_library = true
152 output_name = "libCHIP_tests"
153 output_dir = "${root_out_dir}/lib"
154 }
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +0200155 }
Song Guo30123da2020-10-13 19:30:39 +0800156
C Freeman79c93152021-08-18 00:20:05 -0400157 chip_test_group("fake_platform_tests") {
Jakub Latusek9c935832024-01-23 12:55:15 +0100158 tests = [ "${chip_root}/src/lib/dnssd/platform/tests" ]
C Freeman79c93152021-08-18 00:20:05 -0400159 }
Michael Spang4b77b8e2022-07-21 19:39:24 -0400160
161 # Tests to run with each Crypto PAL
162 chip_test_group("crypto_tests") {
Jakub Latusek9c935832024-01-23 12:55:15 +0100163 tests = [
Michael Spang4b77b8e2022-07-21 19:39:24 -0400164 "${chip_root}/src/credentials/tests",
165 "${chip_root}/src/crypto/tests",
166 ]
167 }
Andrei Litvind0b9eb42023-05-29 15:24:10 -0400168
169 if (matter_enable_java_compilation) {
170 group("java_controller_tests") {
171 deps = [ "${chip_root}/src/controller/java:unit_tests" ]
172 }
173 }
Rafał Kuźnia6b3ee1a2020-09-04 03:08:16 +0200174}