]> git.proxmox.com Git - mirror_lxc.git/blob - src/tests/lxc-test-rootfs
spelling: timeout
[mirror_lxc.git] / src / tests / lxc-test-rootfs
1 #!/bin/bash
2
3 # lxc: linux Container library
4
5 # Authors:
6 # Feng Li <lifeng68@huawei.com>
7
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
12
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
17
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22 set -ex
23
24 cleanup() {
25 set +e
26 lxc-destroy -n lxc-test-rootfs -f
27 if [ $PHASE != "done" ]; then
28 echo "rootfs test failed at $PHASE"
29 exit 1
30 fi
31 echo "rootfs test passed"
32 exit 0
33 }
34
35 PHASE=setup
36 trap cleanup EXIT
37
38 lxc-destroy -n lxc-test-rootfs -f || true
39 lxc-create -t busybox -n lxc-test-rootfs
40
41 PHASE=ro_rootfs
42 echo "Starting phase $PHASE"
43 config=/var/lib/lxc/lxc-test-rootfs/config
44 sed -i '/lxc.rootfs.options/d' $config
45 echo "lxc.rootfs.options = ro" >> $config
46
47 lxc-start -n lxc-test-rootfs
48 pid=`lxc-info -n lxc-test-rootfs -p -H`
49 ro=0
50 mkdir /proc/$pid/root/rotest || ro=1
51 [ $ro -ne 0 ]
52
53 lxc-stop -n lxc-test-rootfs -k
54 PHASE=rw_rootfs
55 echo "Starting phase $PHASE"
56 sed -i '/lxc.rootfs.options/d' $config
57 echo "lxc.rootfs.options = rw" >> $config
58 lxc-start -n lxc-test-rootfs
59 pid=`lxc-info -n lxc-test-rootfs -p -H`
60 ro=0
61 mkdir /proc/$pid/root/rwtest || ro=1
62 [ $ro -ne 1 ]
63 rmdir /proc/$pid/root/rwtest
64 ro=0
65
66 PHASE=done