-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestScript.c
249 lines (210 loc) · 6.67 KB
/
testScript.c
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#include <stdio.h>
#include <stdlib.h>
/*
This only tests for GET and PUT
Files Needed: a.txt, b.txt, c.txt, d.txt, e.txt, f.txt
Make sure to be in same directory for both terminals
HOW TO RUN testScript:
1.) Terminal 1, run "make" and then "./httpserver 8080"
2.) Terminal 2, run "gcc testScript.c" and then "./a.out"
*/
int main() {
int x;
system("rm -f x*.txt");
// GET TESTS =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
system("echo GET tests =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
system("curl -s http://localhost:8080/a.txt -o d.txt");
x = system("diff d.txt a.txt");
if(x == 0) {
printf("Test 1 PASSED\n");
} else {
printf("Test 1 failed\n");
}
system("curl -s http://localhost:8080/b.txt -o d.txt");
x = system("diff d.txt b.txt");
if(x == 0) {
printf("Test 2 PASSED\n");
} else {
printf("Test 2 failed\n");
}
system("curl -s http://localhost:8080/c.txt -o d.txt");
x = system("diff d.txt c.txt");
if(x == 0) {
printf("Test 3 PASSED\n");
} else {
printf("Test 3 failed\n");
}
system("curl -s http://localhost:8080/e.txt -o d.txt");
x = system("diff d.txt e.txt");
if(x == 0) {
printf("Test 4 PASSED\n");
} else {
printf("Test 4 failed\n");
}
system("curl -s http://localhost:8080/Makefile -o d.txt");
x = system("diff d.txt Makefile");
if(x == 0) {
printf("Test 5 PASSED\n");
} else {
printf("Test 5 failed\n");
}
system("curl -s http://localhost:8080/httpserver -o d.txt");
x = system("diff d.txt httpserver");
if(x == 0) {
printf("Test 6 PASSED\n");
} else {
printf("Test 6 failed\n");
}
system("curl -s http://localhost:8080/httpserver.c -o d.txt");
x = system("diff d.txt httpserver.c");
if(x == 0) {
printf("Test 7 PASSED\n");
} else {
printf("Test 7 failed\n");
}
system("curl -s http://localhost:8080/f.txt -o d.txt");
x = system("diff d.txt f.txt");
if(x == 0) {
printf("Test 8 PASSED\n");
} else {
printf("Test 8 failed\n");
}
system("curl -s http://localhost:8080/WRITEUP.pdf -o d.txt");
x = system("diff d.txt WRITEUP.pdf");
if(x == 0) {
printf("Test 9 PASSED\n");
} else {
printf("Test 9 failed\n");
}
system("curl -s http://localhost:8080/DESIGN.pdf -o d.txt");
x = system("diff d.txt DESIGN.pdf");
if(x == 0) {
printf("Test 10 PASSED\n");
} else {
printf("Test 10 failed\n");
}
// // // PUT TESTS =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// system("echo PUT tests =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
// system("curl -T Makefile http://localhost:8080/d.txt");
// x = system("diff Makefile d.txt");
// if(x == 0) {
// printf("Test 1 PASSED\n");
// } else {
// printf("Test 1 failed\n");
// }
// system("curl -T a.txt http://localhost:8080/d.txt");
// x = system("diff a.txt d.txt");
// if(x == 0) {
// printf("Test 2 PASSED\n");
// } else {
// printf("Test 2 failed\n");
// }
// system("curl -T b.txt http://localhost:8080/d.txt");
// x = system("diff b.txt d.txt");
// if(x == 0) {
// printf("Test 3 PASSED\n");
// } else {
// printf("Test 3 failed\n");
// }
// system("curl -T c.txt http://localhost:8080/d.txt");
// x = system("diff c.txt d.txt");
// if(x == 0) {
// printf("Test 4 PASSED\n");
// } else {
// printf("Test 4 failed\n");
// }
// system("curl -T e.txt http://localhost:8080/d.txt");
// x = system("diff e.txt d.txt");
// if(x == 0) {
// printf("Test 5 PASSED\n");
// } else {
// printf("Test 5 failed\n");
// }
// system("curl -T a.txt http://localhost:8080/x1.txt");
// x = system("diff a.txt x1.txt");
// if(x == 0) {
// printf("Test 6 PASSED\n");
// } else {
// printf("Test 6 failed\n");
// }
// system("curl -T b.txt http://localhost:8080/x2.txt");
// x = system("diff b.txt x2.txt");
// if(x == 0) {
// printf("Test 7 PASSED\n");
// } else {
// printf("Test 7 failed\n");
// }
// system("curl -T c.txt http://localhost:8080/x3.txt");
// x = system("diff c.txt x3.txt");
// if(x == 0) {
// printf("Test 8 PASSED\n");
// } else {
// printf("Test 8 failed\n");
// }
// system("curl -T e.txt http://localhost:8080/x4.txt");
// x = system("diff e.txt x4.txt");
// if(x == 0) {
// printf("Test 9 PASSED\n");
// } else {
// printf("Test 9 failed\n");
// }
// system("curl -T httpserver http://localhost:8080/x5.txt");
// x = system("diff httpserver x5.txt");
// if(x == 0) {
// printf("Test 10 PASSED\n");
// } else {
// printf("Test 10 failed\n");
// }
// system("curl -T httpserver.c http://localhost:8080/x6.txt");
// x = system("diff httpserver.c x6.txt");
// if(x == 0) {
// printf("Test 11 PASSED\n");
// } else {
// printf("Test 11 failed\n");
// }
// system("curl -T a.txt http://localhost:8080/x4.txt");
// x = system("diff a.txt x4.txt");
// if(x == 0) {
// printf("Test 12 PASSED\n");
// } else {
// printf("Test 12 failed\n");
// }
// system("curl -T b.txt http://localhost:8080/x1.txt");
// x = system("diff b.txt x1.txt");
// if(x == 0) {
// printf("Test 13 PASSED\n");
// } else {
// printf("Test 13 failed\n");
// }
// // // PUT tests with large binary files =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// system("echo PUT tests with large binary files similar to test 8 on GitLab =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
// system("curl -T e.txt http://localhost:8080/x7.txt");
// x = system("diff e.txt x7.txt");
// if(x == 0) {
// printf("Test 1 PASSED\n");
// } else {
// printf("Test 1 failed\n");
// }
// system("curl -T f.txt http://localhost:8080/x8.txt");
// x = system("diff f.txt x8.txt");
// if(x == 0) {
// printf("Test 2 PASSED\n");
// } else {
// printf("Test 2 failed\n");
// }
// system("curl -T e.txt http://localhost:8080/x8.txt");
// x = system("diff e.txt x8.txt");
// if(x == 0) {
// printf("Test 3 PASSED\n");
// } else {
// printf("Test 3 failed\n");
// }
// system("curl -T f.txt http://localhost:8080/x7.txt");
// x = system("diff f.txt x7.txt");
// if(x == 0) {
// printf("Test 4 PASSED\n");
// } else {
// printf("Test 4 failed\n");
// }
return 0;
}