-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.sh
executable file
·74 lines (54 loc) · 1.68 KB
/
test.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
printf "testing '$1'\n"
printf "testing python... "
ppp_file=$1
py_output=$(python3 $ppp_file 2>&1)
py_exit_code=$?
if [ "$py_exit_code" -eq "0" ]; then
printf "succeeded\n"
else
printf "FAILED!\n"
fi
printf "testing C++... "
cpp_comp_output=$(g++ -x c++ -std=c++14 $ppp_file -o tmp_bin 2>&1)
cpp_comp_exit_code=$?
cpp_run_output=""
cpp_run_exit_code=1
if [ "$cpp_comp_exit_code" -eq "0" ]; then
cpp_run_output=$(./tmp_bin 2>&1)
cpp_run_exit_code=$?
if [ "$cpp_run_exit_code" -eq "0" ]; then
printf "succeeded\n"
else
printf "CRASHED!\n"
fi
rm tmp_bin
else
printf "FAILED TO COMPILE!\n"
fi
if [ "$py_exit_code" -eq "0" ] && [ "$cpp_run_exit_code" -eq "0" ] && [ "$py_output" = "$cpp_run_output" ]; then
printf "Python and C++ outputs match\n"
printf "________\n"
printf " output \__________________________________________\n\n"
printf "$py_output\n"
printf "___________________________________________________\n"
else
if [ "$py_exit_code" -eq "0" ] && [ "$cpp_run_exit_code" -eq "0" ]; then
printf "Python and C++ outputs DO NOT MATCH!\n"
fi
printf "_______________\n"
printf " Python output \___________________________________\n\n"
printf "$py_output\n"
printf "___________________________________________________\n"
if [ "$cpp_comp_exit_code" -ne "0" ]; then
printf "_____________________\n"
printf " C++ compiler output \_____________________________\n\n"
printf "$cpp_comp_output\n"
printf "___________________________________________________\n"
else
printf "____________\n"
printf " C++ output \______________________________________\n\n"
printf "$cpp_run_output\n"
printf "___________________________________________________\n"
fi
fi
printf "\n"