Skip to content

Commit 22d490a

Browse files
authored
Enabled most unit tests for ESP32 (#36738)
* Enabled most unit tests for ESP32 * Reformatting by Restyled
1 parent cbf92b7 commit 22d490a

File tree

8 files changed

+57
-38
lines changed

8 files changed

+57
-38
lines changed

build/chip/chip_test_suite.gni

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ template("chip_test_suite") {
9393
} else {
9494
public_deps += [ "${chip_root}/src/platform/logging:default" ]
9595
}
96+
97+
if (chip_device_platform == "esp32") {
98+
complete_static_lib = true
99+
}
96100
}
97101

98102
# Build a source_set or a flashable executable for each individual unit test source, which also includes the common files.

src/credentials/BUILD.gn

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ static_library("credentials") {
110110
import("${chip_root}/build/chip/tests.gni")
111111
if (!(chip_build_tests && (chip_device_platform == "mbed" ||
112112
chip_device_platform == "openiotsdk" ||
113-
chip_device_platform == "nrfconnect"))) {
113+
chip_device_platform == "nrfconnect" ||
114+
chip_device_platform == "esp32"))) {
114115
sources += [
115116
"tests/CHIPAttCert_test_vectors.cpp",
116117
"tests/CHIPAttCert_test_vectors.h",

src/lib/core/BUILD.gn

+1-4
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,7 @@ static_library("core") {
204204
]
205205
}
206206

207-
static_library("vectortlv") {
208-
output_name = "libVectorTlv"
209-
output_dir = "${root_out_dir}/lib"
210-
207+
source_set("vectortlv") {
211208
sources = [
212209
"TLVVectorWriter.cpp",
213210
"TLVVectorWriter.h",

src/lib/support/BUILD.gn

+1-3
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,7 @@ static_library("support") {
334334
}
335335
}
336336

337-
static_library("test_utils") {
338-
output_name = "libTestUtils"
339-
output_dir = "${root_out_dir}/lib"
337+
source_set("test_utils") {
340338
deps = [ "${chip_root}/src/platform" ]
341339

342340
sources = [

src/test_driver/esp32/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
/build/
22
/sdkconfig
33
/sdkconfig.old
4+
/dependencies.lock
5+
/sdkconfig
6+
/managed_components/

src/test_driver/esp32/CMakeLists.txt

+23-12
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,36 @@ project(test-driver)
3535
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DLWIP_IPV6_SCOPES=0;-DCHIP_HAVE_CONFIG_H" APPEND)
3636
idf_build_set_property(C_COMPILE_OPTIONS "-Os;-DLWIP_IPV6_SCOPES=0" APPEND)
3737

38-
# TODO: libAppTests depends on MessagingTestHelpers, which depends on
39-
# NetworkTestHelpers. That sort of depends on InetTestHelpers or
40-
# equivalent (to provide gSystemLayer, gInet, InitNetwork(),
41-
# ShutdownNetwork()) but there's only a POSIX implementation of that
42-
# last, which does not compile on ESP32. Need to figure out how to
43-
# make that work. See comments below for the transport layer tests,
44-
# which have the same issue.
45-
#
46-
# libAppTests.a -lMessagingTestHelpers -lNetworkTestHelpers
47-
#
48-
# TODO: ble tests do not compile using CMake (library is not auto-built)
49-
# libBleLayerTests.a
5038

39+
esp32_unit_test(NAME testAccess LIBRARY accesstest)
40+
esp32_unit_test(NAME testAddressResolve LIBRARY AddressResolveTests)
41+
esp32_unit_test(NAME testAppClusterBuildingBlock LIBRARY AppClusterBuildingBlockTests)
42+
esp32_unit_test(NAME testAppDataModel LIBRARY AppDataModelTests)
5143
esp32_unit_test(NAME testASN1 LIBRARY ASN1Tests)
44+
esp32_unit_test(NAME testBDX LIBRARY BDXTests)
5245
esp32_unit_test(NAME testChipCrypto LIBRARY ChipCryptoTests EXTRA_LIBRARIES -lCertTestVectors)
46+
esp32_unit_test(NAME testCodegenDataModelProvider LIBRARY CodegenDataModelProviderTests)
5347
esp32_unit_test(NAME testCore LIBRARY CoreTests)
48+
esp32_unit_test(NAME testFormat LIBRARY FormatTests)
49+
esp32_unit_test(NAME testIMInterface LIBRARY IMInterfaceTests)
5450
esp32_unit_test(NAME testInetLayer LIBRARY InetLayerTests)
51+
esp32_unit_test(NAME testInteractionModel LIBRARY InteractionModelTests)
52+
esp32_unit_test(NAME testMinimalMdnsCore LIBRARY MinimalMdnsCoreTests)
53+
esp32_unit_test(NAME testMinimalMdnsRecords LIBRARY MinimalMdnsRecordsTests)
54+
esp32_unit_test(NAME testMinimalMdnsResponders LIBRARY MinimalMdnsRespondersTests)
55+
esp32_unit_test(NAME testMdns LIBRARY MdnsTests)
5556
esp32_unit_test(NAME testRetransmit LIBRARY RetransmitTests)
57+
esp32_unit_test(NAME testSetupPayload LIBRARY SetupPayloadTests)
5658
esp32_unit_test(NAME testSystemLayer LIBRARY SystemLayerTests)
59+
esp32_unit_test(NAME testUserDirectedCommissioning LIBRARY UserDirectedCommissioningTests)
60+
61+
# TODO: libAppTests depends on MessagingTestHelpers, which depends on
62+
# NetworkTestHelpers. That sort of depends on InetTestHelpers or
63+
# equivalent (to provide gSystemLayer, gInet, InitNetwork(),
64+
# ShutdownNetwork()) but there's only a POSIX implementation of that
65+
# last, which does not compile on ESP32.
66+
# This affects AppTests, MessagingLayerTests, MinimalMdnstests, ControllerTests
67+
# ControllerDataModelTests, ICDServerTests, SecureChannelTests.
5768

5869

5970
# allow other tools to discover what images are available without grepping for '.img'

src/test_driver/esp32/README.md

+23-16
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ An application that runs Matter's unit tests on ESP32 device or QEMU.
66

77
- [Matter Tests on Device](#chip-tests-on-device)
88
- [Supported Devices](#supported-devices)
9-
- [Building the Application](#building-the-application)
10-
- [To build the application, follow these steps:](#to-build-the-application-follow-these-steps)
11-
- [Using QEMU](#using-qemu)
9+
- [Requirements](#requirements)
10+
- [Building Unit Tests](#building-unit-tests)
11+
- [Running Unit Tests](#running-unit-tests)
1212

1313
---
1414

@@ -20,7 +20,7 @@ The Matter application is intended to work on
2020
[M5Stack](http://m5stack.com). Support for the [M5Stack](http://m5stack.com) is
2121
still a Work in Progress.
2222

23-
## Building the Application
23+
## Requirements
2424

2525
Building the application requires the use of the Espressif ESP32 IoT Development
2626
Framework and the xtensa-esp32-elf toolchain.
@@ -51,20 +51,27 @@ follow these steps:
5151
$ make -j8
5252
$ export QEMU_ESP32=${HOME}/tools/qemu_esp32/xtensa-softmmu/qemu-system-xtensa
5353

54-
### To build the application, follow these steps:
54+
## Building Unit Tests
5555

56-
#### Using QEMU
56+
To build all unit tests:
5757

58-
- Setup ESP32 QEMU. This will build QEMU and install necessary artifacts to
59-
run unit tests.
58+
$ source scripts/activate.sh
59+
$ scripts/build/build_examples.py --target esp32-qemu-tests build
6060

61-
```
62-
source idf.sh
63-
./qemu_setup.sh
64-
```
61+
This generates a list of QEMU images in `out/esp32-qemu-tests/`
6562

66-
- Run specific unit tests
63+
There is one image for each test directory (i.e. each chip_test_suite). So for
64+
example `src/inet/tests` builds to `out/esp32-qemu-tests/testInetLayer.img`
6765

68-
```
69-
idf make -C build/chip/src/crypto/tests check
70-
```
66+
The file `out/esp32-qemu-tests/test_images.txt` contains the names of all the
67+
images that were built.
68+
69+
## Running Unit Tests
70+
71+
To run all unit test images using QEMU:
72+
73+
$ src/test_driver/esp32/run_qemu_image.py --verbose --file-image-list out/esp32-qemu-tests/test_images.txt
74+
75+
To run a single unit test image, such as `testInetLayer.img`:
76+
77+
$ src/test_driver/esp32/run_qemu_image.py --verbose --image out/esp32-qemu-tests/testInetLayer.img

src/test_driver/esp32/cmake/esp32_unit_tests.cmake

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ macro(esp32_unit_test)
3636
idf::main
3737
-Wl,--whole-archive ${UNIT_TEST_LIBRARY} -Wl,--no-whole-archive
3838
${UNIT_TEST_EXTRA_LIBRARIES}
39-
-lVectorTlv
40-
-lTestUtils
4139
nlfaultinjection
4240
)
4341

0 commit comments

Comments
 (0)