[gegl] tests: Make the 'compositions' test support arbitrary reference images



commit e634d581294e3e9ed18f7063f3c93ee67dd680ef
Author: Martin Nordholts <martinn src gnome org>
Date:   Fri May 14 19:00:50 2010 +0200

    tests: Make the 'compositions' test support arbitrary reference images
    
    Generalize the compositions test makefile so we can have .gegl
    reference images too (for HDR tests for example). Also add a sample
    test that uses a .gegl (GeglBuffer) reference image. It also acts as a
    regression test for the GeglBuffer saver and loader.

 tests/compositions/Makefile.am              |   56 ++++++++++++++++++---------
 tests/compositions/hdr-color.xml            |   14 +++++++
 tests/compositions/reference/hdr-color.gegl |  Bin 0 -> 131368 bytes
 tests/compositions/verify-results.sh        |    6 ++-
 4 files changed, 56 insertions(+), 20 deletions(-)
---
diff --git a/tests/compositions/Makefile.am b/tests/compositions/Makefile.am
index a125060..7bc2123 100644
--- a/tests/compositions/Makefile.am
+++ b/tests/compositions/Makefile.am
@@ -1,42 +1,60 @@
+
+# The setup is as follows:
+#  * Each test comes with one <name>.xml GEGL XML and one reference
+#    output file in 'reference' called <name>.<ext>, where <ext> is a
+#    supported output file type.
+#  * The test is run by putting the XML into a file in 'output', named
+#    <name>.<ext> and then compared with the file in 'reference'. If
+#    these files are equal, the test is a 'pass'.
+
+
 SUBDIRS=data
 
-EXTRA_DIST=$(wildcard *.xml) $(wildcard reference/*.png) verify-results.sh
+EXTRA_DIST=$(wildcard *.xml) $(wildcard reference/*) verify-results.sh
+
+# Env vars to make binaries use builddir stuff
+builddir_gegl_env = GEGL_SWAP=RAM GEGL_PATH=$(top_builddir)/operations
+
+# Binary paths
+gegl_bin = $(top_builddir)/bin/gegl$(EXEEXT)
+img_cmp_bin = $(top_builddir)/tools/img_cmp$(EXEEXT)
+
+# Commands run in a builddir env
+builddir_gegl = $(builddir_gegl_env) $(gegl_bin)
+builddir_img_cmp = $(builddir_gegl_env) $(img_cmp_bin)
 
-output/%.png: %.xml
-	@echo $@ > /tmp/a ;\
-	GEGL_SWAP=RAM GEGL_PATH=$(top_builddir)/operations \
-	$(top_builddir)/bin/gegl$(EXEEXT) $< -o $@ 
 
+# For simplicity, use the same time stamp for output of all
+# compositions. Use the same output file as in the reference dir
 images.stamp: $(wildcard $(srcdir)/*.xml) \
               $(wildcard $(top_builddir)/operations/*/*$(SHREXT)) \
 	      $(top_builddir)/gegl/libgegl-$(GEGL_API_VERSION).la \
-	      $(top_builddir)/bin/gegl$(EXEEXT)
-	@echo "--[updating test renders]--"; \
-	mkdir output || true > /dev/null;
-	test -e reference || ln -s $(srcdir)/reference reference || true > /dev/null;
-	for XML in $(srcdir)/*.xml; do \
+	      $(gegl_bin)
+	@echo "--[doing XML composition test renderings]--"
+	@mkdir -p ./output
+	@for XML in $(srcdir)/*.xml; do \
+	    echo $$XML; \
 	    export BASE=`echo $$XML | sed s?$(srcdir)/?? | sed s/\.xml//`;\
-            PNG=$$BASE".png";\
-	    echo $${XML}; \
-	   $(MAKE) "output/$$PNG" >/dev/null; \
+	    $(builddir_gegl) $$XML -o output/`basename $(srcdir)/reference/$$BASE.*`; \
 	done
 	@touch images.stamp
 
+# Read by verify-results.sh
+TESTS_ENVIRONMENT = VERIFY_RESULTS_REFERENCE=$(srcdir)/reference
 
 TESTS = verify-results.sh
 verify-results.sh: tests-report
 
 tests-report: images.stamp \
               $(top_srcdir)/tools/img_cmp \
-              $(srcdir)/output/*.png \
-              $(srcdir)/reference/*.png
+              $(srcdir)/reference/*
+	@echo "--[Verifying test renderings against references]--"
 	@echo "" > tests-report ;
 	@for XML in $(srcdir)/*.xml; do\
+	    echo $$XML; \
 	    export BASE=`echo $$XML | sed s?$(srcdir)/?? | sed s/\.xml//`;\
-	    PNG=$$BASE".png";\
-            GEGL_SWAP=RAM GEGL_PATH=$(top_builddir)/operations \
-	    $(top_builddir)/tools/img_cmp $(srcdir)/reference/$$PNG output/$$PNG >> tests-report; true ;\
+	    $(builddir_img_cmp) $(srcdir)/reference/$$BASE.* output/$$BASE.* >> tests-report; true ;\
 	   done;
 
 clean-local:
-	rm -f images.stamp *.png output/*.png *.txt tests-report
+	rm -f images.stamp output/* *.txt tests-report
diff --git a/tests/compositions/hdr-color.xml b/tests/compositions/hdr-color.xml
new file mode 100644
index 0000000..f147c16
--- /dev/null
+++ b/tests/compositions/hdr-color.xml
@@ -0,0 +1,14 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+  <node operation='gegl:crop'>
+    <params>
+      <param name='width'>10.000000</param>
+      <param name='height'>10.000000</param>
+    </params>
+  </node>
+  <node operation='gegl:color'>
+    <params>
+      <param name='value'>rgb(100.0, 100.0, 100.0)</param>
+    </params>
+  </node>
+</gegl>
diff --git a/tests/compositions/reference/hdr-color.gegl b/tests/compositions/reference/hdr-color.gegl
new file mode 100644
index 0000000..c052b65
Binary files /dev/null and b/tests/compositions/reference/hdr-color.gegl differ
diff --git a/tests/compositions/verify-results.sh b/tests/compositions/verify-results.sh
index b30a58a..dec264c 100755
--- a/tests/compositions/verify-results.sh
+++ b/tests/compositions/verify-results.sh
@@ -1,5 +1,9 @@
 #!/bin/sh
-total_tests=`ls -1 reference | wc -l`
+
+# Set by TESTS_ENVIRONMENT in Makefile.am
+reference_dir=$VERIFY_RESULTS_REFERENCE
+
+total_tests=`ls -1 $reference_dir | wc -l`
 successful_tests=`cat tests-report | grep identical | wc -l`
 
 if [ $total_tests -eq $successful_tests ]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]