Skip to content

Commit 512aecb

Browse files
committed
tcp: add netsim test.
This test simulates a network with a given latency and packet loss, and measures the throughput between two virtual smoltcp instances.
1 parent ddc495b commit 512aecb

File tree

5 files changed

+404
-1
lines changed

5 files changed

+404
-1
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: Test
77
jobs:
88
tests:
99
runs-on: ubuntu-22.04
10-
needs: [check-msrv, test-msrv, test-stable, clippy]
10+
needs: [check-msrv, test-msrv, test-stable, clippy, test-netsim]
1111
steps:
1212
- name: Done
1313
run: exit 0
@@ -48,6 +48,14 @@ jobs:
4848
- name: Run Tests nightly
4949
run: ./ci.sh test nightly
5050

51+
test-netsim:
52+
runs-on: ubuntu-22.04
53+
continue-on-error: true
54+
steps:
55+
- uses: actions/checkout@v4
56+
- name: Run network-simulation tests
57+
run: ./ci.sh netsim
58+
5159
test-build-16bit:
5260
runs-on: ubuntu-22.04
5361
continue-on-error: true

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ getopts = "0.2"
3535
rand = "0.8"
3636
url = "2.0"
3737
rstest = "0.17"
38+
insta = "1.41.1"
39+
rand_chacha = "0.3.1"
3840

3941
[features]
4042
std = ["managed/std", "alloc"]
@@ -109,6 +111,8 @@ default = [
109111

110112
"_proto-fragmentation" = []
111113

114+
"_netsim" = []
115+
112116
# BEGIN AUTOGENERATED CONFIG FEATURES
113117
# Generated by gen_config.py. DO NOT EDIT.
114118
iface-max-addr-count-1 = []
@@ -267,6 +271,10 @@ rpl-parents-buffer-count-32 = []
267271

268272
# END AUTOGENERATED CONFIG FEATURES
269273

274+
[[test]]
275+
name = "netsim"
276+
required-features = ["_netsim"]
277+
270278
[[example]]
271279
name = "packet2pcap"
272280
path = "utils/packet2pcap.rs"

ci.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ test() {
6060
fi
6161
}
6262

63+
netsim() {
64+
cargo test --release --features _netsim netsim
65+
}
66+
6367
check() {
6468
local version=$1
6569
rustup toolchain install $version
@@ -139,3 +143,7 @@ fi
139143
if [[ $1 == "coverage" || $1 == "all" ]]; then
140144
coverage
141145
fi
146+
147+
if [[ $1 == "netsim" || $1 == "all" ]]; then
148+
netsim
149+
fi

0 commit comments

Comments
 (0)