From: Iago López Galeiras Date: Tue, 12 Dec 2017 16:47:41 +0000 (+0000) Subject: test: add smoke tests for `--network-namespace-path` X-Git-Tag: v236~4^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f3d33947eaf9f88f3113e1e07eafcbbc7626b7c4;p=thirdparty%2Fsystemd.git test: add smoke tests for `--network-namespace-path` We create net ns with `ip netns`, pass the created ns to nspawn and check the loopback interface is DOWN. --- diff --git a/test/TEST-13-NSPAWN-SMOKE/test.sh b/test/TEST-13-NSPAWN-SMOKE/test.sh index 3b572a76777..239c7e0731e 100755 --- a/test/TEST-13-NSPAWN-SMOKE/test.sh +++ b/test/TEST-13-NSPAWN-SMOKE/test.sh @@ -18,12 +18,12 @@ test_setup() { eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) setup_basic_environment - dracut_install busybox chmod rmdir unshare + dracut_install busybox chmod rmdir unshare ip cp create-busybox-container $initdir/ ./create-busybox-container $initdir/nc-container - initdir="$initdir/nc-container" dracut_install nc + initdir="$initdir/nc-container" dracut_install nc ip # setup the testsuite service cat >$initdir/etc/systemd/system/testsuite.service <$initdir/test-nspawn.sh <<'EOF' @@ -142,6 +144,17 @@ function run { return 1 fi + # test --network-namespace-path works with a network namespace created by "ip netns" + ip netns add nspawn_test + _netns_opt="--network-namespace-path=/run/netns/nspawn_test" + UNIFIED_CGROUP_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" ip a | grep -E '^1: lo.*DOWN' + local r=$? + ip netns del nspawn_test + + if [ $r -ne 0 ]; then + return 1 + fi + return 0 }