]> git.proxmox.com Git - mirror_zfs-debian.git/blob - debian/tests/kernel-smoke-test-filesystem
Prepare upload of 0.7.3-1
[mirror_zfs-debian.git] / debian / tests / kernel-smoke-test-filesystem
1 #!/bin/sh
2 #
3 # Copyright (C) 2016 Canonical
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #
19 echo -n "kernel smoke test, create and destroy ZFS filesystems: "
20 TMP=/tmp
21 VDEV0=${TMP}/pool0-$$.img
22 VDEV1=${TMP}/pool1-$$.img
23 POOL=pool-smoke-$$
24 ZFSFS="test tmp example data1 data2 data3"
25
26 dd if=/dev/zero of=${VDEV0} bs=1M count=512 > /dev/null 2>&1
27 dd if=/dev/zero of=${VDEV1} bs=1M count=512 > /dev/null 2>&1
28
29 zpool create ${POOL} ${VDEV0} ${VDEV1}
30 ret=$?
31 if [ $ret -ne 0 ]; then
32 echo "FAILED: zpool create failed, exit code=$ret"
33 rm ${VDEV0} ${VDEV1}
34 exit 1
35 fi
36
37 #
38 # And populate with ZFS file systems
39 #
40 for fs in ${ZFSFS}
41 do
42 zfs create ${POOL}/$fs
43 ret=$?
44 if [ $ret -ne 0 ]; then
45 echo "FAILED: zfs create filesystem $fs failed, exit code=$ret"
46 zpool destroy ${POOL}
47 rm ${VDEV0} ${VDEV1}
48 exit 1
49 fi
50
51 zfs set quota=128M ${POOL}/$fs
52 ret=$?
53 if [ $ret -ne 0 ]; then
54 echo "FAILED: zfs set quota on $fs failed, exit code=$ret"
55 zpool destroy ${POOL}
56 rm ${VDEV0} ${VDEV1}
57 exit 1
58 fi
59
60 zfs set compression=on ${POOL}/$fs
61 ret=$?
62 if [ $ret -ne 0 ]; then
63 echo "FAILED: zfs set compression on $fs failed, exit code=$ret"
64 zpool destroy ${POOL}
65 rm ${VDEV0} ${VDEV1}
66 exit 1
67 fi
68 done
69
70 #
71 # And destroy ZFS file systems
72 #
73 for fs in ${ZFSFS}
74 do
75 zfs destroy ${POOL}/$fs
76 ret=$?
77 if [ $ret -ne 0 ]; then
78 echo "FAILED: zfs destroy filesystem $fs failed, exit code=$ret"
79 zpool destroy ${POOL}
80 rm ${VDEV0} ${VDEV1}
81 exit 1
82 fi
83 done
84
85 zpool destroy ${POOL}
86 ret=$?
87 if [ $ret -ne 0 ]; then
88 echo "FAILED: zpool destroy failed, exit code=$ret"
89 #
90 # destroy failed, try to clean up, but this
91 # wil probably fail
92 #
93 rm ${VDEV0} ${VDEV1}
94 exit 1
95 fi
96
97 rm ${VDEV0} ${VDEV1}
98 echo "PASSED"
99 exit 0