Added negative test scenarios

This commit is contained in:
Egor Sheremetov 2023-10-04 05:23:14 +02:00
parent 304c21260e
commit f51e482449
7 changed files with 34 additions and 1 deletions

View file

@ -9,6 +9,15 @@ INVARIANTS_CHECK_FLAGS=$(TEST_FLAGS) -DFULL_INVARIANT_CHECKS
all: gc.o runtime.o all: gc.o runtime.o
ar rc runtime.a runtime.o gc.o ar rc runtime.a runtime.o gc.o
NEGATIVE_TESTS=$(sort $(basename $(notdir $(wildcard negative_scenarios/*_neg.c))))
$(NEGATIVE_TESTS): %: negative_scenarios/%.c
@echo "Running test $@"
@$(CC) -o $@.o $(COMMON_FLAGS) negative_scenarios/$@.c gc.c
@./$@.o 2> negative_scenarios/$@.err || diff negative_scenarios/$@.err negative_scenarios/expected/$@.err
negative_tests: $(NEGATIVE_TESTS)
# this is a target that runs unit tests, scenarios are written in a single file `test_main.c` # this is a target that runs unit tests, scenarios are written in a single file `test_main.c`
unit_tests.o: gc.c gc.h runtime.c runtime.h runtime_common.h virt_stack.c virt_stack.h test_main.c test_util.s unit_tests.o: gc.c gc.h runtime.c runtime.h runtime_common.h virt_stack.c virt_stack.h test_main.c test_util.s
$(CC) -o unit_tests.o $(UNIT_TESTS_FLAGS) gc.c virt_stack.c runtime.c test_main.c test_util.s $(CC) -o unit_tests.o $(UNIT_TESTS_FLAGS) gc.c virt_stack.c runtime.c test_main.c test_util.s
@ -32,4 +41,4 @@ runtime.o: runtime.c runtime.h
$(CC) $(PROD_FLAGS) -c runtime.c $(CC) $(PROD_FLAGS) -c runtime.c
clean: clean:
$(RM) *.a *.o *~ $(RM) *.a *.o *~ negative_scenarios/*.err

View file

@ -0,0 +1,2 @@
ERROR: pop_extra_root: extra_roots are empty
: Success

View file

@ -0,0 +1,2 @@
ERROR: push_extra_roots: extra_roots_pool overflow
: Success

View file

@ -0,0 +1,2 @@
ERROR: pop_extra_root: stack invariant violation
: Success

View file

@ -0,0 +1,5 @@
#include "../gc.h"
#include <stddef.h>
int main () { pop_extra_root((void **)NULL); }

View file

@ -0,0 +1,7 @@
#include "../gc.h"
#include <stddef.h>
int main () {
for (size_t i = 0; i < MAX_EXTRA_ROOTS_NUMBER + 1; ++i) { push_extra_root(NULL); }
}

View file

@ -0,0 +1,6 @@
#include "../gc.h"
int main () {
push_extra_root(NULL);
pop_extra_root((void **)239);
}