]> git.proxmox.com Git - mirror_lxc.git/blame - src/tests/lxc-test-snapdeps
seccomp: document path calculation
[mirror_lxc.git] / src / tests / lxc-test-snapdeps
CommitLineData
c4532a20
SH
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
30set -e
31
32if ! grep -q overlay /proc/filesystems; then
33 echo "Not running this test as overlay is not available"
34 exit 0
35fi
36
37cleanup() {
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
44verify_deps() {
45 n=$1
46 m=`wc -l /var/lib/lxc/snapdeptest/lxc_snapshots | awk '{ print $1 }'`
47 [ $((n*2)) -eq $m ]
48}
49
50cleanup
51
52trap cleanup EXIT SIGHUP SIGINT SIGTERM
53
54lxc-create -t busybox -n snapdeptest
d0a6bd39 55lxc-copy -s -n snapdeptest -N snapdeptest1
c4532a20
SH
56fail=0
57lxc-destroy -n snapdeptest || fail=1
58if [ $fail -eq 0 ]; then
59 echo "FAIL: clone did not prevent deletion"
60 false
61fi
62
63for i in `seq 2 20`; do
d0a6bd39 64 lxc-copy -s -n snapdeptest -N snapdeptest$i
c4532a20
SH
65done
66
67verify_deps 20
68
69lxc-destroy -n snapdeptest1
70
71verify_deps 19
72
73lxc-destroy -n snapdeptest20
74
75verify_deps 18
76
77for i in `seq 2 19`; do
78 lxc-destroy -n snapdeptest$i
79done
80
81lxc-destroy -n snapdeptest
82
83echo "Snapshot clone dependency test passed"
84exit 0