From 8ba07cb81ace89edf67bc4c8d2aeebc7e48195f5 Mon Sep 17 00:00:00 2001 From: Kamal Mostafa Date: Tue, 21 Jun 2011 20:26:00 -0700 Subject: [PATCH] make check: runs testcases/ --- src/Makefile.am | 16 +-- src/Makefile.in | 136 ++++++++++++++++++----- src/{ => testcases}/self-test-baudot.txt | 0 src/testcases/test.01-self-test-1200 | 2 + src/testcases/test.02-self-test-300 | 2 + src/testcases/test.03-self-test-rtty | 2 + src/testcases/test.04-self-test-0.5 | 5 + 7 files changed, 123 insertions(+), 40 deletions(-) rename src/{ => testcases}/self-test-baudot.txt (100%) create mode 100755 src/testcases/test.01-self-test-1200 create mode 100755 src/testcases/test.02-self-test-300 create mode 100755 src/testcases/test.03-self-test-rtty create mode 100755 src/testcases/test.04-self-test-0.5 diff --git a/src/Makefile.am b/src/Makefile.am index 27b44b0..c0b5ae6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,8 +14,9 @@ INCLUDES = $(DEPS_CFLAGS) bin_PROGRAMS = minimodem -EXTRA_DIST = self-test self-test-baudot.txt # run-test +EXTRA_DIST = self-test testcases/* # run-test +TESTS = testcases/test.* SIMPLEAUDIO_SRC = \ simpleaudio.h \ @@ -32,16 +33,3 @@ BAUDOT_SRC = baudot.h baudot.c minimodem_LDADD = $(DEPS_LIBS) minimodem_SOURCES = minimodem.c $(BAUDOT_SRC) $(FSK_SRC) $(SIMPLEAUDIO_SRC) - -test: - for file in simpleaudio.[ch] ; \ - do { for rate in 1200 300 50; \ - do ./self-test $$rate $$file || exit; \ - done }; \ - done - ./self-test rtty self-test-baudot.txt - [ ! -f ./run-test ] || ./run-test - @echo - @echo "minimodem: ALL TESTS PASS" - @echo - diff --git a/src/Makefile.in b/src/Makefile.in index 4facf9e..7655d5b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -75,6 +75,8 @@ SOURCES = $(minimodem_SOURCES) DIST_SOURCES = $(minimodem_SOURCES) ETAGS = etags CTAGS = ctags +am__tty_colors = \ +red=; grn=; lgn=; blu=; std= DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ @@ -166,7 +168,8 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -Wall -Werror INCLUDES = $(DEPS_CFLAGS) -EXTRA_DIST = self-test self-test-baudot.txt # run-test +EXTRA_DIST = self-test testcases/* # run-test +TESTS = testcases/test.* SIMPLEAUDIO_SRC = \ simpleaudio.h \ simpleaudio_internal.h \ @@ -334,6 +337,98 @@ GTAGS: distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + echo "$$grn$$dashes"; \ + else \ + echo "$$red$$dashes"; \ + fi; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes$$std"; \ + test "$$failed" -eq 0; \ + else :; fi + distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -365,6 +460,7 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(PROGRAMS) installdirs: @@ -465,34 +561,22 @@ ps-am: uninstall-am: uninstall-binPROGRAMS -.MAKE: install-am install-strip +.MAKE: check-am install-am install-strip -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic ctags distclean distclean-compile \ - distclean-generic distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-binPROGRAMS \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-binPROGRAMS +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-binPROGRAMS clean-generic ctags distclean \ + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS -test: - for file in simpleaudio.[ch] ; \ - do { for rate in 1200 300 50; \ - do ./self-test $$rate $$file || exit; \ - done }; \ - done - ./self-test rtty self-test-baudot.txt - [ ! -f ./run-test ] || ./run-test - @echo - @echo "minimodem: ALL TESTS PASS" - @echo - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/self-test-baudot.txt b/src/testcases/self-test-baudot.txt similarity index 100% rename from src/self-test-baudot.txt rename to src/testcases/self-test-baudot.txt diff --git a/src/testcases/test.01-self-test-1200 b/src/testcases/test.01-self-test-1200 new file mode 100755 index 0000000..93989d0 --- /dev/null +++ b/src/testcases/test.01-self-test-1200 @@ -0,0 +1,2 @@ +# use fsk.c as the sample text file +exec ./self-test 1200 fsk.c diff --git a/src/testcases/test.02-self-test-300 b/src/testcases/test.02-self-test-300 new file mode 100755 index 0000000..96ad090 --- /dev/null +++ b/src/testcases/test.02-self-test-300 @@ -0,0 +1,2 @@ +# use fsk.c as the sample text file +exec ./self-test 300 fsk.c diff --git a/src/testcases/test.03-self-test-rtty b/src/testcases/test.03-self-test-rtty new file mode 100755 index 0000000..7576d75 --- /dev/null +++ b/src/testcases/test.03-self-test-rtty @@ -0,0 +1,2 @@ +# use self-test-baudot.txt as the sample text file +exec ./self-test rtty testcases/self-test-baudot.txt diff --git a/src/testcases/test.04-self-test-0.5 b/src/testcases/test.04-self-test-0.5 new file mode 100755 index 0000000..a45bff5 --- /dev/null +++ b/src/testcases/test.04-self-test-0.5 @@ -0,0 +1,5 @@ +#!/bin/bash +TMPF=/tmp/minimodem-test.$$ +trap "rm -f $TMPF" 0 +echo "KAMAL" > $TMPF +./self-test 0.5 $TMPF