-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_mac.sh
231 lines (192 loc) · 4.56 KB
/
test_mac.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
TEST_DIR="./"
RESULTFILE=$TEST_DIR"result.txt"
EXEC="./lsls"
function compare_tty() {
diff -u ${REAL_OUT_FILE} ${MINE_OUT_FILE}
}
function compare_file() {
diff -u ${REAL_OUT_FILE} ${MINE_OUT_FILE} && diff -u ${REAL_ERR_FILE} ${MINE_ERR_FILE}
}
function print_result() {
{ test_stat=$?; } 2>/dev/null
# { set +x; } 2>/dev/null
if [ $test_stat -eq 0 ]; then
echo -e "\033[32m[ OK ]\033[m $1"
echo [ OK ] "$(date -R) $1" >> $RESULTFILE
else
echo -e "\033[31m[FAIL] $1\033[m"
echo "[FAIL] "$(date -R)" $1" >> $RESULTFILE
fi
# set -x
}
function run_tty() {
P=$1
echo "[tty: $P]" > /dev/stderr
rm ${EXEC}
cp /bin/ls ${EXEC}
time script -t 0 -q ${REAL_OUT_FILE} ${EXEC} $P > /dev/null
rm ${EXEC}
cp ./ft_ls ${EXEC}
time script -t 0 -q ${MINE_OUT_FILE} ${EXEC} $P > /dev/null
compare_tty
print_result "tty: $P"
}
function run_file() {
P=$1
echo "[file: $P]" > /dev/stderr
rm ${EXEC}
cp /bin/ls ${EXEC}
time bash -c "(${EXEC} $P; echo $?) > ${REAL_OUT_FILE} 2> ${REAL_ERR_FILE}"
rm ${EXEC}
cp ./ft_ls ${EXEC}
time bash -c "(${EXEC} $P; echo $?) > ${MINE_OUT_FILE} 2> ${MINE_ERR_FILE}"
compare_file
print_result "file: $P"
}
rm -rf $RESULTFILE
EXEC=~/yo_ft_ls
REAL_OUT_FILE=`mktemp`
MINE_OUT_FILE=`mktemp`
REAL_ERR_FILE=`mktemp`
MINE_ERR_FILE=`mktemp`
# argv が存在する場合は, それだけでテストする
if [ $# -eq 1 ]; then
run_tty "$1"
cp ${REAL_OUT_FILE} "./test_real_out.txt"
cp ${MINE_OUT_FILE} "./test_mine_out.txt"
cp ${REAL_ERR_FILE} "./test_real_err.txt"
cp ${MINE_ERR_FILE} "./test_mine_err.txt"
exit 0
fi
run_tty "./"
run_tty "./srcs"
run_tty "./includes"
run_tty "./srcs ./includes"
run_tty ". ./srcs ./includes"
run_tty ". ."
run_tty ".. .. ."
run_tty "/usr"
run_tty "/usr/local"
run_tty "/usr/bin"
run_tty "/usr/bin /usr"
run_tty "/usr/bin /usr/bin"
run_tty "-l ./srcs"
run_tty "-l ./includes"
run_tty "-l ./srcs ./includes"
run_tty "srcs/"
run_tty "srcs/*"
run_tty "./includes/../srcs/"
run_tty "./includes/../srcs/*"
run_tty "-l srcs/"
run_tty "-l srcs/*"
run_tty "-l ./includes/../srcs/"
run_tty "-l ./includes/../srcs/*"
run_tty "-l ./includes/../srcs/*"
run_tty "Makefile"
run_tty "Makefile src/"
run_tty "libft libft"
run_tty "-l libft libft"
run_tty "-R libft libft"
run_tty "-lR libft libft"
run_tty "-R"
run_tty "."
run_tty "-R ."
run_tty "-G"
run_tty "-G srcs"
run_tty "-G includes"
run_tty "-G minimini"
run_tty "-G /usr"
run_tty "-G /usr/bin"
run_tty "-l /usr/bin"
run_tty "-lG pocket"
run_tty "-lG /usr/bin"
run_tty " /dev/"
run_tty "-G /dev/"
run_tty "/"
run_tty "-l /"
run_tty "-lG /"
run_tty "-l@"
run_tty "-l@e"
run_tty "xxx x"
run_tty ""
run_tty "-R"
run_tty "-l ./srcs"
run_tty "-l ./includes"
run_tty "-lf ccc aaa bbb"
run_tty "-l ccc aaa bbb"
run_tty "test_field1/link_dir_1"
run_tty "-l test_field1/link_dir_1"
run_tty "test_field3"
run_tty "-l test_field3"
run_tty "-R test_field3"
run_tty "-lR test_field3"
run_tty "test_field3/*"
run_tty "-l test_field3/*"
run_tty "-R test_field3/*"
run_tty "-lR test_field3/*"
run_tty "-g srcs includes"
run_tty "-gl srcs includes"
run_tty "-d"
run_tty "-dR"
run_tty "-d .."
run_tty "-dR .."
run_tty "-d test_field*"
run_tty "-Rd test_field*"
run_tty "-lRd test_field*"
run_tty "-a .."
run_tty "-a ."
run_tty "-a"
run_tty "-aR pocket"
run_tty "-aR pocket/dir"
run_tty "-aR pocket/dir/."
run_tty "-aR pocket/dir/.."
run_tty "-l@ test_field3"
run_tty "-lG /Applications"
run_file ""
run_file "-R"
run_file "-l ./srcs"
run_file "-l ./includes"
run_file "-lf ccc aaa bbb"
run_file "-l ccc aaa bbb"
run_file "test_field1/link_dir_1"
run_file "-l test_field1/link_dir_1"
run_file "test_field3"
run_file "-l test_field3"
run_file "-R test_field3"
run_file "-lR test_field3"
run_file "test_field3/*"
run_file "-l test_field3/*"
run_file "-R test_field3/*"
run_file "-lR test_field3/*"
run_file "-g srcs includes"
run_file "-gl srcs includes"
run_tty "test_field"
run_tty "-d test_field"
run_tty "-l test_field"
run_tty "-R test_field"
run_tty "-a test_field"
run_tty "-lR test_field"
run_tty "-laR test_field"
run_tty "-laR --col test_field"
run_tty "-laRu test_field"
run_tty "-laRr test_field"
run_tty "-laRt test_field"
run_tty "-laRf test_field"
run_file "test_field"
run_file "-d test_field"
run_file "-l test_field"
run_file "-R test_field"
run_file "-a test_field"
run_file "-lR test_field"
run_file "-laR test_field"
run_file "-laR --col test_field"
run_file "-laRu test_field"
run_file "-laRr test_field"
run_file "-laRt test_field"
run_file "-laRf test_field"
run_file "--color"
run_file "--color=auto"
run_file "--color=always"
run_file "--color=none"
run_tty "-l /Applications"
run_tty "-lG /Applications"