From b42fca2574a19621c34a535d4a8d2a9f85cd8a48 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 31 May 2017 15:14:54 +0800 Subject: [PATCH] add readonly rootfs ut Signed-off-by: Peng Tao --- hack/lib/test.sh | 11 +++++++++++ hack/pods/readonly-rootfs.pod | 18 ++++++++++++++++++ hack/test-cmd.sh | 1 + 3 files changed, 30 insertions(+) create mode 100644 hack/pods/readonly-rootfs.pod diff --git a/hack/lib/test.sh b/hack/lib/test.sh index 7efd0730..d38efd60 100644 --- a/hack/lib/test.sh +++ b/hack/lib/test.sh @@ -228,3 +228,14 @@ hyper::test::container_logs_no_newline() { echo logs result $res test x$res = "xfoobar" } + +hyper::test::container_readonly_rootfs_and_volume() { + echo "Container rootfs and volume readonly test" + id=$(sudo hyperctl run -p ${HYPER_ROOT}/hack/pods/readonly-rootfs.pod | sed -ne 's/POD id is \(.*\)/\1/p') + sudo hyperctl exec -t $id mount + res1=$(sudo hyperctl exec $id touch /foobar | grep 'Read-only file system' > /dev/null 2>&1; echo $?) + res2=$(sudo hyperctl exec $id touch /tmp/foobar | grep 'Read-only file system' > /dev/null 2>&1; echo $?) + sudo hyperctl rm $id + echo res1=$res1 res2=$res2 + test $res1 -eq 0 -a $res2 -eq 0 +} diff --git a/hack/pods/readonly-rootfs.pod b/hack/pods/readonly-rootfs.pod new file mode 100644 index 00000000..7a19a447 --- /dev/null +++ b/hack/pods/readonly-rootfs.pod @@ -0,0 +1,18 @@ +{ + "containers" : [{ + "name": "busybox-readonly", + "image": "busybox", + "command": ["/bin/sh"], + "readonly": true, + "volumes": [{ + "volume": "tmp", + "path": "/tmp", + "readOnly": true + }] + }], + "volumes": [{ + "name": "tmp", + "source": "", + "format": "" + }] +} diff --git a/hack/test-cmd.sh b/hack/test-cmd.sh index 6aeade7c..7d65577e 100755 --- a/hack/test-cmd.sh +++ b/hack/test-cmd.sh @@ -198,6 +198,7 @@ __EOF__ hyper::test::imagevolume hyper::test::force_kill_container hyper::test::container_logs_no_newline + hyper::test::container_readonly_rootfs_and_volume stop_hyperd }