-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomp_correct.sh
37 lines (33 loc) · 928 Bytes
/
comp_correct.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
# $1: Number of total operation
# $2: M, all the values generated will be in [1, M], and M must <= 1e6
# $3: name of the first compared obj
# $4: name of the second compared obj
# Files
SRC_DIR=src
BIN_DIR=bin
DATA_DIR=data
# Executable
Tar_datagen=$BIN_DIR/datagen.run
Tar_1=$BIN_DIR/$3.run
Tar_2=$BIN_DIR/$4.run
# Main routine
cnt=0
while [ 1 ]
do
let cnt+=1
# Step 1: generate correspond input data
./$Tar_datagen $1 $2 > $DATA_DIR/in.in
# Step 2: feed the data into two programs
./$Tar_1 < $DATA_DIR/in.in > $DATA_DIR/1.out
./$Tar_2 < $DATA_DIR/in.in > $DATA_DIR/2.out
# Step 3: compare the output of two programs
cmp -s $DATA_DIR/1.out $DATA_DIR/2.out
cmp_=$?
if [ $cmp_ -eq 0 ]
then
echo Round No.$cnt Test passed!
else
echo Round No.$cnt Test failed, please check the difference between $DATA_DIR/1.out and $DATA_DIR/2.out
break
fi
done