File: kernel-smoke-test

package info (click to toggle)
zfs-linux 2.3.2-2
  • links: PTS, VCS
  • area: contrib
  • in suites: trixie
  • size: 71,496 kB
  • sloc: ansic: 392,648; sh: 67,208; asm: 47,693; python: 8,160; makefile: 5,100; perl: 839; sed: 41
file content (121 lines) | stat: -rwxr-xr-x 2,728 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/sh 
#
# Copyright (C) 2016 Canonical
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
# We run all the tests in this specific order from this
# main script so that we don't have to go through the
# pain of checking and rebuilding installing and removing
# the modules for each test.  A good smoke test will
# exercise all the base functionality with the same
# instance of the ZFS spl and zfs drivers to see what
# the cumulative testing of each scenario does to the
# environment.
#
LSMOD=/sbin/lsmod
RMMOD=/sbin/rmmod
MODPROBE=/sbin/modprobe
TESTS="
kernel-smoke-test-pool-striped
kernel-smoke-test-pool-mirror
kernel-smoke-test-pool-raidz
kernel-smoke-test-pool-nested-raidz3
kernel-smoke-test-pool-draid
kernel-smoke-test-zil
kernel-smoke-test-filesystem
kernel-smoke-test-snapshot
kernel-smoke-test-clone
kernel-smoke-test-send-receive
kernel-smoke-test-scrub
kernel-smoke-test-encryption"
rc=0
#
#  We only test on 64 bit arches for the moment
#  as these are the ones that ZFS supports.
#
if [ `getconf LONG_BIT` = "32" ]
then
	echo "Testing on 32 bit architectures not possible."
	exit 0
fi

#
#  Remove a module if it is loaded
#
rm_mod()
{
	loaded=$($LSMOD | grep "^$1")
	if [ ! -z "$loaded" ]; then
		echo "Unloading $1"
		$RMMOD $1
	fi
}

#
#  Recursively find module dependencies and remove these modules
#
rm_mod_dep()
(
	mod=$1
	n=0
	deps=""

	while true
	do
		deps=$($LSMOD | grep "^$mod" | awk '{ print $4 }' | tr ',' ' ')
		if [ -z "$deps" ]; then
			rm_mod $mod
			return 0
		else
			for dep in $deps
			do
				rm_mod_dep $dep
				if [ $? -ne 0 ]; then
					return 1
				fi
			done
		fi
		n=$((n + 1))
		if [ $n -gt 20 ]; then
			echo "Cannot remove $mod or a dependency module $deps"
			return 1
		fi
	done
	return 0
)

#
#  need to stop zed to remove previous zfs
#
systemctl stop zfs-zed.service

echo "Removing existing zfs modules"
rm_mod_dep zfs
rm_mod_dep spl

# Load zfs kernel module before tests
echo "Loading new zfs modules"
$MODPROBE zfs

for t in ${TESTS}
do
	./debian/tests/$t
	if [ $? -ne 0 ]; then
		rc=1
	fi
done
exit $rc