summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorIago López Galeiras <iago@kinvolk.io>2017-12-12 16:47:41 +0000
committerIago López Galeiras <iago@kinvolk.io>2017-12-14 17:34:26 +0100
commitf3d33947eaf9f88f3113e1e07eafcbbc7626b7c4 (patch)
tree5bfe8c20476b8ec75f214d164ea472935c8e96b6 /test
parent25fd8143169d43843143f12ecf73cc80e4cc3f9f (diff)
downloadsystemd-f3d33947eaf9f88f3113e1e07eafcbbc7626b7c4.tar.gz
systemd-f3d33947eaf9f88f3113e1e07eafcbbc7626b7c4.tar.bz2
systemd-f3d33947eaf9f88f3113e1e07eafcbbc7626b7c4.zip
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.
Diffstat (limited to 'test')
-rwxr-xr-xtest/TEST-13-NSPAWN-SMOKE/test.sh17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/TEST-13-NSPAWN-SMOKE/test.sh b/test/TEST-13-NSPAWN-SMOKE/test.sh
index 3b572a7677..239c7e0731 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 <<EOF
@@ -34,6 +34,8 @@ After=multi-user.target
[Service]
ExecStart=/test-nspawn.sh
Type=oneshot
+StandardOutput=tty
+StandardError=tty
EOF
cat >$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
}