Repository navigation
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·196 lines (177 loc) · 6.79 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·196 lines (177 loc) · 6.79 KB
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
#!/bin/bash
TMP_DIR=~/tmp_21sh
TMP_DIR_LOG=~/tmp_21sh_log
LOG=${TMP_DIR_LOG}/log
RESULT=${TMP_DIR_LOG}/result
LOG_2=${TMP_DIR_LOG}/log_2
RESULT_2=${TMP_DIR_LOG}/result_2
mkdir ${TMP_DIR}
mkdir ${TMP_DIR_LOG}
quit()
{
rm -rf ${TMP_DIR} ${TMP_DIR_LOG}
exit 1
}
execute_bash()
{
(./21sh < ${1}) > ${LOG} 2> ${LOG_2}
YOUR_RET=($?)
(bash < ${1}) > ${RESULT} 2> ${RESULT_2}
OUR_RET=($?)
if [ $OUR_RET -ne $YOUR_RET ]; then
printf "\nSTDIN--------------------------------------------------------------\n"
while read line
do
echo -e "\033[31m$line\033[0m"
done < ${1}
printf "\033[0m-----------------------------------------------------------------\033[0m\n"
printf "\r\n\033[31mError:\t\t\033[0m\033[37;1m ./21sh ${1} <=> bash ${1}\033[0m\n\n"
printf "bash return: %d | 21sh return: %d\n\n" $OUR_RET $YOUR_RET
quit
elif !(diff ${LOG} ${RESULT}) then
printf "\nSTDIN--------------------------------------------------------------\n"
while read line
do
echo -e "\033[31m$line\033[0m"
done < ${1}
printf "\033[0m-----------------------------------------------------------------\033[0m\n"
printf "\r\n\033[31mError STDOUT:\t\t\033[0m\033[37;1m ./21sh ${1} <=> bash ${1}\033[0m\n\n"
diff ${LOG} ${RESULT}
quit
else
printf "\n\033[32mSTDIN\033[0m--------------------------------------------------------------\n"
while read line
do
echo -e "\033[32m$line\033[0m"
done < ${1}
printf "\033[0m-----------------------------------------------------------------\033[0m\n"
printf "\n\033[32mSuccess:\t\033[37;1m ./21sh ${1} <=> bash ${1}\033[0m\n\n"
printf "\nSTDERR--------------------------------------------------------------\n"
diff ${RESULT_2} ${LOG_2}
printf "\n--------------------------------------------------------------------\n"
fi
}
execute_bash_empty()
{
(env -i ./21sh ${1}) > ${LOG} 2> ${LOG_2}
YOUR_RET=($?)
(env -i bash < ${1}) > ${RESULT} 2> ${RESULT_2}
OUR_RET=($?)
if [ $OUR_RET -ne $YOUR_RET ]; then
printf "\nSTDIN--------------------------------------------------------------\n"
while read line
do
echo -e "\033[31m$line\033[0m"
done < ${1}
printf "\033[0m-----------------------------------------------------------------\033[0m\n"
printf "\r\n\033[31mError:\t\t\033[0m\033[37;1m env -i ./21sh ${1} <=> env -i bash ${1}\033[0m\n\n"
printf "env -i bash return: %d | env -i ./21sh return: %d\n\n" $OUR_RET $YOUR_RET
quit
elif !(diff ${LOG} ${RESULT}) then
printf "\nSTDIN--------------------------------------------------------------\n"
while read line
do
echo -e "\033[31m$line\033[0m"
done < ${1}
printf "\033[0m-----------------------------------------------------------------\033[0m\n"
printf "\r\n\033[31mError STDOUT:\t\t\033[0m\033[37;1m env -i ./21sh ${1} <=> env -i bash ${1}\033[0m\n\n"
diff ${LOG} ${RESULT}
quit
else
printf "\n\033[32mSTDIN\033[0m--------------------------------------------------------------\n"
while read line
do
echo -e "\033[32m$line\033[0m"
done < ${1}
printf "\033[0m-----------------------------------------------------------------\033[0m\n"
printf "\n\033[32mSuccess:\t\033[37;1m env -i ./21sh ${1} <=> env -i bash ${1}\033[0m\n\n"
printf "\nSTDERR--------------------------------------------------------------\n"
diff ${RESULT_2} ${LOG_2}
printf "\n--------------------------------------------------------------------\n"
fi
}
execute_csh()
{
(./21sh ${1}) > ${LOG} 2> ${LOG_2}
YOUR_RET=($?)
(csh < ${1}) > ${RESULT} 2> ${RESULT_2}
OUR_RET=($?)
if !(diff ${LOG} ${RESULT}) then
printf "\nSTDIN--------------------------------------------------------------\n"
while read line
do
echo -e "\033[31m$line\033[0m"
done < ${1}
printf "\033[0m-----------------------------------------------------------------\033[0m\n"
printf "\r\n\033[31mError STDOUT:\t\t\033[0m\033[37;1m ./21sh ${1} <=> csh ${1}\033[0m\n\n"
diff ${LOG} ${RESULT}
quit
else
printf "\n\033[32mSTDIN\033[0m--------------------------------------------------------------\n"
while read line
do
echo -e "\033[32m$line\033[0m"
done < ${1}
printf "\033[0m-----------------------------------------------------------------\033[0m\n"
printf "\n\033[32mSuccess:\t\033[37;1m ./21sh ${1} <=> csh ${1}\033[0m\n\n"
printf "\nSTDERR--------------------------------------------------------------\n"
diff ${RESULT_2} ${LOG_2}
printf "\n--------------------------------------------------------------------\n"
fi
}
execute_csh_empty()
{
(env -i ./21sh ${1}) > ${LOG} 2> ${LOG_2}
YOUR_RET=($?)
(env -i csh ${1}) > ${RESULT} 2> ${RESULT_2}
OUR_RET=($?)
if !(diff ${LOG} ${RESULT}) then
printf "\nSTDIN--------------------------------------------------------------\n"
while read line
do
echo -e "\033[31m$line\033[0m"
done < ${1}
printf "\033[0m-----------------------------------------------------------------\033[0m\n"
printf "\r\n\033[31mError STDOUT:\t\t\033[0m\033[37;1m env -i ./21sh ${1} <=> env -i csh ${1}\033[0m\n\n"
diff ${LOG} ${RESULT}
quit
else
printf "\n\033[32mSTDIN\033[0m--------------------------------------------------------------\n"
while read line
do
echo -e "\033[32m$line\033[0m"
done < ${1}
printf "\033[0m-----------------------------------------------------------------\033[0m\n"
printf "\n\033[32mSuccess:\t\033[37;1m env -i ./21sh ${1} <=> env -i csh ${1}\033[0m\n\n"
printf "\nSTDERR--------------------------------------------------------------\n"
diff ${RESULT_2} ${LOG_2}
printf "\n--------------------------------------------------------------------\n"
fi
}
rm -rf leaks
for filename in $(ls tests_csh/); do
echo Test tests_csh/${filename}
execute_csh tests_csh/${filename}
echo Test leaks tests_csh/${filename}
valgrind --track-origins=yes --show-leak-kinds=all --track-fds=yes \
--show-reachable=no --leak-check=full env -i ./21sh tests_csh/${filename} 2>> leaks
echo Test env -i tests_csh/${filename}
execute_csh_empty tests_csh/${filename}
echo Test env -i leaks tests_csh/${filename}
valgrind --track-origins=yes --show-leak-kinds=all --track-fds=yes \
--show-reachable=no --leak-check=full env -i ./21sh tests_csh/${filename} 2>> leaks
done
for filename in $(ls tests_sh/); do
echo Test tests_sh/${filename}
execute_bash tests_sh/${filename}
echo Test leaks tests_sh/${filename}
valgrind --track-origins=yes --show-leak-kinds=all --track-fds=yes \
--show-reachable=no --leak-check=full ./21sh tests_sh/${filename} 2>> leaks
echo Test env -i tests_sh/${filename}
execute_bash_empty tests_sh/${filename}
echo Test env -i leaks tests_sh/${filename}
valgrind --track-origins=yes --show-leak-kinds=all --track-fds=yes \
--show-reachable=no --leak-check=full env -i ./21sh tests_sh/${filename} 2>> leaks
done
rm -rf ${TMP_DIR} ${TMP_DIR_LOG}
exit 0