Skip to content

Commit d3f3d94

Browse files
authored
[Fake platform] Ensure that we only build TestPlatform when building unit tests (project-chip#43503)
* [Fake platform] Ensure that we only build TestPlatform when building tests for the Fake Platform * fix buildgn mistake
1 parent c531a36 commit d3f3d94

7 files changed

Lines changed: 20 additions & 30 deletions

File tree

BUILD.gn

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
173173
deps += [ "${chip_root}/src/app/server" ]
174174
}
175175

176-
if (chip_build_tests) {
176+
if (chip_build_tests && chip_device_platform != "fake") {
177177
deps += [
178178
"//examples:example_tests",
179179
"//src:tests",
@@ -187,6 +187,10 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
187187
}
188188
}
189189

190+
if (chip_link_tests && chip_device_platform == "fake") {
191+
deps += [ "//:fake_platform_tests" ]
192+
}
193+
190194
if (chip_with_lwip) {
191195
deps += [ "${lwip_root}:lwip" ]
192196
}
@@ -258,9 +262,8 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
258262
}
259263

260264
group("check") {
261-
if (chip_link_tests) {
265+
if (chip_link_tests && chip_device_platform != "fake") {
262266
deps = [
263-
"//:fake_platform_tests",
264267
"//examples/chef:chef.tests",
265268
"//scripts/build:build_examples.tests",
266269
"//scripts/py_matter_idl:matter-idl.tests",
@@ -275,6 +278,8 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
275278
if (current_os == "linux" || current_os == "mac") {
276279
deps += [ "${chip_root}/scripts/tools/zap:tests" ]
277280
}
281+
} else if (chip_link_tests && chip_device_platform == "fake") {
282+
deps = [ "//:fake_platform_tests" ]
278283
}
279284
}
280285
} else {

src/app/clusters/administrator-commissioning-server/tests/BUILD.gn

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import("${chip_root}/build/chip/chip_test_suite.gni")
1919

2020
chip_test_suite("tests") {
2121
output_name = "libTestAdministratorCommissioningCluster"
22-
if (!chip_fake_platform) {
23-
test_sources = [ "TestAdministratorCommissioningCluster.cpp" ]
24-
}
22+
23+
test_sources = [ "TestAdministratorCommissioningCluster.cpp" ]
24+
2525
cflags = [ "-Wconversion" ]
2626

2727
public_deps = [

src/app/tests/BUILD.gn

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ chip_test_suite("tests") {
272272
"TestEventOverflow.cpp",
273273
"TestEventPathParams.cpp",
274274
"TestFabricScopedEventLogging.cpp",
275+
"TestFailSafeContext.cpp",
275276
"TestInteractionModelEngine.cpp",
276277
"TestMessageDef.cpp",
277278
"TestNumericAttributeTraits.cpp",
@@ -286,6 +287,7 @@ chip_test_suite("tests") {
286287
"TestStatusIB.cpp",
287288
"TestStatusResponseMessage.cpp",
288289
"TestTestEventTriggerDelegate.cpp",
290+
"TestThreadBorderRouterManagementCluster.cpp",
289291
"TestTimeSyncDataProvider.cpp",
290292
"TestTimedHandler.cpp",
291293
"TestWriteInteraction.cpp",
@@ -300,6 +302,7 @@ chip_test_suite("tests") {
300302
":ecosystem-information-test-srcs",
301303
":operational-state-test-srcs",
302304
":ota-requestor-test-srcs",
305+
":thread-border-router-management-test-srcs",
303306
":thread-network-directory-test-srcs",
304307
":time-sync-data-provider-test-srcs",
305308
"${chip_root}/src/app",
@@ -347,14 +350,6 @@ chip_test_suite("tests") {
347350
"${chip_root}/src/messaging/tests/echo:common",
348351
]
349352
}
350-
if (!chip_fake_platform) {
351-
test_sources += [ "TestThreadBorderRouterManagementCluster.cpp" ]
352-
public_deps += [ ":thread-border-router-management-test-srcs" ]
353-
}
354-
355-
if (!chip_fake_platform) {
356-
test_sources += [ "TestFailSafeContext.cpp" ]
357-
}
358353

359354
# DefaultICDClientStorage assumes that raw AES key is used by the application
360355
if (chip_crypto != "psa") {
@@ -373,10 +368,10 @@ chip_test_suite("tests") {
373368
test_sources += [ "TestClusterStateCache.cpp" ]
374369
}
375370

376-
# On NRF, Open IoT SDK and fake platforms we do not have a realtime clock available,
371+
# On NRF platform we do not have a realtime clock available,
377372
# so TestEventLogging.cpp would be testing the same thing as TestEventLoggingNoUTCTime,
378373
# but it's not set up to deal with the timestamps being that low.
379-
if (chip_device_platform != "nrfconnect" && chip_device_platform != "fake") {
374+
if (chip_device_platform != "nrfconnect") {
380375
test_sources += [ "TestEventLogging.cpp" ]
381376
}
382377
}

src/controller/tests/BUILD.gn

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,9 @@ chip_test_suite("tests") {
3737
"TestEventNumberCaching.cpp",
3838
"TestReadChunking.cpp",
3939
"TestServerCommandDispatch.cpp",
40+
"TestWriteChunking.cpp",
4041
]
4142

42-
# At some instances, this Test end ups allocating more than 32 Timers, and since the fake platform doesn`t use the heap, the maximum number of allowed timers is 32.
43-
# So we get failures because we can't allocate any more timers, in the log it looks like:
44-
# SendMessage() to UDP:[::1]:5541 failed: b
45-
# deactivating since the Fake platform is mostly done to test Platform APIs
46-
if (chip_device_platform != "fake") {
47-
test_sources += [ "TestWriteChunking.cpp" ]
48-
}
49-
5043
# Not supported on efr32.
5144
if (chip_device_platform != "efr32") {
5245
test_sources += [

src/controller/tests/data_model/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ chip_test_suite("data_model") {
2929
]
3030

3131
test_sources = []
32-
if (chip_device_platform != "esp32" && chip_device_platform != "fake") {
32+
if (chip_device_platform != "esp32") {
3333
test_sources += [
3434
"TestCommands.cpp",
3535
"TestWrite.cpp",

src/platform/tests/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ declare_args() {
2323
chip_enable_dnssd_tests = chip_device_platform == "darwin"
2424
}
2525

26-
if (chip_device_platform != "none" && chip_device_platform != "fake") {
26+
if (chip_device_platform != "none") {
2727
import("${chip_root}/build/chip/chip_test_suite.gni")
2828

2929
chip_test_suite("tests") {

src/system/tests/BUILD.gn

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@ chip_test_suite("tests") {
2727
"TestSystemErrorStr.cpp",
2828
"TestSystemPacketBuffer.cpp",
2929
"TestSystemScheduleLambda.cpp",
30+
"TestSystemScheduleWork.cpp",
3031
"TestSystemTimer.cpp",
3132
"TestTimeSource.cpp",
3233
]
3334

34-
if (chip_device_platform != "fake") {
35-
test_sources += [ "TestSystemScheduleWork.cpp" ]
36-
}
37-
3835
# SystemPacketBuffer on nrfconnect uses LwIP buffers, which ignore the
3936
# requested allocation size and always allocate at max-size. So our test,
4037
# which tries to size-limit the buffers, does not work correctly there.

0 commit comments

Comments
 (0)