Browse Source

test: Rewrite tests.

Georgi Chorbadzhiyski 12 years ago
parent
commit
e852616bff
8 changed files with 71 additions and 36 deletions
  1. 3
    0
      test/expect_1
  2. 1
    0
      test/expect_2
  3. 2
    0
      test/expect_3
  4. 2
    0
      test/expect_4
  5. 0
    0
      test/filelist.txt
  6. 0
    4
      test/mount.sh
  7. 63
    29
      test/test.sh
  8. 0
    3
      test/umount.sh

+ 3
- 0
test/expect_1 View File

1
+12345678901234567890123456789012345678901234567890123456789012345678901234567890
2
+abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij
3
+09876543210987654321098765432109876543210987654321098765432109876543210987654321

+ 1
- 0
test/expect_2 View File

1
+abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij

+ 2
- 0
test/expect_3 View File

1
+12345678901234567890123456789012345678901234567890123456789012345678901234567890
2
+abcdefghijabcdefghijabcdefghijabcdefghi

+ 2
- 0
test/expect_4 View File

1
+cdefghijabcdefghijabcdefghijabcdefghij
2
+09876543210987654321098765432109876543210987654321098765432109876543210987654321

test/test.txt → test/filelist.txt View File


+ 0
- 4
test/mount.sh View File

1
-#!/bin/sh
2
-
3
-../fjfs testmnt.txt test.txt
4
-

+ 63
- 29
test/test.sh View File

1
 #!/bin/sh
1
 #!/bin/sh
2
 
2
 
3
-set -e
3
+mount1_fjfs() {
4
+	echo "Using filelist.txt as input."
5
+	../fjfs --file mount-point filelist.txt
6
+}
4
 
7
 
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
8
+mount2_fjfs() {
9
+	echo "Using glob 'test?' as input."
10
+	../fjfs --glob mount-point 'test?'
11
+}
12
+
13
+mount3_fjfs() {
14
+	echo "Using args 'test1 test2 test3' as input."
15
+	../fjfs --args mount-point test1 test2 test3
16
+}
17
+
18
+umount_fjfs() {
19
+	fusermount -u mount-point && rm mount-point
11
 	echo
20
 	echo
21
+}
12
 
22
 
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
23
+do_tests() {
24
+	# Direct compare
25
+	diff -u expect_1 mount-point
26
+	if [ $? = 0 ]
27
+	then
28
+		echo "test 1: OK"
29
+	else
30
+		echo "test 1: FAIL!"
17
 	fi
31
 	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 test2 file'
21
-		exit 1
32
+
33
+	head -n2 mount-point | tail -n1 > result_2
34
+	diff -u expect_2 result_2
35
+	if [ $? = 0 ]
36
+	then
37
+		echo "test 2: OK"
38
+	else
39
+		echo "test 2: FAIL!"
22
 	fi
40
 	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 test3 file'
26
-		exit 1
41
+	rm result_2
42
+
43
+	head -c 120 mount-point > result_3
44
+	diff -u expect_3 result_3
45
+	if [ $? = 0 ]
46
+	then
47
+		echo "test 3: OK"
48
+	else
49
+		echo "test 3: FAIL!"
27
 	fi
50
 	fi
51
+	rm result_3
28
 
52
 
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
53
+	tail -c 120 mount-point > result_4
54
+	diff -u expect_4 result_4
55
+	if [ $? = 0 ]
56
+	then
57
+		echo "test 4: OK"
58
+	else
59
+		echo "test 4: FAIL!"
60
+	fi
61
+	rm result_4
32
 }
62
 }
33
 
63
 
34
-rm -f testmnt.txt
35
-res=0
36
-./mount.sh
37
-(dotest) || res=$?
38
-./umount.sh
39
-rm -f testmnt.txt
40
-exit "$res"
64
+mount1_fjfs
65
+do_tests
66
+umount_fjfs
67
+
68
+mount2_fjfs
69
+do_tests
70
+umount_fjfs
71
+
72
+mount3_fjfs
73
+do_tests
74
+umount_fjfs

+ 0
- 3
test/umount.sh View File

1
-#!/bin/sh
2
-
3
-fusermount -u testmnt.txt && rm testmnt.txt

Loading…
Cancel
Save