~ubuntu-branches/ubuntu/precise/ecryptfs-utils/precise-security

« back to all changes in this revision

Viewing changes to tests/run_tests.sh

  • Committer: Package Import Robot
  • Author(s): Dustin Kirkland, Dustin Kirkland, Tyler Hicks, Eddie Garcia, Colin King
  • Date: 2012-02-16 14:22:09 UTC
  • mfrom: (1.1.41)
  • Revision ID: package-import@ubuntu.com-20120216142209-n1r1a7dwbbq49xzs
Tags: 96-0ubuntu1
[ Dustin Kirkland ]
* CONTRIBUTING:
  - added a new file to describe how to contribute to ecryptfs
* === added directory img/old, img/old/ecryptfs_14.png,
  img/old/ecryptfs_192.png, img/old/ecryptfs_64.png:
  - saving the old logos/branding for posterity
* debian/copyright, img/COPYING:
  - added CC-by-SA 3.0 license
  - use the text version
* img/ecryptfs_14.png, img/ecryptfs_192.png, img/ecryptfs_64.png:
  - added scaled copies of images used for Launchpad.net branding
* src/utils/ecryptfs-recover-private: LP: #847505
  - add an option to allow user to enter the mount passphrase,
    in case they've recorded that, but forgotten their login
    passphrase
* src/libecryptfs/sysfs.c: LP: #802197
  - default sysfs to /sys, if not found in /etc/mtab
  - it seems that reading /etc/mtab for this is outdated
  - ensure that ecryptfs works even if there is no sysfs entry
    in /etc/mtab
* src/key_mod/ecryptfs_key_mod_tspi.c: LP: #462225
  - fix TPM and string_to_uuid 64bits issue
  - thanks to Janos for the patch
* precise

[ Tyler Hicks ]
* CONTRIBUTING:
  - clarified how to contribute to the ecryptfs kernel module
* tests/lib/etl_funcs.sh:
  - created eCryptfs test library of bash functions for use in test
    cases and test harnesses
* test/etl_add_passphrase_key_to_keyring.c:
  - created a C helper program to allow bash scripts to interface to
    the libecryptfs function that adds passphrase-based keys to the
    kernel keyring
* tests/kernel/tests.rc, tests/userspace/tests.rc:
  - created a test case category files for test harnesses to source
    when running testcases of a certain category (destructive, safe,
    etc.)
* tests/run_tests.sh:
  - created a test harness to run eCryptfs test cases
* tests/kernel/miscdev-bad-count.sh,
  tests/kernel/miscdev-bad-count/test.c:
  - created test case for miscdev issue reported to mailing list
* tests/kernel/lp-885744.sh:
  - created test case for pathconf bug
* tests/kernel/lp-926292.sh:
  - created test case for checking stale inode attrs after setxattr
* tests/new.sh:
  - created new test case template to copy from
* tests/userspace/verify-passphrase-sig.sh,
  tests/userspace/verify-passphrase-sig/test.c:
  - created test case, for make check, to test the creation of
    passphrase-based fekeks and signatures
* configure.ac, Makefile.am, tests/Makefile.am, tests/lib/Makefile.am,
  tests/kernel/Makefile.am, tests/userspace/Makefile.am:
  - updated and created autoconf/automake files to build the new tests
    directory
  - added make check target

