Przeglądaj źródła

Add build scripts for fuzz test

bel2125 5 lat temu
rodzic
commit
293c8c3da7

+ 16 - 0
.gitignore

@@ -14,8 +14,12 @@ out
 [oO]utput
 [tT]esting
 examples/embedded_c/embedded_c
+examples/embedded_cpp/embedded_cpp
 *.a
 *.o
+VisualStudio/unit_test/*
+log.out
+
 
 ################# //hash
 ## CMake
@@ -279,3 +283,15 @@ conan/test_package/build
 ## Visual Studio Code
 ##########################
 .vscode
+
+
+##########################
+## Fuzz test corpus
+##########################
+fuzztest/http1/**
+fuzztest/http1c/**
+fuzztest/url/**
+crash-[0-9a-f]*
+leak-[0-9a-f]*
+slow-unit-[0-9a-f]*
+civetweb_fuzz?

+ 1 - 1
fuzztest/README.txt

@@ -16,7 +16,7 @@ Second fuzz target: vary HTTP1 request for HTTP1 server
 Third fuzz target: vary HTTP1 response for HTTP1 client API
 - make WITH_ALL=1 TEST_FUZZ=3
 - mv civetweb civetweb_fuzz3
-- sudo ./civetweb_fuzz2 -max_len=2048 -dict=fuzztest/http1.dict fuzztest/http1c/
+- sudo ./civetweb_fuzz3 -max_len=2048 -dict=fuzztest/http1.dict fuzztest/http1c/
 
 
 

+ 11 - 0
fuzztest/build.sh

@@ -0,0 +1,11 @@
+#!/bin/sh
+
+make clean
+rm civetweb_fuzz?
+
+make WITH_ALL=1 TEST_FUZZ=1
+mv civetweb civetweb_fuzz1
+make WITH_ALL=1 TEST_FUZZ=2
+mv civetweb civetweb_fuzz2
+make WITH_ALL=1 TEST_FUZZ=3
+mv civetweb civetweb_fuzz3

+ 51 - 0
fuzztest/build_and_run.sh

@@ -0,0 +1,51 @@
+#!/bin/sh
+
+make clean
+rm civetweb_fuzz?
+
+make WITH_ALL=1 TEST_FUZZ=1
+mv civetweb civetweb_fuzz1
+make WITH_ALL=1 TEST_FUZZ=2
+mv civetweb civetweb_fuzz2
+make WITH_ALL=1 TEST_FUZZ=3
+mv civetweb civetweb_fuzz3
+
+echo ""
+echo "====================="
+echo "== Build completed =="
+echo "====================="
+echo ""
+
+ls -halt civetweb*
+echo ""
+md5sum civetweb_fuzz*
+
+echo ""
+echo "====================="
+echo "== run fuzz test 1 =="
+echo "====================="
+echo ""
+
+./civetweb_fuzz1 -max_total_time=600 -max_len=2048 fuzztest/url/
+
+echo ""
+echo "====================="
+echo "== run fuzz test 2 =="
+echo "====================="
+echo ""
+
+./civetweb_fuzz2 -max_total_time=600 -max_len=2048 -dict=fuzztest/http1.dict fuzztest/http1/
+
+echo ""
+echo "====================="
+echo "== run fuzz test 3 =="
+echo "====================="
+echo ""
+
+./civetweb_fuzz3 -max_total_time=600 -max_len=2048 -dict=fuzztest/http1.dict fuzztest/http1c/
+
+echo ""
+echo "====================="
+echo "== fuzz tests done =="
+echo "====================="
+echo ""

+ 0 - 2
fuzztest/fuzzmain.c

@@ -294,8 +294,6 @@ LLVMFuzzerTestOneInput_URI(const uint8_t *data, size_t size)
 		return 1;
 	}
 
-	printf("URI: %s\n", URI);
-
 	return test_http_request("127.0.0.1", 8080, 0, URI);
 }
 

+ 9 - 0
unittest/build_and_run.sh

@@ -0,0 +1,9 @@
+#!/bin/sh
+rm -rf output
+mkdir output
+gcc unittest/cgi_test.c -o output/cgi_test.cgi
+cd output
+cmake ..
+make all
+make test
+cd ..