Skip to content

Commit ab61335

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 7a248ae commit ab61335

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
@@ -59,6 +59,10 @@ test() {
5959
fi
6060
}
6161

62+
netsim() {
63+
cargo test --release --features _netsim netsim
64+
}
65+
6266
check() {
6367
local version=$1
6468
rustup toolchain install $version
@@ -138,3 +142,7 @@ fi
138142
if [[ $1 == "coverage" || $1 == "all" ]]; then
139143
coverage
140144
fi
145+
146+
if [[ $1 == "netsim" || $1 == "all" ]]; then
147+
netsim
148+
fi

0 commit comments

Comments
 (0)