]> gitweb.michael.orlitzky.com - libsvgtiny-pixbuf.git/commitdiff
Makefile.am,run-tests.sh: new bare-bones test suite
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 8 Aug 2023 14:41:04 +0000 (10:41 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 8 Aug 2023 14:41:04 +0000 (10:41 -0400)
Does it segfault? No? Ship it!

Makefile.am
run-tests.sh [new file with mode: 0755]

index 7912a933b35640f0bfe6aca71eb4f05ec82cc364..052f3d7e9050fb1ae20ac2fbad8207cbbb2b09e6 100644 (file)
@@ -28,6 +28,10 @@ svg2png_SOURCES = $(libpixbufloader_svg_la_SOURCES)
 svg2png_CPPFLAGS = $(libpixbufloader_svg_la_CPPFLAGS)
 svg2png_LDADD = $(libpixbufloader_svg_la_LIBADD)
 
+# Test suite
+dist_check_SCRIPTS = run-tests.sh
+TESTS = $(dist_check_SCRIPTS)
+AM_TESTS_ENVIRONMENT = export test_cases="$(top_srcdir)/test-cases";
 
 # Miscellaneous
-EXTRA_DIST = gdk_pixbuf_get_from_surface.h
+EXTRA_DIST = gdk_pixbuf_get_from_surface.h test-cases
diff --git a/run-tests.sh b/run-tests.sh
new file mode 100755 (executable)
index 0000000..cd25d0c
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Run svg2png on a few carefully chosen cases to ensure that it
+# doesn't segfault. The $test_cases variable is set by automake.  We
+# have to override some bits of gdk-pixbuf to ensure that the
+# newly-build libsvgtiny-pixbuf is used, and not the installed copy --
+# or worse, an installed copy of librsvg.
+set -e
+
+LOADERS_CACHE=$(pwd)/loaders.cache
+
+# I'm not real happy about hard-coding the name ".libs", but it works
+# for now (we need the directory where the just-built *.so file
+# lives).
+GDK_PIXBUF_MODULEDIR=.libs gdk-pixbuf-query-loaders > "${LOADERS_CACHE}"
+export GDK_PIXBUF_MODULE_FILE="${LOADERS_CACHE}"
+
+TEST_CASES=$(find ${test_cases} -type f -name '*.svg')
+for f in $TEST_CASES; do
+    g="$(basename "${f}").png"
+    echo "Converting ${f} to ${g}..."
+    ./svg2png "${f}" "${g}"
+    echo "Success."
+    rm "${g}"
+done
+
+rm "${LOADERS_CACHE}"