]> git.proxmox.com Git - mirror_lxc.git/blob - src/tests/lxc-test-snapdeps
configure.ac: add --enable-deprecated flag
[mirror_lxc.git] / src / tests / lxc-test-snapdeps
1 #!/bin/bash
2
3 # lxc: linux Container library
4
5 # Authors:
6 # Serge Hallyn <serge.hallyn@ubuntu.com>
7 #
8 # This is a test for dependency between snapshots
9 #
10 # When container c2 is created as an overlayfs clone of c1, then
11 # we record it as such, because c1 cannot be deleted until c2 is
12 # deleted. Once c2 is deleted, c1 should be delete-able.
13
14 # This library is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU Lesser General Public
16 # License as published by the Free Software Foundation; either
17 # version 2.1 of the License, or (at your option) any later version.
18
19 # This library is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 # Lesser General Public License for more details.
23
24 # You should have received a copy of the GNU Lesser General Public
25 # License along with this library; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27
28 # This test assumes an Ubuntu host
29
30 set -e
31
32 if ! grep -q overlay /proc/filesystems; then
33 echo "Not running this test as overlay is not available"
34 exit 0
35 fi
36
37 cleanup() {
38 for i in `seq 1 20`; do
39 lxc-destroy -n snapdeptest$i > /dev/null 2>&1 || true
40 done
41 lxc-destroy -n snapdeptest > /dev/null 2>&1 || true
42 }
43
44 verify_deps() {
45 n=$1
46 m=`wc -l /var/lib/lxc/snapdeptest/lxc_snapshots | awk '{ print $1 }'`
47 [ $((n*2)) -eq $m ]
48 }
49
50 cleanup
51
52 trap cleanup EXIT SIGHUP SIGINT SIGTERM
53
54 lxc-create -t busybox -n snapdeptest
55 lxc-copy -s -n snapdeptest -N snapdeptest1
56 fail=0
57 lxc-destroy -n snapdeptest || fail=1
58 if [ $fail -eq 0 ]; then
59 echo "FAIL: clone did not prevent deletion"
60 false
61 fi
62
63 for i in `seq 2 20`; do
64 lxc-copy -s -n snapdeptest -N snapdeptest$i
65 done
66
67 verify_deps 20
68
69 lxc-destroy -n snapdeptest1
70
71 verify_deps 19
72
73 lxc-destroy -n snapdeptest20
74
75 verify_deps 18
76
77 for i in `seq 2 19`; do
78 lxc-destroy -n snapdeptest$i
79 done
80
81 lxc-destroy -n snapdeptest
82
83 echo "Snapshot clone dependency test passed"
84 exit 0