3
# eCryptfs test suite harness
4
# Author: Tyler Hicks <tyhicks@canonical.com>
6
# Copyright (C) 2012 Canonical, Ltd.
8
# This program is free software; you can redistribute it and/or
9
# modify it under the terms of the GNU General Public License
10
# as published by the Free Software Foundation; either version 2
11
# of the License, or (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24
# # ./tests/run_tests.sh -K -c destructive -d /dev/vdb -l /lower -u /upper
26
# This would run kernel tests in the destructive category, as defined in
27
# kernel/tests.rc. /dev/vdb would be the block device containing the lower
28
# filesystem, which would be mounted at /lower. The eCryptfs mount point would
32
run_tests_dir=$(dirname $0)
35
. ${run_tests_dir}/lib/etl_funcs.sh
56
trap run_tests_cleanup 0 1 2 3 15
63
for etest in $tests; do
64
printf "%-16s\t" $(basename "$etest" .sh)
79
echo "Usage: $(basename $0) [options] -K|-U -c categories -b blocks -l lower_mnt -u upper_mnt"
80
echo " or: $(basename $0) [options] -K|-U -c categories -d device -l lower_mnt -u upper_mnt"
82
echo "eCryptfs test harness"
84
echo " -b blocks number of 1K blocks used when creating backing "
85
echo " disk for lower filesystem (not compatible "
87
echo " -c categories test categories to run (destructive, ...)"
88
echo " -D disk_dir directory used to store created backing disk "
89
echo " when using -b (not compatible with -d)"
90
echo " -d device backing device to mount lower filesystem, such "
91
echo " as /dev/sdd3 (not compatible with -b)"
92
echo " -f lower_fs lower filesystem type (ext2, ext3, ext4)"
93
echo " -h display this help and exit"
94
echo " -K run tests relating to the kernel module"
95
echo " -l lower_mnt destination path to mount lower filesystem"
96
echo " -U run tests relating to the userspace utilities/"
97
echo " -u upper_mnt destination path to mount upper filesystem"
100
while getopts "b:c:D:d:f:hKl:Uu:" opt; do
145
if [ -z "$lower_mnt" ] || [ -z "$upper_mnt" ]; then
146
# Lower and upper mounts must be specified
147
echo "Lower and upper mounts must be specified" 1>&2
150
elif [ "$blocks" -lt 1 ] && [ -z "$device" ]; then
151
# Must specify blocks for disk creation *or* an existing device
152
echo "Blocks for disk creation or an existing device must be specified" 1>&2
155
elif [ "$blocks" -gt 0 ] && [ -n "$device" ]; then
156
# Can't specify blocks for disk creation *and* an existing device
157
echo "Cannot specify blocks for disk creation *and* also an existing device" 1>&2
160
elif [ -n "$disk_dir" ] && [ -n "$device" ]; then
161
# Can't specify a dir for disk creation and an existing device
162
echo "Cannot specify a directory for disk creation *and* also an existing device" 1>&2
165
elif [ -z "$categories" ]; then
166
# Lets not assume anything here
167
echo "Must specify at least one or more test category" 1>&2
170
elif ! $kernel && ! $userspace ; then
171
# Must specify at least one of these
172
echo "Must specify one of -U or -K" 1>&2
175
elif [ ! -d "$lower_mnt" ]; then
176
# A small attempt at making sure we're dealing with directories
177
echo "Lower mount point must exist" 1>&2
180
elif [ ! -d "$upper_mnt" ]; then
181
# A small attempt at making sure we're dealing with directories
182
echo "Upper mount point must exist" 1>&2
185
elif [ -n "$disk_dir" ] && [ ! -d "$disk_dir" ]; then
186
# A small attempt at making sure we're dealing with a directory
187
echo "Directory used to store created backing disk must exist" 1>&2
192
export ETL_LFS=$lower_fs
193
export ETL_LMOUNT_SRC=$device
194
export ETL_LMOUNT_DST=$lower_mnt
195
export ETL_MOUNT_SRC=$lower_mnt
196
export ETL_MOUNT_DST=$upper_mnt
198
if [ "$blocks" -gt 0 ]; then
199
etl_create_disk $blocks $disk_dir
200
if [ $? -ne 0 ]; then
204
export ETL_LMOUNT_SRC=$ETL_DISK
207
# Source in the kernel and/or userspace tests.rc files to build the test lists
208
categories=$(echo $categories | tr ',' ' ')
210
. ${run_tests_dir}/kernel/tests.rc
211
for cat in $categories ; do
212
eval cat_tests=\$$cat
213
ktests="$ktests $cat_tests"
216
run_tests "${run_tests_dir}/kernel" "$ktests"
217
if [ $? -ne 0 ]; then
223
. ${run_tests_dir}/userspace/tests.rc
224
for cat in $categories ; do
225
eval cat_tests=\$$cat
226
utests="$utests $cat_tests"
229
run_tests "${run_tests_dir}/userspace" "$utests"
230
if [ $? -ne 0 ]; then
238
echo "$passed passed"
239
echo "$failed failed"