Michał Górny avatar Michał Górny committed c27e28b

Support running tests using autotools.

Comments (0)

Files changed (6)

 bin_PROGRAMS = mirage2iso
 
+SUBDIRS = tests
+
 mirage2iso_SOURCES = mirage2iso.c mirage-compat.h \
 	mirage-password.c mirage-password.h mirage-wrapper.c mirage-wrapper.h
 mirage2iso_LDADD = $(GLIB_LIBS) $(LIBMIRAGE_LIBS) $(LIBASSUAN_LIBS)
 mirage2iso_CPPFLAGS = $(GLIB_CFLAGS) $(LIBMIRAGE_CFLAGS) $(LIBASSUAN_CFLAGS)
+
+check-recursive: mirage2iso
 AC_PREREQ([2.60])
 AC_INIT([mirage2iso], [0.3])
 AC_CONFIG_AUX_DIR([build-aux])
-AM_INIT_AUTOMAKE([1.6 foreign dist-bzip2 no-dependencies])
+AM_INIT_AUTOMAKE([1.11 foreign dist-bzip2 no-dependencies parallel-tests])
 
 AC_PROG_CC_C99
 AC_USE_SYSTEM_EXTENSIONS
 	[AC_DEFINE([HAVE_TERMIOS], [1], [Define if you have termios headers and functions])])
 
 AC_CONFIG_HEADER([mirage-config.h])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile tests/Makefile])
 AC_OUTPUT

tests/Makefile.am

+TESTS = 00_input.iso \
+	01_poweriso_bin.bin 01_poweriso_bin.cue 01_poweriso_bin.toc \
+	02_poweriso-4.6-bestcompression.daa 02_poweriso-4.6-encrypted.daa \
+	02_poweriso-4.6-split1.part01.daa 02_poweriso-4.6-split2.part001.daa 02_poweriso-4.6-split3.daa \
+	03_nerolinux-4.0.0.nrg \
+	04_alcohol120_2.0.0.1331.mds \
+	04_nerolinux-4.0.0-multisession.nrg
+
+EXTRA_DIST = perform-test
+
+LOG_COMPILER = $(srcdir)/perform-test
+AM_LOG_FLAGS = @top_builddir@/mirage2iso
+
+clean-tests-extra:
+	for t in $(TESTS); do rm -f $${t}.iso $${t}.iso.2; done
+
+clean-am: clean-tests-extra

tests/perform-test

+#!/bin/sh
+
+m2i=${1}
+input=${2}
+output=${2}.iso
+base=00_input.iso
+
+echo "${input} -> ${output}"
+
+set -x
+case "$(basename "${input}")" in
+	04_*)
+		base2=00_second.iso
+		output2=${output}.2
+
+		"${m2i}" -q -s 0 -p test "${input}" "${output}" && \
+			cmp "${base}" "${output}" && \
+			"${m2i}" -q -s 1 -p test "${input}" "${output2}" && \
+			cmp "${base2}" "${output2}"
+		;;
+	*)
+		"${m2i}" -q -s 0 -p test "${input}" "${output}" && \
+			cmp "${base}" "${output}"
+		;;
+esac

tests/tests-gen.awk

-#!/usr/bin/awk -f
-
-BEGIN {
-	print "MIRAGE2ISO = mirage2iso"
-	print "INPUT = 00_input.iso"
-	print "SECOND = 00_second.iso"
-	print
-	print "all:"
-	print "preclean:"
-	print "	rm -f tests-failed"
-
-	failpart = " || ( echo '	$<' >> tests-failed; false )"
-}
-
-{
-	print $2 ": " $1 " preclean"
-	print "	$(MIRAGE2ISO) -q -s 0 -p test $< $@" failpart
-	print "	cmp $(INPUT) $@" failpart
-
-	all = all " " $2
-
-	if ($3) {
-		print $3 ": " $1 " preclean"
-		print "	$(MIRAGE2ISO) -q -s 1 -p test $< $@" failpart
-		print "	cmp $(SECOND) $@" failpart
-
-		all = all " " $3
-	}
-}
-
-END {
-	print "tests: " all
-	print "clean: preclean"
-	print "	rm -f " all
-	print "distclean: clean"
-	print "	rm -f Makefile"
-	print "install:"
-	print ".PHONY: all tests clean distclean install"
-}

tests/tests-list

-00_input.iso 00_input.iso.iso
-01_poweriso_bin.bin 01_poweriso_bin.iso
-01_poweriso_bin.cue 01_poweriso_bin_cue.iso
-01_poweriso_bin.toc 01_poweriso_bin_toc.iso
-02_poweriso-4.6-bestcompression.daa 02_poweriso-4.6-bestcompression.iso
-02_poweriso-4.6-encrypted.daa 02_poweriso-4.6-encrypted.iso
-02_poweriso-4.6-split1.part01.daa 02_poweriso-4.6-split1.part01.iso
-02_poweriso-4.6-split2.part001.daa 02_poweriso-4.6-split2.part001.iso
-02_poweriso-4.6-split3.daa 02_poweriso-4.6-split3.iso
-03_nerolinux-4.0.0.nrg 03_nerolinux-4.0.0.iso
-04_alcohol120_2.0.0.1331.mds 04_alcohol120_2.0.0.1331_s1.iso 04_alcohol120_2.0.0.1331_s2.iso
-04_nerolinux-4.0.0-multisession.nrg 04_nerolinux-4.0.0-multisession_s1.iso 04_nerolinux-4.0.0-multisession_s2.iso
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.