-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·109 lines (92 loc) · 2.75 KB
/
run.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
#!/bin/bash
# subtasks=( "G1" "G2" "G3" "tests" "tests-ours" )
# scores=( 10 20 30 60 40)
mkdir -p out
mkdir -p report
cd ./tests
prefix="" ;
score=0;
dirlist=(`ls`) ;
OUTPUT_DIRECTORY="out/"
TEST_DIRECTORY="tests/"
REPORT_DIRECTORY="report/"
SOURCE_DIRECTORY="src/"
cd ../
touch wrongs
rm wrongs
touch wrongs
for folder in ${dirlist[*]}
do
NUMBER_OF_PASSED=0
NUMBER_OF_FAILED=0
echo "Subtask $folder -------------------------------------"
cd ./out
mkdir -p $folder
cd ../report
mkdir -p $folder
cd ..
cd ./tests
cd $folder
testlist=(`ls ${prefix}*.d`);
cd ../../
for filelist in ${testlist[*]}
do
filename=`echo $filelist | cut -d'.' -f1`;
output_filename="$filename.out"
output_asm="$filename.s"
program_input="$filename.in"
report_filename="$filename.report.txt"
echo "Running Test $filename -------------------------------------"
if command -v python3; then
python3 "$SOURCE_DIRECTORY/main.py" -i "$TEST_DIRECTORY/$folder/$filelist" -o "$OUTPUT_DIRECTORY/$folder/$output_asm"
else
python "$SOURCE_DIRECTORY/main.py" -i "$TEST_DIRECTORY/$folder/$filelist" -o "$OUTPUT_DIRECTORY/$folder/$output_asm"
fi
if [ $? -eq 0 ]; then
echo "MIPS Generated Successfuly!"
spim -a -f "$OUTPUT_DIRECTORY$folder/$output_asm" < "$TEST_DIRECTORY$folder/$program_input" > "$OUTPUT_DIRECTORY$folder/$output_filename"
if [ $? -eq 0 ]; then
echo "Code Executed Successfuly!"
if command -v python3; then
python3 comp.py -a "$OUTPUT_DIRECTORY$folder/$output_filename" -b "$TEST_DIRECTORY$folder/$output_filename" -o "$REPORT_DIRECTORY$folder/$report_filename"
else
python comp.py -a "$OUTPUT_DIRECTORY$folder/$output_filename" -b "$TEST_DIRECTORY$folder/$output_filename" -o "$REPORT_DIRECTORY$folder/$report_filename"
fi
if [[ $? = 0 ]]; then
((NUMBER_OF_PASSED++))
echo "++++ test passed"
else
((NUMBER_OF_FAILED++))
echo "---- test failed !"
echo "$folder/$filename" >> wrongs
echo
fi
fi
else
echo "Code did not execute successfuly!"
((NUMBER_OF_FAILED++))
echo "$folder/$filename" >> wrongs
fi
done
echo "Passed : $NUMBER_OF_PASSED"
echo "Failed : $NUMBER_OF_FAILED"
# echo "Subtask score: "
# len=${#subtasks[@]}
# for (( i=0; i<$len; i++ ))
# do
# if [[ "${subtasks[$i]}" == "$folder" ]]; then
# subtask_score=$(${scores[$i]}*$NUMBER_OF_PASSED/($NUMBER_OF_PASSED + $NUMBER_OF_FAILED));
# echo $subtask_score;
# (( score+= ${scores[$i]}*$NUMBER_OF_PASSED/($NUMBER_OF_PASSED + $NUMBER_OF_FAILED)));
# fi
# done
((total_passed+=$NUMBER_OF_PASSED))
((total_failed+=$NUMBER_OF_FAILED))
echo "Subtask $folder done ------------------------------"
echo $'\n\n'
done
echo "Final score: "
# echo "$score"
echo "Passed : $total_passed"
echo "Failed : $total_failed"
cat wrongs