mirror of
https://github.com/cesanta/mongoose.git
synced 2025-01-18 23:53:15 +08:00
Fix #1483 - add valgrind target, do not use stdlib strcasecmp()
This commit is contained in:
parent
870431dc1a
commit
8c447a95dd
6
Makefile
6
Makefile
@ -70,7 +70,7 @@ fuzz: fuzzer
|
||||
# make CC=/usr/local/opt/llvm\@8/bin/clang ASAN_OPTIONS=detect_leaks=1
|
||||
test: mongoose.h Makefile $(SRCS)
|
||||
$(CC) $(SRCS) $(CFLAGS) -coverage $(LDFLAGS) -g -o unit_test
|
||||
ASAN1OPTIONS=$(ASAN_OPTIONS) $(RUN) ./unit_test
|
||||
ASAN_OPTIONS=$(ASAN_OPTIONS) $(RUN) ./unit_test
|
||||
|
||||
coverage: test
|
||||
gcov -l -n *.gcno | sed '/^$$/d' | sed 'N;s/\n/ /'
|
||||
@ -79,6 +79,10 @@ coverage: test
|
||||
upload-coverage: coverage
|
||||
curl -s https://codecov.io/bash | /bin/bash
|
||||
|
||||
valgrind: ASAN =
|
||||
valgrind: RUN = valgrind --tool=memcheck --gen-suppressions=all --leak-check=full --show-leak-kinds=all --leak-resolution=high --track-origins=yes --error-exitcode=1 --exit-on-first-error=yes
|
||||
valgrind: test
|
||||
|
||||
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
|
||||
|
||||
|
@ -3745,7 +3745,7 @@ static char *mg_ssi(const char *path, const char *root, int depth) {
|
||||
struct mg_iobuf b = {NULL, 0, 0};
|
||||
FILE *fp = fopen(path, "rb");
|
||||
if (fp != NULL) {
|
||||
char buf[BUFSIZ], arg[sizeof(buf)];
|
||||
char buf[BUFSIZ] = "", arg[sizeof(buf)] = "";
|
||||
int ch, intag = 0;
|
||||
size_t len = 0, align = MG_IO_SIZE;
|
||||
while ((ch = fgetc(fp)) != EOF) {
|
||||
|
@ -11,7 +11,7 @@ static char *mg_ssi(const char *path, const char *root, int depth) {
|
||||
struct mg_iobuf b = {NULL, 0, 0};
|
||||
FILE *fp = fopen(path, "rb");
|
||||
if (fp != NULL) {
|
||||
char buf[BUFSIZ], arg[sizeof(buf)];
|
||||
char buf[BUFSIZ] = "", arg[sizeof(buf)] = "";
|
||||
int ch, intag = 0;
|
||||
size_t len = 0, align = MG_IO_SIZE;
|
||||
while ((ch = fgetc(fp)) != EOF) {
|
||||
|
@ -1212,15 +1212,10 @@ static bool sn(const char *fmt, ...) {
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool sccmp(const char *s1, const char *s2) {
|
||||
static bool sccmp(const char *s1, const char *s2, int expected) {
|
||||
int n1 = mg_casecmp(s1, s2);
|
||||
#if MG_ARCH == MG_ARCH_UNIX
|
||||
int n2 = strcasecmp(s1, s2);
|
||||
#else
|
||||
int n2 = mg_casecmp(s1, s2); // On MSVC98, _stricmp() is buggy
|
||||
#endif
|
||||
MG_INFO(("[%s] [%s] %d %d", s1, s2, n1, n2));
|
||||
return n1 == n2;
|
||||
MG_INFO(("[%s] [%s] %d %d", s1, s2, n1, expected));
|
||||
return n1 == expected;
|
||||
}
|
||||
|
||||
static void test_str(void) {
|
||||
@ -1234,11 +1229,11 @@ static void test_str(void) {
|
||||
ASSERT(mg_strstr(mg_str("abc"), mg_str("b")) != NULL);
|
||||
ASSERT(mg_strcmp(mg_str("hi"), mg_strstrip(mg_str(" \thi\r\n"))) == 0);
|
||||
|
||||
ASSERT(sccmp("", ""));
|
||||
ASSERT(sccmp("", "1"));
|
||||
ASSERT(sccmp("a", "A"));
|
||||
ASSERT(sccmp("a1", "A"));
|
||||
ASSERT(sccmp("a", "A1"));
|
||||
ASSERT(sccmp("", "", 0));
|
||||
ASSERT(sccmp("", "1", -49));
|
||||
ASSERT(sccmp("a", "A", 0));
|
||||
ASSERT(sccmp("a1", "A", 49));
|
||||
ASSERT(sccmp("a", "A1", -49));
|
||||
|
||||
ASSERT(sn("%d", 0));
|
||||
ASSERT(sn("%d", 1));
|
||||
|
Loading…
Reference in New Issue
Block a user