]> git.proxmox.com Git - mirror_zfs-debian.git/blame - debian/tests/kernel-smoke-test-send-receive
Add isolation-machine restriction to autopkgtest.
[mirror_zfs-debian.git] / debian / tests / kernel-smoke-test-send-receive
CommitLineData
a99554ab
AX
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#
19echo -n "kernel smoke test, ZFS send and receive: "
20TMP=/tmp
21VDEV0=${TMP}/pool0-$$.img
22VDEV1=${TMP}/pool1-$$.img
23POOL=pool-smoke-$$
24SNAP=${TMP}/snapshot-$$.zfs
25DATA=/${POOL}/test/data
26
27dd if=/dev/zero of=${VDEV0} bs=1M count=512 > /dev/null 2>&1
28dd if=/dev/zero of=${VDEV1} bs=1M count=512 > /dev/null 2>&1
29
30zpool create ${POOL} ${VDEV0} ${VDEV1}
31ret=$?
32if [ $ret -ne 0 ]; then
33 echo "FAILED: zpool create failed, exit code=$ret"
34 rm ${VDEV0} ${VDEV1}
35 exit 1
36fi
37
38zfs create ${POOL}/test
39ret=$?
40if [ $ret -ne 0 ]; then
41 echo "FAILED: zfs create failed, exit code=$ret"
42 zpool destroy ${POOL}
43 rm ${VDEV0} ${VDEV1}
44 exit 1
45fi
46
47#
48# Populate with files..
49#
50cp -rp /etc /${POOL}/test
51dd if=/dev/urandom of=${DATA} bs=1M count=64 > /dev/null 2>&1
52sum1=$(md5sum ${DATA} | awk '{print $1}')
53
54#
55# Make a snapshot
56#
57zfs snapshot -r ${POOL}/test@snap
58ret=$?
59if [ $ret -ne 0 ]; then
60 echo "FAILED: zfs snapshot failed, exit code=$ret"
61 zpool destroy ${POOL}
62 rm ${VDEV0} ${VDEV1}
63 exit 1
64fi
65
66#
67# Make snapshot
68#
69zfs send ${POOL}/test@snap > ${SNAP}
70
71rm -rf ${POOL}/test
72
73zfs destroy ${POOL}/test@snap
74ret=$?
75if [ $ret -ne 0 ]; then
76 echo "FAILED: zfs destroy snapshot failed, exit code=$ret"
77 zpool destroy ${POOL}
78 rm ${VDEV0} ${VDEV1}
79 exit 1
80fi
81
82#
83# Receive it back..
84#
85zfs receive -F ${POOL}/test < ${SNAP}
86
87sum2=$(md5sum ${DATA} | awk '{print $1}')
88if [ x"$sum1" != x"$sum2" ]; then
89 echo "FAILED: received data different from original"
90 zpool destroy ${POOL}
91 rm ${VDEV0} ${VDEV1}
92 exit 1
93fi
94
95zpool destroy ${POOL}
96ret=$?
97if [ $ret -ne 0 ]; then
98 echo "FAILED: zpool destroy failed, exit code=$ret"
99 #
100 # destroy failed, try to clean up, but this
101 # wil probably fail
102 #
103 rm ${VDEV0} ${VDEV1}
104 exit 1
105fi
106
107rm ${VDEV0} ${VDEV1}
108echo "PASSED"
109exit 0