Added valgrind to the CI, fixed tests

This exposed an issue with my dev environment, which I had to patch.

Fixed #153
This commit is contained in:
2024-11-17 18:49:40 +11:00
parent 2f9489d5fd
commit 7398898a61
12 changed files with 63 additions and 25 deletions

View File

@@ -81,4 +81,4 @@ build-run-valgrind: $(addprefix $(TEST_OUTDIR)/,$(notdir $(TEST_CASESFILES:%.c=%
.PRECIOUS: $(TEST_OUTDIR)/%.run-valgrind
$(TEST_OUTDIR)/%.run-valgrind: $(TEST_OUTDIR)/%.exe
valgrind $< --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes $<

View File

@@ -210,7 +210,7 @@ int test_string_concatenation() {
//check the refcounts
if (strlen(buffer) != 11 ||
strcmp(buffer, "Hello world") != 0)
strncmp(buffer, "Hello world", 11) != 0)
{
fprintf(stderr, TOY_CC_ERROR "ERROR: Failed to get the raw buffer from concatenated string\n" TOY_CC_RESET);
free(buffer);
@@ -267,7 +267,7 @@ int test_string_with_stressed_bucket() {
//grab the buffer
char* buffer = Toy_getStringRawBuffer(str);
if (strcmp(buffer, "thequickbrownfoxjumpedoverthelazydog") != 0 ||
if (strncmp(buffer, "thequickbrownfoxjumpedoverthelazydog", 36) != 0 ||
strlen(buffer) != 36)
{
fprintf(stderr, TOY_CC_ERROR "ERROR: Unexpected state of the raw buffer after string stress test: '%s'\n" TOY_CC_RESET, buffer);

View File

@@ -49,7 +49,7 @@ valgrind: source repl run-valgrind
run-valgrind: $(TEST_SCRIPTFILES:.toy=.toy-valgrind)
%.toy-valgrind: %.toy
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose $(TEST_OUTDIR)/$(TEST_REPLNAME) -f ../$< --verbose
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes $(TEST_OUTDIR)/$(TEST_REPLNAME) -f ../$< --verbose
#compile the source and repl first
source: $(TEST_OBJDIR) $(TEST_OUTDIR)