mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-22 11:36:21 +00:00
Better coverage
This commit is contained in:
1 parent
37e9a2ee95
commit
d806ed5d5f
4 files changed
+26
-10
No files matched your search
@@ -56,6 +56,7 @@ test: mongoose.c mongoose.h Makefile test/unit_test.c
|
||||
|
||||
coverage: test
|
||||
gcov -l -n *.gcno | sed '/^$$/d' | sed 'N;s/\n/ /'
|
||||
gcov mongoose.gcno >/dev/null
|
||||
|
||||
infer:
|
||||
infer run -- cc test/unit_test.c -c -W -Wall -Werror -Isrc -I. -O2 -DMG_ENABLE_MBEDTLS=1 -DMG_ENABLE_LINES -I/usr/local/Cellar/mbedtls/2.23.0/include -DMG_ENABLE_IPV6=1 -g -o /dev/null
|
||||
|
||||
+2
-2
@@ -2694,8 +2694,8 @@ static void connect_conn(struct mg_connection *c) {
|
||||
if (rc == EAGAIN || rc == EWOULDBLOCK) rc = 0;
|
||||
c->is_connecting = 0;
|
||||
if (rc) {
|
||||
mg_call(c, MG_EV_ERROR, (void *) "connect error");
|
||||
c->is_closing = 1;
|
||||
char buf[40];
|
||||
mg_error(c, "error connecting to %s", mg_straddr(c, buf, sizeof(buf)));
|
||||
} else {
|
||||
if (c->is_tls_hs && mg_tls_handshake(c)) {
|
||||
c->is_tls_hs = 0;
|
||||
|
||||
+2
-2
@@ -475,8 +475,8 @@ static void connect_conn(struct mg_connection *c) {
|
||||
if (rc == EAGAIN || rc == EWOULDBLOCK) rc = 0;
|
||||
c->is_connecting = 0;
|
||||
if (rc) {
|
||||
mg_call(c, MG_EV_ERROR, (void *) "connect error");
|
||||
c->is_closing = 1;
|
||||
char buf[40];
|
||||
mg_error(c, "error connecting to %s", mg_straddr(c, buf, sizeof(buf)));
|
||||
} else {
|
||||
if (c->is_tls_hs && mg_tls_handshake(c)) {
|
||||
c->is_tls_hs = 0;
|
||||
|
||||
+21
-6
@@ -433,7 +433,10 @@ static int cmpbody(const char *buf, const char *str) {
|
||||
}
|
||||
|
||||
static void eh9(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
if (ev == MG_EV_ERROR) *(void **) fn_data = ev_data;
|
||||
if (ev == MG_EV_ERROR) {
|
||||
ASSERT(!strcmp((char *) ev_data, "error connecting to 127.0.0.1:55117"));
|
||||
*(int *) fn_data = 7;
|
||||
}
|
||||
(void) c;
|
||||
}
|
||||
|
||||
@@ -484,11 +487,10 @@ static void test_http_server(void) {
|
||||
|
||||
{
|
||||
// Test connection refused
|
||||
char *msg = NULL;
|
||||
int i;
|
||||
mg_connect(&mgr, "tcp://127.0.0.1:55117", eh9, &msg);
|
||||
for (i = 0; i < 10; i++) mg_mgr_poll(&mgr, 1);
|
||||
ASSERT(msg != NULL && strcmp(msg, "connect error") == 0);
|
||||
int i, errored = 0;
|
||||
mg_connect(&mgr, "tcp://127.0.0.1:55117", eh9, &errored);
|
||||
for (i = 0; i < 10 && errored == 0; i++) mg_mgr_poll(&mgr, 1);
|
||||
ASSERT(errored == 7);
|
||||
}
|
||||
|
||||
// HEAD request
|
||||
@@ -712,6 +714,19 @@ static void test_http_parse(void) {
|
||||
ASSERT(mg_vcmp(v, "5") == 0);
|
||||
ASSERT((v = mg_http_get_header(&req, "f")) == NULL);
|
||||
}
|
||||
|
||||
{
|
||||
struct mg_connection c;
|
||||
struct mg_str s,
|
||||
res = mg_str("GET /\r\nAuthorization: Basic Zm9vOmJhcg==\r\n\r\n");
|
||||
memset(&c, 0, sizeof(c));
|
||||
mg_printf(&c, "%s", "GET /\r\n");
|
||||
mg_http_bauth(&c, "foo", "bar");
|
||||
mg_printf(&c, "%s", "\r\n");
|
||||
s = mg_str_n((char *) c.send.buf, c.send.len);
|
||||
ASSERT(mg_strcmp(s, res) == 0);
|
||||
mg_iobuf_free(&c.send);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_http_range(void) {
|
||||
|
||||
Reference in new issue
Block a user