-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorrect_and_time.sh
executable file
·233 lines (205 loc) · 7.03 KB
/
correct_and_time.sh
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/bin/bash
#!/bin/bash
#!/bin/bash
if [ $# != 2 ]; then
echo "usage: bash correct.sh <file_size> <prime>"
exit 1
fi
file_size=$1
index_1=0
index_2=0
prime=$2
#生成测试文件
mkdir ./test_data
dd if=/dev/urandom of=./test_data/data bs=$file_size count=1 iflag=fullblock
#编译时间测试程序
#测试write模块时间
./time_check write ./test_data/data $prime
rm -rf disk*
#测试evenodd正确性
./evenodd write ./test_data/data $prime
## test two files failed
### case 1:
echo "============================"
let "index_1=prime"
let "index_2=prime+1"
mv disk_$index_1 _disk_$index_1
mv disk_$index_2 _disk_$index_2
./evenodd read ./test_data/data ./test_data/data_read
result=`diff ./test_data/data ./test_data/data_read`
if [ -n "$result" ]
then
echo "删除掉disk_${index_1}和disk_${index_2} read失败" >> error_log.txt
echo "此时素数取值为:$prime 文件大小为: ${file_size}B" >> error_log.txt
echo "$result" >> error_log.txt
echo "===============================================" >> error_log.txt
else
rm -rf ./test_data/data_read
./time_check read ./test_data/data ./test_data/data_read
fi
mv _disk_$index_1 disk_$index_1
mv _disk_$index_2 disk_$index_2
rm -rf ./test_data/data_read
echo ====================================
# ### case 2:
let "index_1=prime-2"
let "index_2=prime"
mv disk_$index_1 _disk_$index_1
mv disk_$index_2 _disk_$index_2
./evenodd read ./test_data/data ./test_data/data_read
result=`diff ./test_data/data ./test_data/data_read`
if [ -n "$result" ]
then
echo "删除掉disk_${index_1}和disk_${index_2} read失败" >> error_log.txt
echo "此时素数取值为:$prime 文件大小为: ${file_size}B" >> error_log.txt
echo "$result" >> error_log.txt
echo "==============================================" >> error_log.txt
else
rm -rf ./test_data/data_read
./time_check read ./test_data/data ./test_data/data_read
fi
mv _disk_$index_1 disk_$index_1
mv _disk_$index_2 disk_$index_2
rm -rf ./test_data/data_read
echo ====================================
# ### case 3:
let "index_1=prime-1"
let "index_2=prime+1"
mv disk_$index_1 _disk_$index_1
mv disk_$index_2 _disk_$index_2
./evenodd read ./test_data/data ./test_data/data_read
result=`diff ./test_data/data ./test_data/data_read`
if [ -n "$result" ]
then
echo "删除掉disk_${index_1}和disk_${index_2} read失败" >> error_log.txt
echo "此时素数取值为:$prime 文件大小为: ${file_size}B" >> error_log.txt
echo "$result" >> error_log.txt
echo "===============================================" >> error_log.txt
else
rm -rf ./test_data/data_read
./time_check read ./test_data/data ./test_data/data_read
fi
mv _disk_$index_1 disk_$index_1
mv _disk_$index_2 disk_$index_2
rm -rf ./test_data/data_read
echo ====================================
# ### case 4:
let "index_1=prime-2"
let "index_2=prime-1"
mv disk_$index_1 _disk_$index_1
mv disk_$index_2 _disk_$index_2
./evenodd read ./test_data/data ./test_data/data_read
result=`diff ./test_data/data ./test_data/data_read`
if [ -n "$result" ]
then
echo "删除掉disk_${index_1}和disk_${index_2} read失败" >> error_log.txt
echo "此时素数取值为:$prime 文件大小为: ${file_size}B" >> error_log.txt
echo "$result" >> error_log.txt
echo "===============================================" >> error_log.txt
else
rm -rf ./test_data/data_read
./time_check read ./test_data/data ./test_data/data_read
fi
mv _disk_$index_1 disk_$index_1
mv _disk_$index_2 disk_$index_2
rm -rf ./test_data/data_read
echo ====================================
# ### case 5:
let "index_1=prime-2"
let "index_2=prime-3"
mv disk_$index_1 _disk_$index_1
mv disk_$index_2 _disk_$index_2
./evenodd read ./test_data/data ./test_data/data_read
result=`diff ./test_data/data ./test_data/data_read`
if [ -n "$result" ]
then
echo "删除掉disk_${index_1}和disk_${index_2} read失败" >> error_log.txt
echo "此时素数取值为:$prime 文件大小为: ${file_size}B" >> error_log.txt
echo "$result" >> error_log.txt
echo "===============================================" >> error_log.txt
else
rm -rf ./test_data/data_read
./time_check read ./test_data/data ./test_data/data_read
fi
mv _disk_$index_1 disk_$index_1
mv _disk_$index_2 disk_$index_2
rm -rf ./test_data/data_read
echo ====================================
rm -rf disk*
rm -rf test*
# for ((i=1;i<=test_number;i++))
# do
# #生成测试文件
# let "file_size = skip * 1024"
# mkdir ./test_data_"$skip"_KB
# dd if=/dev/urandom of=./test_data_"$skip"_KB/data bs=$file_size count=1 iflag=fullblock
# ## test two files failed
# ### case 1:
# echo "============================"
# ./evenodd write ./test_data_"$skip"_KB/data $prime
# let "index_1=prime"
# let "index_2=prime+1"
# mv disk_$index_1 _disk_$index_1
# mv disk_$index_2 _disk_$index_2
# ./evenodd read ./test_data_"$skip"_KB/data ./test_data_"$skip"_KB/data_read
# result=`diff ./test_data_"$skip"_KB/data ./test_data_"$skip"_KB/data_read`
# if [ -n "$result" ]
# then
# echo "素数取值为:$prime 文件大小为: ${skip}KB"
# echo "修复失败"
# #exit 1
# fi
# mv _disk_$index_1 disk_$index_1
# mv _disk_$index_2 disk_$index_2
# #rm -rf ./test_data_"$skip"_KB/data_read
# echo ====================================
# # # ### case 2:
# # # echo "============================"
# # mv disk_3 _disk_3
# # mv disk_54 _disk_54
# # ./evenodd read ./test_data_"$skip"_KB/data ./test_data_"$skip"_KB/data_read
# # result=`diff ./test_data_"$skip"_KB/data ./test_data_"$skip"_KB/data_read`
# # if [ -n "$result" ]
# # then
# # echo "修复失败"
# # exit 1
# # fi
# # mv _disk_3 disk_3
# # mv _disk_54 disk_54
# # rm -rf ./test_data_"$skip"_KB/data_read
# # # ### case 3:
# # # echo "============================"
# # mv disk_4 _disk_4
# # mv disk_53 _disk_53
# # ./evenodd read ./test_data_"$skip"_KB/data ./test_data_"$skip"_KB/data_read
# # result=`diff ./test_data_"$skip"_KB/data ./test_data_"$skip"_KB/data_read`
# # if [ -n "$result" ]
# # then
# # echo "修复失败"
# # exit 1
# # fi
# # mv _disk_4 disk_4
# # mv _disk_53 disk_53
# # rm -rf ./test_data_"$skip"_KB/data_read
# # # ### case 4:
# # # echo "============================"
# # mv disk_0 _disk_0
# # mv disk_6 _disk_6
# # ./evenodd read ./test_data_"$skip"_KB/data ./test_data_"$skip"_KB/data_read
# # result=`diff ./test_data_"$skip"_KB/data ./test_data_"$skip"_KB/data_read`
# # if [ -n "$result" ]
# # then
# # echo "修复失败"
# # exit 1
# # fi
# # mv _disk_0 disk_0
# # mv _disk_6 disk_6
# # rm -rf ./test_data_"$skip"_KB/data_read
# # # ./evenodd write ./test_data_"$skip"_KB/data 5
# # # echo test_file_name:./test_data_"$skip"_KB/data
# # # echo test_file_size:$file_size
# # # echo test_prime:7
# let "skip = skip * 8"
# #rm -rf test_data*
# #rm -rf disk*
# done