mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-27 20:48:29 +00:00
Move tests -> test
This commit is contained in:
1 parent
6197842bca
commit
cb7743fa39
3 files changed
+14
-13
No files matched your search
+1
-1
@@ -4,7 +4,7 @@ after_success: bash <(curl -s https://codecov.io/bash)
|
|||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
- osx
|
- osx
|
||||||
- windows
|
# - windows
|
||||||
compiler:
|
compiler:
|
||||||
- clang
|
- clang
|
||||||
- gcc
|
- gcc
|
||||||
|
|||||||
@@ -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
|
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
|
GCC = docker run --rm -v $(CDIR):$(CDIR) -w $(CDIR) mdashnet/cc2
|
||||||
VCFLAGS = /nologo /W3 /O2 /I. $(DEFS) $(TFLAGS)
|
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/*)
|
EXAMPLES := $(wildcard examples/*)
|
||||||
EXAMPLE_TARGET ?= example
|
EXAMPLE_TARGET ?= example
|
||||||
.PHONY: $(EXAMPLES)
|
.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
|
$(CLANG) mongoose.c test/fuzz.c $(CFLAGS) -DMG_ENABLE_LOG=0 -fsanitize=fuzzer,signed-integer-overflow,address $(LDFLAGS) -g -o fuzzer
|
||||||
$(DEBUGGER) ./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: CFLAGS += -DMG_ENABLE_IPV6=1 -fsanitize=address#,undefined
|
||||||
test: mongoose.c mongoose.h clean Makefile test/unit_test.c
|
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
|
$(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
|
coverage: test
|
||||||
gcov -l -n *.gcno | sed '/^$$/d' | sed 'N;s/\n/ /'
|
gcov -l -n *.gcno | sed '/^$$/d' | sed 'N;s/\n/ /'
|
||||||
|
|||||||
+9
-9
@@ -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")) {
|
} else if (mg_http_match_uri(hm, "/badroot")) {
|
||||||
mg_http_serve_dir(c, hm, "/BAAADDD!");
|
mg_http_serve_dir(c, hm, "/BAAADDD!");
|
||||||
} else {
|
} 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)) {
|
if (mg_url_is_ssl(url)) {
|
||||||
struct mg_tls_opts opts;
|
struct mg_tls_opts opts;
|
||||||
memset(&opts, 0, sizeof(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) {
|
if (strstr(url, "127.0.0.1") != NULL) {
|
||||||
// Local connection, use self-signed certificates
|
// Local connection, use self-signed certificates
|
||||||
opts.ca = "./tests/data/ss_ca.pem";
|
opts.ca = "./test/data/ss_ca.pem";
|
||||||
opts.cert = "./tests/data/ss_client.pem";
|
opts.cert = "./test/data/ss_client.pem";
|
||||||
}
|
}
|
||||||
mg_tls_init(c, &opts);
|
mg_tls_init(c, &opts);
|
||||||
// c->is_hexdumping = 1;
|
// c->is_hexdumping = 1;
|
||||||
@@ -436,7 +436,7 @@ static void test_http_server(void) {
|
|||||||
{
|
{
|
||||||
extern char *mg_http_etag(char *, size_t, struct stat *);
|
extern char *mg_http_etag(char *, size_t, struct stat *);
|
||||||
char etag[100];
|
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(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",
|
ASSERT(fetch(&mgr, buf, url, "GET /a.txt HTTP/1.0\nIf-None-Match: %s\n\n",
|
||||||
etag) == 304);
|
etag) == 304);
|
||||||
@@ -460,7 +460,7 @@ static void test_http_server(void) {
|
|||||||
#endif
|
#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(fetch(&mgr, buf, url, "GET /ca.pem HTTP/1.0\r\n\n") == 200);
|
||||||
ASSERT(cmpbody(data, buf) == 0);
|
ASSERT(cmpbody(data, buf) == 0);
|
||||||
free(data);
|
free(data);
|
||||||
@@ -476,8 +476,8 @@ static void test_http_server(void) {
|
|||||||
|
|
||||||
static void test_tls(void) {
|
static void test_tls(void) {
|
||||||
#if MG_ENABLE_MBEDTLS || MG_ENABLE_OPENSSL
|
#if MG_ENABLE_MBEDTLS || MG_ENABLE_OPENSSL
|
||||||
struct mg_tls_opts opts = {.ca = "./tests/data/ss_ca.pem",
|
struct mg_tls_opts opts = {.ca = "./test/data/ss_ca.pem",
|
||||||
.cert = "./tests/data/ss_server.pem"};
|
.cert = "./test/data/ss_server.pem"};
|
||||||
struct mg_mgr mgr;
|
struct mg_mgr mgr;
|
||||||
struct mg_connection *c;
|
struct mg_connection *c;
|
||||||
const char *url = "https://127.0.0.1:12347";
|
const char *url = "https://127.0.0.1:12347";
|
||||||
@@ -526,7 +526,7 @@ static void test_http_client(void) {
|
|||||||
ok = 0;
|
ok = 0;
|
||||||
#if MG_ENABLE_MBEDTLS || MG_ENABLE_OPENSSL
|
#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);
|
c = mg_http_connect(&mgr, "https://cesanta.com", f3, &ok);
|
||||||
ASSERT(c != NULL);
|
ASSERT(c != NULL);
|
||||||
mg_tls_init(c, &opts);
|
mg_tls_init(c, &opts);
|
||||||
|
|||||||
Reference in new issue
Block a user