Skip to content

Commit d8cd5dc

Browse files
committedJun 18, 2024
making TestInetLayer an executable tool
1 parent ab2907b commit d8cd5dc

File tree

5 files changed

+48
-296
lines changed

5 files changed

+48
-296
lines changed
 

‎BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
161161
"${chip_root}/examples/shell/standalone:chip-shell",
162162
"${chip_root}/src/app/tests/integration:chip-im-initiator",
163163
"${chip_root}/src/app/tests/integration:chip-im-responder",
164+
"${chip_root}/src/inet/tests:inet-layer-test-tool",
164165
"${chip_root}/src/lib/address_resolve:address-resolve-tool",
165166
"${chip_root}/src/messaging/tests/echo:chip-echo-requester",
166167
"${chip_root}/src/messaging/tests/echo:chip-echo-responder",

‎src/inet/tests/BUILD.gn

+44-33
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414

1515
import("//build_overrides/build.gni")
1616
import("//build_overrides/chip.gni")
17+
import("//build_overrides/nlfaultinjection.gni")
1718
import("//build_overrides/pigweed.gni")
1819

19-
import("${chip_root}/build/chip/chip_test_suite.gni")
2020
import("${chip_root}/build/chip/tests.gni")
21+
import("${chip_root}/build/chip/tools.gni")
2122
import("${chip_root}/src/platform/device.gni")
2223
import("${chip_root}/src/system/system.gni")
2324

25+
if (chip_build_tests) {
26+
import("${chip_root}/build/chip/chip_test_suite.gni")
27+
}
28+
2429
config("tests_config") {
2530
include_dirs = [ "." ]
2631
}
@@ -40,55 +45,61 @@ static_library("helpers") {
4045
"TestSetupSignallingPosix.cpp",
4146
]
4247

43-
if (current_os != "mbed") {
44-
sources += [ "TestInetLayer.cpp" ]
45-
}
48+
cflags = [ "-Wconversion" ]
49+
50+
public_deps = [
51+
"${chip_root}/src/inet",
52+
"${chip_root}/src/lib/core",
53+
"${chip_root}/src/platform",
54+
"${nlfaultinjection_root}:nlfaultinjection",
55+
]
4656

4757
if (chip_with_nlfaultinjection) {
4858
sources += [
4959
"TestSetupFaultInjection.h",
5060
"TestSetupFaultInjectionPosix.cpp",
5161
]
62+
public_deps += [ "${nlfaultinjection_root}:nlfaultinjection" ]
5263
}
64+
}
5365

54-
cflags = [ "-Wconversion" ]
66+
if (chip_build_tests) {
67+
chip_test_suite("tests") {
68+
output_name = "libInetLayerTests"
5569

56-
public_deps = [
57-
"${chip_root}/src/inet",
58-
"${chip_root}/src/lib/core",
59-
"${chip_root}/src/platform",
60-
]
70+
public_configs = [ ":tests_config" ]
71+
72+
public_deps = [
73+
":helpers",
74+
"${chip_root}/src/inet",
75+
"${chip_root}/src/lib/core",
76+
]
77+
test_sources = [
78+
"TestBasicPacketFilters.cpp",
79+
"TestInetAddress.cpp",
80+
"TestInetErrorStr.cpp",
81+
]
82+
sources = []
83+
84+
if (chip_system_config_use_sockets && current_os != "zephyr") {
85+
test_sources += [ "TestInetEndPoint.cpp" ]
86+
}
87+
88+
cflags = [ "-Wconversion" ]
89+
}
6190
}
6291

63-
chip_test_suite("tests") {
64-
output_name = "libInetLayerTests"
92+
executable("inet-layer-test-tool") {
93+
sources = [ "inet-layer-test-tool.cpp" ]
6594

66-
public_configs = [ ":tests_config" ]
95+
cflags = [ "-Wconversion" ]
6796

6897
public_deps = [
6998
":helpers",
7099
"${chip_root}/src/inet",
71100
"${chip_root}/src/lib/core",
101+
"${chip_root}/src/platform",
72102
]
73-
test_sources = [
74-
"TestBasicPacketFilters.cpp",
75-
"TestInetAddress.cpp",
76-
"TestInetErrorStr.cpp",
77-
]
78-
sources = []
79-
80-
if (chip_system_config_use_sockets && current_os != "zephyr") {
81-
test_sources += [ "TestInetEndPoint.cpp" ]
82-
}
83103

84-
# This fails on Raspberry Pi (Linux arm64), so only enable on Linux
85-
# x64.
86-
if (current_os != "mac" && current_os != "zephyr" &&
87-
chip_device_platform != "esp32" && current_cpu == "x64" &&
88-
chip_device_platform != "ameba") {
89-
# TODO: This test does not seem executed
90-
sources += [ "TestLwIPDNS.cpp" ]
91-
}
92-
93-
cflags = [ "-Wconversion" ]
104+
output_dir = root_out_dir
94105
}

‎src/inet/tests/TestInetLayerCommon.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ extern bool IsSender();
126126
extern bool IsTesting(const TestStatus & aTestStatus);
127127
extern bool WasSuccessful(const TestStatus & aTestStatus);
128128

129-
extern chip::System::PacketBufferHandle MakeDataBuffer(uint16_t aDesiredLength, uint8_t aFirstValue);
130-
extern chip::System::PacketBufferHandle MakeDataBuffer(uint16_t aDesiredLength);
129+
extern chip::System::PacketBufferHandle MakeDataBuffer(size_t aDesiredLength, uint8_t aFirstValue);
130+
extern chip::System::PacketBufferHandle MakeDataBuffer(size_t aDesiredLength);
131131
extern chip::System::PacketBufferHandle MakeICMPv4DataBuffer(uint16_t aDesiredUserLength);
132132
extern chip::System::PacketBufferHandle MakeICMPv6DataBuffer(uint16_t aDesiredUserLength);
133133

‎src/inet/tests/TestLwIPDNS.cpp

-260
This file was deleted.

0 commit comments

Comments
 (0)