Skip to content

Commit

Permalink
run nft tests in netns
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhb committed Mar 15, 2024
1 parent 173d1bd commit b98e508
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ jobs:
- name: Run tests
run: cargo test --verbose
- name: Run tests (rootful)
run: nft --version; sudo -E $(which cargo) test --verbose -- --ignored
run: sudo -E env "PATH=$PATH" $(which cargo) test --verbose -- --ignored

18 changes: 18 additions & 0 deletions tests/run_nft_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh -e
NETNS=nft-$(cat /proc/sys/kernel/random/uuid)

function nsexec {
ip netns exec $NETNS $@
}

function cleanup {
ip netns delete "$NETNS"
exit 0
}
trap cleanup EXIT

# create net namespace
(ip netns ls | grep -Fx "$NETNS" 2>/dev/null) || ip netns add "$NETNS"

nft --version;
nsexec cargo test --verbose -- --ignored

0 comments on commit b98e508

Please sign in to comment.