Browse Source

Unmount the filesystem if the test fails halfway.

Peter Pentchev 13 years ago
parent
commit
d88b0155cb
1 changed files with 34 additions and 26 deletions
  1. 34
    26
      test.sh

+ 34
- 26
test.sh View File

@@ -2,31 +2,39 @@
2 2
 
3 3
 set -e
4 4
 
5
+dotest()
6
+{
7
+	cat testmnt.txt
8
+	head -c 20 testmnt.txt
9
+	tail -c 20 testmnt.txt
10
+	head -c 160 testmnt.txt | tail -n 1
11
+	echo
12
+
13
+	cnt1=`wc -c test1 | (read a b; echo "$a")`
14
+	if ! expr "x$cnt1" : 'x[0-9][0-9]*$' > /dev/null; then
15
+		echo 'Could not count the characters in the test1 file'
16
+		exit 1
17
+	fi
18
+	cnt2=`wc -c test2 | (read a b; echo "$a")`
19
+	if ! expr "x$cnt2" : 'x[0-9][0-9]*$' > /dev/null; then
20
+		echo 'Could not count the characters in the test1 file'
21
+		exit 1
22
+	fi
23
+	cnt3=`wc -c test3 | (read a b; echo "$a")`
24
+	if ! expr "x$cnt3" : 'x[0-9][0-9]*$' > /dev/null; then
25
+		echo 'Could not count the characters in the test1 file'
26
+		exit 1
27
+	fi
28
+
29
+	head -c "$cnt1" testmnt.txt | diff -u test1 -
30
+	tail -c "$cnt3" testmnt.txt | diff -u test3 -
31
+	cat test1 test2 test3 | diff -u - testmnt.txt
32
+}
33
+
34
+rm -f testmnt.txt
35
+res=0
5 36
 ./mount.sh
6
-cat testmnt.txt
7
-head -c 20 testmnt.txt
8
-tail -c 20 testmnt.txt
9
-head -c 160 testmnt.txt | tail -n 1
10
-echo
11
-
12
-cnt1=`wc -c test1 | (read a b; echo "$a")`
13
-if ! expr "x$cnt1" : 'x[0-9][0-9]*$' > /dev/null; then
14
-	echo 'Could not count the characters in the test1 file'
15
-	exit 1
16
-fi
17
-cnt2=`wc -c test2 | (read a b; echo "$a")`
18
-if ! expr "x$cnt2" : 'x[0-9][0-9]*$' > /dev/null; then
19
-	echo 'Could not count the characters in the test1 file'
20
-	exit 1
21
-fi
22
-cnt3=`wc -c test3 | (read a b; echo "$a")`
23
-if ! expr "x$cnt3" : 'x[0-9][0-9]*$' > /dev/null; then
24
-	echo 'Could not count the characters in the test1 file'
25
-	exit 1
26
-fi
27
-
28
-head -c "$cnt1" testmnt.txt | diff -u test1 -
29
-tail -c "$cnt3" testmnt.txt | diff -u test3 -
30
-cat test1 test2 test3 | diff -u - testmnt.txt
31
-
37
+(dotest) || res=$?
32 38
 ./umount.sh
39
+rm -f testmnt.txt
40
+exit "$res"

Loading…
Cancel
Save