-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-gen.lib
70 lines (62 loc) · 1.96 KB
/
test-gen.lib
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
#!/bin/sh
# These routines contain the filesystem generation code.
# This code is sourced by the other scripts so that digest
# generation is consistent.
LC_ALL=C
export LC_ALL
test_dir=t_tmp_dir
test_img=t_tmp_ext2.img
gen_cleanup () {
rm -r $test_dir $test_img
}
calc_digest () {
digest=`md5sum $test_img 2>/dev/null | cut -f 1 -d " "`
if [ x$digest != x ] ; then
echo $digest
else
digest=`md5 $test_img 2>/dev/null | cut -f 4 -d " "`
echo $digest
fi
}
# dgen - Exercises the -d option of genext2fs.
# Creates an image with a file of given size.
dgen () {
blocks=$1; blocksz=$2; size=$3
echo Testing $blocks blocks of $blocksz bytes with file of size $size
mkdir $test_dir || exit 1
cd $test_dir
if [ x$size = x0 ]; then
> file.$size
else
dd if=/dev/zero of=file.$size bs=$size count=1 2>/dev/null
fi
chmod 777 file.$size
TZ=UTC-11 touch -t 200502070321.43 file.$size .
cd ..
./genext2fs -B $blocksz -N 17 -b $blocks -d $test_dir -f -o Linux -q $test_img
}
# fgen - Exercises the -D option of genext2fs.
# Creates an image with the devices listed in the given spec file.
fgen () {
blocks=$1; fname=$3
echo Testing $blocks blocks with with devices file $fname
mkdir $test_dir || exit 1
cp $fname $test_dir
TZ=UTC-11 touch -t 200502070321.43 $test_dir/$fname
./genext2fs -N 92 -b $blocks -D $test_dir/$fname -f -o Linux $test_img
}
# lgen - Exercises the -d option of genext2fs, with symlink.
# Creates an image with a symlink of variable length.
# NB: some systems including early versions of Mac OS X cannot
# change symlink timestamps; this test will fail on those systems.
lgen () {
blocks=$1; blocksz=$2; appendage=$3
echo Testing $blocks blocks of $blocksz bytes with symlink ...$appendage
mkdir $test_dir || exit 1
cd $test_dir
target=12345678901234567890123456789012345678901234567890$appendage
ln -s $target symlink
TZ=UTC-11 touch -h -t 201309241353.59 symlink .
cd ..
./genext2fs -B $blocksz -N 234 -b $blocks -d $test_dir -f -o Linux -q $test_img
}