[ Eddie Garcia ]
* img/*: LP: #907131
  - contributing a new set of logos and branding under the CC-by-SA3.0
    license

[ Colin King ]
* tests/kernel/extend-file-random.sh,
  tests/kernel/extend-file-random/test.c:
  - Test to randomly extend file size, read/write + unlink
* tests/kernel/trunc-file.sh, tests/kernel/trunc-file/test.c:
  - Test to exercise file truncation
* tests/kernel/directory-concurrent.sh,
  tests/kernel/directory-concurrent/test.c:
  - test for directory creation/deletion races with multiple processes
* tests/kernel/file-concurrent.sh,
  tests/kernel/file-concurrent/test.c:
  - test for file creation/truncation/unlink races with multiple
    processes
* tests/kernel/inotify.sh, tests/kernel/inotify/test.c:
  - test for proper inotify support
* tests/kernel/mmap-dir.sh, tests/kernel/mmap-dir/test.c:
  - test that directory files cannot be mmap'ed
* tests/kernel/read-dir.sh, tests/kernel/read-dir/test.c:
  - test that read() on directory files returns the right error
* tests/kernel/setattr-flush-dirty.sh:
  - test that the modified timestamp isn't clobbered in writeback
* tests/kernel/inode-race-stat.sh, tests/kernel/inode-race-stat/test.c:
  - test for inode initialization race condition

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# eCryptfs test suite harness
 
4
# Author: Tyler Hicks <tyhicks@canonical.com>
 
5
#
 
6
# Copyright (C) 2012 Canonical, Ltd.
 
7
#
 
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.
 
12
#
 
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.
 
17
#
 
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
 
21
#
 
22
# Example usage:
 
23
#
 
24
# # ./tests/run_tests.sh -K -c destructive -d /dev/vdb -l /lower -u /upper
 
25
#
 
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
 
29
# be /upper.
 
30
#
 
31
 
 
32
run_tests_dir=$(dirname $0)
 
33
rc=1
 
34
 
 
35
. ${run_tests_dir}/lib/etl_funcs.sh
 
36
 
 
37
blocks=0
 
38
categories=""
 
39
device=""
 
40
disk_dir=""
 
41
failed=0
 
42
kernel=false
 
43
ktests=""
 
44
lower_fs=""
 
45
lower_mnt=""
 
46
passed=0
 
47
upper_mnt=""
 
48
userspace=false
 
49
utests=""
 
50
 
 
51
run_tests_cleanup()
 
52
{
 
53
        etl_remove_disk
 
54
        exit $rc
 
55
}
 
56
trap run_tests_cleanup 0 1 2 3 15
 
57
 
 
58
run_tests()
 
59
{
 
60
        test_dir=$1
 
61
        tests=$2
 
62
 
 
63
        for etest in $tests; do
 
64
                printf "%-16s\t" $(basename "$etest" .sh)
 
65
 
 
66
                ${test_dir}/${etest}
 
67
                if [ $? -ne 0 ]; then
 
68
                        ((failed++))
 
69
                        printf "FAIL\n"
 
70
                else
 
71
                        ((passed++))
 
72
                        printf "pass\n"
 
73
                fi
 
74
        done
 
75
}
 
76
 
 
77
usage()
 
78
{
 
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"
 
81
        echo
 
82
        echo "eCryptfs test harness"
 
83
        echo
 
84
        echo "  -b blocks       number of 1K blocks used when creating backing "
 
85
        echo "          disk for lower filesystem (not compatible "
 
86
        echo "          with -d)"
 
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"
 
98
}
 
99
 
 
100
while getopts "b:c:D:d:f:hKl:Uu:" opt; do
 
101
        case $opt in
 
102
        b)
 
103
                blocks=$OPTARG
 
104
                ;;
 
105
        c)
 
106
                categories=$OPTARG
 
107
                ;;
 
108
        d)
 
109
                device=$OPTARG
 
110
                ;;
 
111
        D)
 
112
                disk_dir=$OPTARG
 
113
                ;;
 
114
        f)
 
115
                lower_fs=$OPTARG
 
116
                ;;
 
117
        h)
 
118
                usage
 
119
                rc=0
 
120
                exit
 
121
                ;;
 
122
        K)
 
123
                kernel=true
 
124
                ;;
 
125
        l)
 
126
                lower_mnt=$OPTARG
 
127
                ;;
 
128
        U)
 
129
                userspace=true
 
130
                ;;
 
131
        u)
 
132
                upper_mnt=$OPTARG
 
133
                ;;
 
134
        \?)
 
135
                usage 1>&2
 
136
                exit
 
137
                ;;
 
138
        :)
 
139
                usage 1>&2
 
140
                exit
 
141
                ;;
 
142
        esac
 
143
done
 
144
 
 
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
 
148
        usage 1>&2
 
149
        exit
 
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
 
153
        usage 1>&2
 
154
        exit
 
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
 
158
        usage 1>&2
 
159
        exit
 
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
 
163
        usage 1>&2
 
164
        exit
 
165
elif [ -z "$categories" ]; then
 
166
        # Lets not assume anything here
 
167
        echo "Must specify at least one or more test category" 1>&2
 
168
        usage 1>&2
 
169
        exit
 
170
elif ! $kernel && ! $userspace ; then
 
171
        # Must specify at least one of these
 
172
        echo "Must specify one of -U or -K" 1>&2
 
173
        usage 1>&2
 
174
        exit
 
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
 
178
        usage 1>&2
 
179
        exit
 
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
 
183
        usage 1>&2
 
184
        exit
 
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
 
188
        usage 1>&2
 
189
        exit
 
190
fi
 
191
 
 
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
 
197
 
 
198
if [ "$blocks" -gt 0 ]; then
 
199
        etl_create_disk $blocks $disk_dir
 
200
        if [ $? -ne 0 ]; then
 
201
                rc=1
 
202
                exit
 
203
        fi
 
204
        export ETL_LMOUNT_SRC=$ETL_DISK
 
205
fi
 
206
 
 
207
# Source in the kernel and/or userspace tests.rc files to build the test lists
 
208
categories=$(echo $categories | tr ',' ' ')
 
209
if $kernel ; then
 
210
        . ${run_tests_dir}/kernel/tests.rc
 
211
        for cat in $categories ; do
 
212
                eval cat_tests=\$$cat
 
213
                ktests="$ktests $cat_tests"
 
214
        done
 
215
 
 
216
        run_tests "${run_tests_dir}/kernel" "$ktests"
 
217
        if [ $? -ne 0 ]; then
 
218
                rc=1
 
219
                exit
 
220
        fi
 
221
fi
 
222
if $userspace ; then
 
223
        . ${run_tests_dir}/userspace/tests.rc
 
224
        for cat in $categories ; do
 
225
                eval cat_tests=\$$cat
 
226
                utests="$utests $cat_tests"
 
227
        done
 
228
 
 
229
        run_tests "${run_tests_dir}/userspace" "$utests"
 
230
        if [ $? -ne 0 ]; then
 
231
                rc=1
 
232
                exit
 
233
        fi
 
234
fi
 
235
 
 
236
echo ""
 
237
echo "Test Summary:"
 
238
echo "$passed passed"
 
239
echo "$failed failed"
 
240
 
 
241
rc=$failed
 
242
exit