diff --git a/tests/Makefile b/tests/Makefile index bcffa41c..f691b5f0 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -63,7 +63,7 @@ depend: # Clean ##################################################################################################### -check: depend +check: depend checkfail $(MAKE) `ls test-*.c|$(SED) 's/\.c/\.log/g'` clean: @@ -74,6 +74,18 @@ clean: distclean: clean $(RM) *.depend depend +checkfail: fail-no-oplist + + +##################################################################################################### +# Proper failure generation (test if the code properly fails to compile) +##################################################################################################### + +# TODO: should grep failure message? +fail-no-oplist: + for i in 1 2 3 4 5 6 ; do \ + if $(CC) $(CFLAGS) $(CPPFLAGS) -g -c fail-no-oplist.c -o tmp.o -DTEST=$$i 2> fail-no-oplist-$$i.log ; then echo FAILURE: fail-no-oplist-$$i ; false; else echo OK: fail-no-oplist-$$i ; fi \ + done ##################################################################################################### # Code generation analysis diff --git a/tests/fail-no-oplist.c b/tests/fail-no-oplist.c new file mode 100644 index 00000000..278f2d14 --- /dev/null +++ b/tests/fail-no-oplist.c @@ -0,0 +1,48 @@ +#include "m-core.h" + +#if !defined(TEST) +# warning Please define TEST variable to select the test to run + +#elif TEST == 1 + +/* Test of the call to no default function */ +#define OP (INIT(init)) + +void f(int x, int y) { + M_CALL_SWAP(OP, x, y); +} + +#elif TEST == 2 + +void f(int x, int y) { + M_CALL_SET(M_VALID_OPLIST(DEFAULT_OPLIST), x, y); +} + +#elif TEST == 3 + +#include "m-array.h" +ARRAY_DEF(array, int, DEFAULT_OPLIST) + +#elif TEST == 4 + +#include "m-list.h" +LIST_DEF(list, int, DEFAULT_OPLIST) + +#elif TEST == 5 + +#include "m-deque.h" +DEQUE_DEF(deque, int, DEFAULT_OPLIST) + +#elif TEST == 6 + +#include "m-i-list.h" +typedef struct tmp_str_s { + ILIST_INTERFACE(tmpstr, struct tmp_str_s); + int n; +} tmp_str_t; +ILIST_DEF(tmpstr, tmp_str_t, DEFAULT_OPLIST) + +#else +# warning TEST variable is out of range. +#endif +