Skip to content

Commit

Permalink
tcp: add netsim test.
Browse files Browse the repository at this point in the history
This test simulates a network with a given latency and packet loss, and measures the
throughput between two virtual smoltcp instances.
  • Loading branch information
Dirbaio committed Dec 30, 2024
1 parent 7a248ae commit aff2bce
Show file tree
Hide file tree
Showing 5 changed files with 400 additions and 3 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Test
jobs:
tests:
runs-on: ubuntu-22.04
needs: [check-msrv, test-msrv, test-stable, clippy]
needs: [check-msrv, test-msrv, test-stable, clippy, test-netsim]
steps:
- name: Done
run: exit 0
Expand Down Expand Up @@ -48,6 +48,14 @@ jobs:
- name: Run Tests nightly
run: ./ci.sh test nightly

test-netsim:
runs-on: ubuntu-22.04
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Run network-simulation tests
run: ./ci.sh netsim

test-build-16bit:
runs-on: ubuntu-22.04
continue-on-error: true
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ getopts = "0.2"
rand = "0.8"
url = "2.0"
rstest = "0.17"
insta = "1.41.1"
rand_chacha = "0.3.1"

[features]
std = ["managed/std", "alloc"]
Expand Down
12 changes: 10 additions & 2 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,20 @@ test() {
rustup toolchain install $version

for features in ${FEATURES_TEST[@]}; do
cargo +$version test --no-default-features --features "$features"
cargo +$version test --no-default-features --features "$features" -- --skip netsim
done

if [[ $version == "nightly" ]]; then
for features in ${FEATURES_TEST_NIGHTLY[@]}; do
cargo +$version test --no-default-features --features "$features"
cargo +$version test --no-default-features --features "$features" -- --skip netsim
done
fi
}

netsim() {
cargo test --release netsim
}

check() {
local version=$1
rustup toolchain install $version
Expand Down Expand Up @@ -138,3 +142,7 @@ fi
if [[ $1 == "coverage" || $1 == "all" ]]; then
coverage
fi

if [[ $1 == "netsim" || $1 == "all" ]]; then
netsim
fi
Loading

0 comments on commit aff2bce

Please sign in to comment.