-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_linux.sh
196 lines (163 loc) · 3.92 KB
/
test_linux.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
TEST_DIR="./"
RESULTFILE=$TEST_DIR"result.txt"
EXEC="./lsls"
function compare_tty() {
diff -u <(head -n-1 ${REAL_OUT_FILE} | tail -n+2) <(head -n-1 ${MINE_OUT_FILE} | tail -n+2)
}
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 -q -c "${EXEC} $P; echo \$?" ${REAL_OUT_FILE} > /dev/null
rm ${EXEC}
cp ./ft_ls ${EXEC}
time script -q -c "${EXEC} $P; echo \$?" ${MINE_OUT_FILE} > /dev/null
compare_tty
print_result "tty: $P"
}
function run_file() {
P=$1
echo "[file: $P]" > /dev/stderr
cp /bin/ls ${EXEC}
(${EXEC} $P; echo $?) > ${REAL_OUT_FILE} 2> ${REAL_ERR_FILE}
cp ./ft_ls ${EXEC}
(${EXEC} $P; echo $?) > ${MINE_OUT_FILE} 2> ${MINE_ERR_FILE}
compare_file
print_result "file: $P"
}
rm -rf $RESULTFILE
EXEC=`mktemp`
chmod a+x ${EXEC}
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 "-R test1"
run_tty "--col"
run_tty "--col srcs"
run_tty "--col includes"
run_tty "--col minimini"
run_tty "--col /usr"
run_tty "--col /usr/bin"
run_tty "-l /usr/bin"
run_tty "-l --col pocket"
run_tty "-l --col /usr/bin"
run_tty "/dev"
run_tty "--col /dev"
run_tty "-l --col /dev"
run_tty "/var"
run_tty "--col /var"
run_tty "-l --col /var"
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_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 "--color"
run_file "--color=auto"
run_file "--color=always"
run_file "--color=none"
run_file "-g srcs includes"
run_file "-gl srcs includes"