mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Added negative test scenarios
This commit is contained in:
parent
304c21260e
commit
f51e482449
7 changed files with 34 additions and 1 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ERROR: pop_extra_root: extra_roots are empty
|
||||||
|
: Success
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ERROR: push_extra_roots: extra_roots_pool overflow
|
||||||
|
: Success
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
ERROR: pop_extra_root: stack invariant violation
|
||||||
|
: Success
|
||||||
5
runtime/negative_scenarios/extra_roots_empty_pop_neg.c
Normal file
5
runtime/negative_scenarios/extra_roots_empty_pop_neg.c
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "../gc.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
int main () { pop_extra_root((void **)NULL); }
|
||||||
7
runtime/negative_scenarios/extra_roots_overflow_neg.c
Normal file
7
runtime/negative_scenarios/extra_roots_overflow_neg.c
Normal 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); }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "../gc.h"
|
||||||
|
|
||||||
|
int main () {
|
||||||
|
push_extra_root(NULL);
|
||||||
|
pop_extra_root((void **)239);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue