1
1
#! /usr/bin/env bash
2
2
3
+ . script/test_large_file.sh
4
+
3
5
SIMPLEFS_MOD=simplefs.ko
4
6
IMAGE=$1
5
7
IMAGESIZE=$2
@@ -47,13 +49,6 @@ dd if=/dev/zero of=$IMAGE bs=1M count=$IMAGESIZE status=none && \
47
49
sudo mount -t simplefs -o loop $IMAGE test && \
48
50
pushd test > /dev/null
49
51
50
- # mkdir
51
- test_op ' mkdir dir'
52
- test_op ' mkdir dir' # expected to fail
53
-
54
- # create file
55
- test_op ' touch file'
56
-
57
52
# create 40920 files
58
53
for (( i= 0 ; i<= $MAXFILES ; i++ ))
59
54
do
98
93
fi
99
94
done
100
95
find . -name ' file_[0-9]*.txt' | xargs sudo rm || { echo " Failed to delete files" ; exit 1; }
96
+ sync
97
+
98
+ popd > /dev/null || { echo " popd failed" ; exit 1; }
99
+ ls test -laR
100
+ rm test/* -rf
101
+ nr_free_blk=$(( $(dd if= $IMAGE bs= 1 skip= 28 count= 4 2 >/ dev/ null | hexdump - v - e '1 / 4 "0 x% 08 x\n"')) )
102
+ echo " $nr_free_blk "
103
+ pushd test > /dev/null || { echo " pushd failed" ; exit 1; }
104
+
105
+ # mkdir
106
+ test_op ' mkdir dir'
107
+ test_op ' mkdir dir' # expected to fail
108
+
109
+ # create file
110
+ test_op ' touch file'
101
111
102
112
# hard link
103
113
test_op ' ln file hdlink'
@@ -119,21 +129,11 @@ test_op 'echo abc > file'
119
129
test $( cat file) = " abc" || echo " Failed to write"
120
130
121
131
# file too large
122
- test_op ' dd if=/dev/zero of=file bs=1M count=12 status=none'
123
- filesize=$( sudo ls -lR | grep -e " $F_MOD 2" .* file | awk ' {print $5}' )
124
- test $filesize -le $MAXFILESIZE || echo " Failed, file size over the limit"
132
+ test_too_large_file
125
133
126
134
# Write the file size larger than BLOCK_SIZE
127
135
# test serial to write
128
- test_op ' printf \"%.0s123456789\" {1..1600} > file.txt'
129
- count=$( awk ' {count += gsub(/123456789/, "")} END {print count}' " file.txt" )
130
- echo " test $count "
131
- test " $count " -eq 1600 || echo " Failed, file size not matching"
132
- # test block to write
133
- test_op ' cat file.txt > checkfile.txt'
134
- count=$( awk ' {count += gsub(/123456789/, "")} END {print count}' " checkfile.txt" )
135
- echo " test $count "
136
- test " $count " -eq 1600 || echo " Failed, file size not matching"
136
+ test_file_size_larger_than_block_size
137
137
138
138
# test remove symbolic link
139
139
test_op ' ln -s file symlink_fake'
@@ -152,7 +152,13 @@ check_exist $S_MOD 1 symlink
152
152
check_exist $F_MOD 1 symlink_fake
153
153
check_exist $F_MOD 1 symlink_hard_fake
154
154
155
+ # clean all files and directories
156
+ test_op ' rm -rf ./*'
157
+
155
158
sleep 1
156
159
popd > /dev/null
157
160
sudo umount test
158
161
sudo rmmod simplefs
162
+
163
+ af_nr_free_blk=$(( $(dd if= $IMAGE bs= 1 skip= 28 count= 4 2 >/ dev/ null | hexdump - v - e '1 / 4 "0 x% 08 x\n"')) )
164
+ test $nr_free_blk -eq $af_nr_free_blk || echo " Failed, some blocks are not be reclaimed"
0 commit comments