mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Add network namespace leak check
Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
@ -35,6 +35,9 @@ function setup_suite() {
|
|||||||
|
|
||||||
# Canary file. Will be removed if any individual test fails.
|
# Canary file. Will be removed if any individual test fails.
|
||||||
touch "$BATS_SUITE_TMPDIR/all-tests-passed"
|
touch "$BATS_SUITE_TMPDIR/all-tests-passed"
|
||||||
|
|
||||||
|
# Track network namespaces, so we can check for leaks at test end
|
||||||
|
ip netns list > $BATS_SUITE_TMPDIR/netns-pre
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run at the very end of all tests. Useful for cleanup of non-BATS tmpdirs.
|
# Run at the very end of all tests. Useful for cleanup of non-BATS tmpdirs.
|
||||||
@ -49,6 +52,15 @@ function teardown_suite() {
|
|||||||
if [ $? -gt 0 ]; then
|
if [ $? -gt 0 ]; then
|
||||||
exit_code=$((exit_code + 1))
|
exit_code=$((exit_code + 1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Network namespace leak check. List should match what we saw above.
|
||||||
|
echo
|
||||||
|
ip netns list > $BATS_SUITE_TMPDIR/netns-post
|
||||||
|
if ! diff -u $BATS_SUITE_TMPDIR/netns-{pre,post}; then
|
||||||
|
echo
|
||||||
|
echo "^^^^^ Leaks found in /run/netns ^^^^^"
|
||||||
|
exit_code=$((exit_code + 1))
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return $exit_code
|
return $exit_code
|
||||||
|
Reference in New Issue
Block a user