From cb7743fa391683698b0f9db52d6d9f5b848ab7a6 Mon Sep 17 00:00:00 2001 From: cpq Date: Sun, 6 Dec 2020 23:19:56 +0000 Subject: [PATCH] Move tests -> test --- .travis.yml | 2 +- Makefile | 7 ++++--- test/unit_test.c | 18 +++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 04513eb3..9620d716 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ after_success: bash <(curl -s https://codecov.io/bash) os: - linux - osx - - windows +# - windows compiler: - clang - gcc diff --git a/Makefile b/Makefile index f2d887b6..6f9c28a7 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,8 @@ VC98 = docker run --rm -e WINEDEBUG=-all -v $(CDIR):$(CDIR) -w $(CDIR) docker.io VC2017 = docker run --rm -e WINEDEBUG=-all -v $(CDIR):$(CDIR) -w $(CDIR) docker.io/mdashnet/vc2017 GCC = docker run --rm -v $(CDIR):$(CDIR) -w $(CDIR) mdashnet/cc2 VCFLAGS = /nologo /W3 /O2 /I. $(DEFS) $(TFLAGS) -CLANG ?= /usr/local/opt/llvm\@9/bin/clang #-L/usr/local/opt/llvm\@8/lib +CLANG ?= clang # /usr/local/opt/llvm\@9/bin/clang +ASAN_OPTIONS ?= EXAMPLES := $(wildcard examples/*) EXAMPLE_TARGET ?= example .PHONY: $(EXAMPLES) @@ -46,11 +47,11 @@ fuzz: mongoose.c mongoose.h Makefile test/fuzz.c $(CLANG) mongoose.c test/fuzz.c $(CFLAGS) -DMG_ENABLE_LOG=0 -fsanitize=fuzzer,signed-integer-overflow,address $(LDFLAGS) -g -o fuzzer $(DEBUGGER) ./fuzzer -# make CC=/usr/local/opt/llvm\@8/bin/clang DEBUGGER=ASAN_OPTIONS=detect_leaks=1 +# make CLANG=/usr/local/opt/llvm\@8/bin/clang ASAN_OPTIONS=detect_leaks=1 test: CFLAGS += -DMG_ENABLE_IPV6=1 -fsanitize=address#,undefined test: mongoose.c mongoose.h clean Makefile test/unit_test.c $(CLANG) mongoose.c test/unit_test.c $(CFLAGS) -coverage $(LDFLAGS) -g -o unit_test - ASAN_OPTIONS=detect_leaks=1 $(DEBUGGER) ./unit_test + ASAN_OPTIONS=$(ASAN_OPTIONS) $(DEBUGGER) ./unit_test coverage: test gcov -l -n *.gcno | sed '/^$$/d' | sed 'N;s/\n/ /' diff --git a/test/unit_test.c b/test/unit_test.c index d6ab3088..3cce1310 100644 --- a/test/unit_test.c +++ b/test/unit_test.c @@ -340,7 +340,7 @@ static void eh1(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { } else if (mg_http_match_uri(hm, "/badroot")) { mg_http_serve_dir(c, hm, "/BAAADDD!"); } else { - mg_http_serve_dir(c, hm, "./tests/data"); + mg_http_serve_dir(c, hm, "./test/data"); } } } @@ -395,11 +395,11 @@ static int fetch(struct mg_mgr *mgr, char *buf, const char *url, if (mg_url_is_ssl(url)) { struct mg_tls_opts opts; memset(&opts, 0, sizeof(opts)); - opts.ca = "./tests/data/ca.pem"; + opts.ca = "./test/data/ca.pem"; if (strstr(url, "127.0.0.1") != NULL) { // Local connection, use self-signed certificates - opts.ca = "./tests/data/ss_ca.pem"; - opts.cert = "./tests/data/ss_client.pem"; + opts.ca = "./test/data/ss_ca.pem"; + opts.cert = "./test/data/ss_client.pem"; } mg_tls_init(c, &opts); // c->is_hexdumping = 1; @@ -436,7 +436,7 @@ static void test_http_server(void) { { extern char *mg_http_etag(char *, size_t, struct stat *); char etag[100]; - ASSERT(stat("./tests/data/a.txt", &st) == 0); + ASSERT(stat("./test/data/a.txt", &st) == 0); ASSERT(mg_http_etag(etag, sizeof(etag), &st) == etag); ASSERT(fetch(&mgr, buf, url, "GET /a.txt HTTP/1.0\nIf-None-Match: %s\n\n", etag) == 304); @@ -460,7 +460,7 @@ static void test_http_server(void) { #endif { - char *data = mg_file_read("./tests/data/ca.pem"); + char *data = mg_file_read("./test/data/ca.pem"); ASSERT(fetch(&mgr, buf, url, "GET /ca.pem HTTP/1.0\r\n\n") == 200); ASSERT(cmpbody(data, buf) == 0); free(data); @@ -476,8 +476,8 @@ static void test_http_server(void) { static void test_tls(void) { #if MG_ENABLE_MBEDTLS || MG_ENABLE_OPENSSL - struct mg_tls_opts opts = {.ca = "./tests/data/ss_ca.pem", - .cert = "./tests/data/ss_server.pem"}; + struct mg_tls_opts opts = {.ca = "./test/data/ss_ca.pem", + .cert = "./test/data/ss_server.pem"}; struct mg_mgr mgr; struct mg_connection *c; const char *url = "https://127.0.0.1:12347"; @@ -526,7 +526,7 @@ static void test_http_client(void) { ok = 0; #if MG_ENABLE_MBEDTLS || MG_ENABLE_OPENSSL { - struct mg_tls_opts opts = {.ca = "./tests/data/ca.pem"}; + struct mg_tls_opts opts = {.ca = "./test/data/ca.pem"}; c = mg_http_connect(&mgr, "https://cesanta.com", f3, &ok); ASSERT(c != NULL); mg_tls_init(c, &opts);