add tests
authorLaurent Mazet <laurent.mazet@thalesgroup.com>
Fri, 26 May 2023 12:16:35 +0000 (14:16 +0200)
committerLaurent Mazet <laurent.mazet@thalesgroup.com>
Fri, 26 May 2023 12:16:35 +0000 (14:16 +0200)
http.c
webserver.c

diff --git a/http.c b/http.c
index 6ce72c05854f61204aba636b0036b5d2f8e5978c..c17781fc76b3d24e8e6f9dc73b642e1284a8adc0 100644 (file)
--- a/http.c
+++ b/http.c
@@ -393,7 +393,7 @@ int processing (char *data, int len, conf_t *conf, char **pdata)
     case get_e:
         VERBOSE (DEBUG, PRINT ("Read file %s\n", filename));
         len = readfile (&buffer, filename);
-        if (len == 0) {
+        if (len < 0) {
             sprintf (location, "http://%s/", conf->servername);
             len = error_404 (pdata, location);
         } else {
index f10838ee7ffa9a04b5e84ae1ab258434b8d8c757..ca44de73ec8ab3ccf9b13d539b93245b7893a607 100644 (file)
@@ -206,9 +206,11 @@ int main (int argc, char *argv[])
 // test: webserver.exe -p -1 2>&1 | grep -q 'incorrect port number'
 // test: webserver.exe -s 2>&1 | grep -q 'missing server name'
 // test: webserver.exe -r 2>&1 | grep -q 'missing directory name'
-// test: webserver.exe > test.log & pid=$!; sleep 1; kill -QUIT $pid; grep -q 'Listening socket on port 8080' test.log
-// test: webserver.exe -p 8000 > test.log & pid=$!; sleep 1; kill -ABRT $pid; grep -q 'Listening socket on port 8000' test.log
-// test: webserver.exe -c iso-8859-1 -r webroot -s localhost & pid=$!; sleep 1; curl http://localhost:8080/index.html -v > test; kill -TERM $pid; grep -q '<title>Test</title>' test
+// test: webserver.exe >& test.log & pid=$!; sleep 1; kill -QUIT $pid; grep -q 'Listening socket on port 8080' test.log
+// test: webserver.exe -p 8000 >& test.log & pid=$!; sleep 1; kill -ABRT $pid; grep -q 'Listening socket on port 8000' test.log
+// test: webserver.exe -c iso-8859-1 -r webroot -s localhost >&/dev/null & pid=$!; sleep 1; curl http://localhost:8080/index.html -v > test; kill -TERM $pid; grep -q '<title>Test</title>' test
+// test: webserver.exe -v 3 -p 8001 >&/dev/null & pid=$!; sleep 1; curl http://localhost:8001/index.html -v > test; kill -TERM $pid
+// test: webserver.exe -c iso-8859-1 -r webroot -s localhost >&/dev/null & pid=$!; sleep 1; curl http://localhost:8080/not_found.html -v > test; kill -TERM $pid; grep -q '404' test
 
 
 /* vim: set ts=4 sw=4 et: */