2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00

test: only run macvlan tests if macvlan devices can be created

Some test environments (Actuated runners for example) do not support
maclvan devices. Skip tests depending on it automatically.

Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
Adrian Reber 2024-07-08 16:51:28 +00:00 committed by Andrei Vagin
parent 01c65732b6
commit d44fc0de5a
2 changed files with 43 additions and 0 deletions

View File

@ -2,6 +2,11 @@
set -x
if ! ../../zdtm/static/macvlan.checkskip; then
echo "No macvlan support. Skipping"
exit 0
fi
if [[ "$1" == "pid" ]]; then
NS=pid
else

View File

@ -0,0 +1,38 @@
#!/bin/bash
FAIL=0
create_macvlan_device() {
if ! ip link add test_mvlan1 type veth >/dev/null 2>&1; then
FAIL=1
fi
if ! ip link add mymacvlan1 link test_mvlan1 type macvlan >/dev/null 2>&1; then
FAIL=1
fi
return "${FAIL}"
}
cleanup() {
ip link del test_mvlan1 >/dev/null 2>&1
ip link del mymacvlan1 >/dev/null 2>&1
}
trap "cleanup" QUIT TERM INT HUP EXIT
# Test once without loading the module
if create_macvlan_device; then
exit 0
fi
# Test once more with explicitly loading the module
if ! modprobe macvlan >/dev/null 2>&1; then
exit 1
fi
create_macvlan_device
if [ "${FAIL}" == "1" ]; then
exit 1
fi
exit 0