Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some pathological cases to the testsuite #223

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ libc_sanity_tests: clean library_debug_unit_tests
$(CC) $(CFLAGS) $(EXE_CFLAGS) $(DEBUG_LOG_FLAGS) $(GDB_FLAGS) $(OS_FLAGS) tests/memcpy_sanity.c $(ISO_ALLOC_PRINTF_SRC) -o $(BUILD_DIR)/memcpy_sanity $(LDFLAGS)
$(CC) $(CFLAGS) $(EXE_CFLAGS) $(DEBUG_LOG_FLAGS) $(GDB_FLAGS) $(OS_FLAGS) tests/memmove_sanity.c $(ISO_ALLOC_PRINTF_SRC) -o $(BUILD_DIR)/memmove_sanity $(LDFLAGS)
$(CC) $(CFLAGS) $(EXE_CFLAGS) $(DEBUG_LOG_FLAGS) $(GDB_FLAGS) $(OS_FLAGS) tests/bzero_sanity.c $(ISO_ALLOC_PRINTF_SRC) -o $(BUILD_DIR)/bzero_sanity $(LDFLAGS)
build/memset_sanity ; build/memcpy_sanity; build/memmove_sanity; build/bzero_sanity ;
$(CC) $(CFLAGS) $(EXE_CFLAGS) $(DEBUG_LOG_FLAGS) $(GDB_FLAGS) $(OS_FLAGS) tests/pathological.c $(ISO_ALLOC_PRINTF_SRC) -o $(BUILD_DIR)/pathological $(LDFLAGS)
build/memset_sanity; build/memcpy_sanity; build/memmove_sanity; build/bzero_sanity; build/pathological;

fuzz_test: clean library_debug_unit_tests
@echo "make fuzz_test"
Expand Down
44 changes: 44 additions & 0 deletions tests/pathological.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* 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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy paste artifact? Also up top in the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How so? It's part of the sanity part of the tests

#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(iso_strdup(""));
iso_free(iso_strdup(NULL));

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

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

iso_verify_zones();

return OK;
}
Loading