Skip to content

Commit

Permalink
Add some pathological cases to the testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoisin committed Jan 3, 2024
1 parent 51cc4b7 commit f0987b8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ tests: clean library_debug_unit_tests
$(CC) $(CFLAGS) $(EXE_CFLAGS) $(DEBUG_LOG_FLAGS) $(GDB_FLAGS) $(OS_FLAGS) tests/uninit_read.c $(ISO_ALLOC_PRINTF_SRC) -o $(BUILD_DIR)/uninit_read $(LDFLAGS)
$(CC) $(CFLAGS) $(EXE_CFLAGS) $(DEBUG_LOG_FLAGS) $(GDB_FLAGS) $(OS_FLAGS) tests/sized_free.c $(ISO_ALLOC_PRINTF_SRC) -o $(BUILD_DIR)/sized_free $(LDFLAGS)
$(CC) $(CFLAGS) $(EXE_CFLAGS) $(DEBUG_LOG_FLAGS) $(GDB_FLAGS) $(OS_FLAGS) tests/pool_test.c $(ISO_ALLOC_PRINTF_SRC) -o $(BUILD_DIR)/pool_test $(LDFLAGS)
$(CC) $(CFLAGS) $(EXE_CFLAGS) $(DEBUG_LOG_FLAGS) $(GDB_FLAGS) $(OS_FLAGS) tests/pathological.c $(ISO_ALLOC_PRINTF_SRC) -o $(BUILD_DIR)/pathological $(LDFLAGS)
utils/run_tests.sh

mte_test: clean
Expand Down
43 changes: 43 additions & 0 deletions tests/pathological.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* iso_alloc memset_sanity.c
* Copyright 2023 - [email protected] */

#include "iso_alloc.h"
#include "iso_alloc_internal.h"

#if !MEMSET_SANITY
#error "This test intended to be run with -DMEMSET_SANITY=1"
#endif

int main(int argc, char *argv[]) {
iso_free(iso_alloc(-1234));
iso_free(iso_alloc(-1));
iso_free(iso_alloc(0));
iso_free(iso_alloc(1));

iso_free(iso_calloc(-1234), 1);
iso_free(iso_calloc(-1), 1);
iso_free(iso_calloc(0), 1);
iso_free(iso_calloc(1), 1);
iso_free(iso_calloc(1, -1234));
iso_free(iso_calloc(1, -1));
iso_free(iso_calloc(1, 0));
iso_free(iso_calloc(1, 1));

iso_free(iso_calloc(0, 0));
iso_free(iso_calloc(0, 1));
iso_free(iso_calloc(1, 0));

iso_free(strdup(""));
iso_free(strdup(NULL));

iso_free(1, iso_realloc(NULL, -1234));
iso_free(1, iso_realloc(NULL, -1));
iso_free(1, iso_realloc(NULL, 0));
iso_free(1, iso_realloc(NULL, 1));

iso_free(iso_realloc(iso_malloc(1), 0));

iso_verify_zones();

return OK;
}
2 changes: 1 addition & 1 deletion utils/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$(echo '' > test_output.txt)

tests=("tests" "big_tests" "interfaces_test" "thread_tests" "pool_test"
"rand_freelist")
"rand_freelist", "pathological")
failure=0
succeeded=0

Expand Down

0 comments on commit f0987b8

Please sign in to comment.