use make realclean define GENFILES
[libfirm] / testprograms / Makefile.in
index 96c452e..04615eb 100644 (file)
@@ -10,6 +10,8 @@ srcdir = @srcdir@
 topdir = ..
 subdir := testprograms
 
+DIFF ?= diff
+REF_DIR = $(srcdir)/ref-results
 
 SOURCES := Makefile.in \
        array-heap_example.c   empty.c                irr_cf_example.c          \
@@ -20,10 +22,11 @@ SOURCES := Makefile.in \
        dead_block_example.c   inheritance_example.c  while_example.c           \
        endless_loop.c         global_cse.c           oo_inline_example.c
 
+GENFILES = %.vcg results.txt
+
 bin_EXAMPLES = $(CFILES:.c=)
 run_bin_EXAMPLES = $(patsubst %.c,./%;,$(CFILES))
 
-
 include $(topdir)/MakeRules
 
 CPPFLAGS += -I$(top_srcdir)/ir/adt -I$(top_srcdir)/ir/common -I$(top_srcdir)/ir/debug \
@@ -41,3 +44,18 @@ all: $(bin_EXAMPLES) $(topdir)/libfirm.a
 
 run:
        $(run_bin_EXAMPLES)
+
+test:   realclean all
+       ($(run_bin_EXAMPLES))>run-result.txt
+       -$(RM) $(REF_DIR)/All_types.vcg $(REF_DIR)/*-type.vcg $(REF_DIR)/*-all.vcg  # contains pointers that differ from run to run -- change!!! debug-ints!!
+       ($(DIFF) run-result.txt $(REF_DIR)/run-result.txt) || (echo Libfirm test failed; exit 1)
+       for g in $(REF_DIR)/*.vcg; do\
+               ($(DIFF) -s `basename $$g` $$g)||   (echo Libfirm test failed; exit 1) \
+       done;
+       @echo Libfirm test successful
+
+reference: realclean all
+       $(RM) $(REF_DIR)/*.vcg
+       ($(run_bin_EXAMPLES))>$(REF_DIR)/run-result.txt
+       rm All_types.vcg  *-type.vcg *-all.vcg    # contains pointers that differ from run to run -- change!!! debug-ints!!
+       install -c -m0644 *.vcg $(REF_DIR)