From 8bd85461621fb0ff18059305a6c1aecdbc18016c Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Sun, 18 Mar 2012 22:19:49 -0700 Subject: [PATCH] Parser test cleanup Major cleanup of parser tests. * Change test data directory layout to ease test automation. * Remove some unneeded files. * Re-write test wraper script, rename to run-parser-tests. * Rework for autotools. Signed-off-by: Geoff Levand --- configure.ac.in | 1 + test/Makefile.am | 20 +---- test/parser-test.sh | 25 ------ test/parser/004/rootdev | 1 - test/parser/Makefile.am | 80 +++++++++++++++++++ .../ps3da1 => data/kboot-01}/etc/kboot.conf | 0 .../{001 => data/kboot-01}/expected-output | 0 .../ps3da1 => data/kboot-02}/etc/kboot.conf | 0 .../{003 => data/kboot-02}/expected-output | 0 .../sda1 => data/kboot-03}/etc/kboot.conf | 0 .../{004 => data/kboot-03}/expected-output | 0 .../ps3da1 => data/kboot-04}/etc/kboot.conf | 0 .../{005 => data/kboot-04}/expected-output | 0 .../ps3da1 => data/kboot-05}/etc/kboot.conf | 0 .../{101 => data/kboot-05}/expected-output | 0 .../ps3da1 => data/kboot-06}/etc/kboot.conf | 0 .../{102 => data/kboot-06}/expected-output | 0 .../ps3da1 => data/kboot-07}/etc/kboot.conf | 0 .../ps3da1 => data/yaboot-01}/etc/yaboot.conf | 0 .../{002 => data/yaboot-01}/expected-output | 0 .../ps3da1 => data/yaboot-02}/etc/yaboot.conf | 0 .../ps3da1 => data/yaboot-03}/etc/yaboot.conf | 0 .../ps3da1 => data/yaboot-04}/etc/yaboot.conf | 0 .../ps3da1 => data/yaboot-05}/etc/yaboot.conf | 0 .../ps3da1 => data/yaboot-06}/etc/yaboot.conf | 0 test/{ => parser}/parser-test.c | 0 test/parser/run-parser-tests.in | 15 ++++ 27 files changed, 98 insertions(+), 44 deletions(-) delete mode 100755 test/parser-test.sh delete mode 100644 test/parser/004/rootdev create mode 100644 test/parser/Makefile.am rename test/parser/{001/ps3da1 => data/kboot-01}/etc/kboot.conf (100%) rename test/parser/{001 => data/kboot-01}/expected-output (100%) rename test/parser/{003/ps3da1 => data/kboot-02}/etc/kboot.conf (100%) rename test/parser/{003 => data/kboot-02}/expected-output (100%) rename test/parser/{004/sda1 => data/kboot-03}/etc/kboot.conf (100%) rename test/parser/{004 => data/kboot-03}/expected-output (100%) rename test/parser/{005/ps3da1 => data/kboot-04}/etc/kboot.conf (100%) rename test/parser/{005 => data/kboot-04}/expected-output (100%) rename test/parser/{101/ps3da1 => data/kboot-05}/etc/kboot.conf (100%) rename test/parser/{101 => data/kboot-05}/expected-output (100%) rename test/parser/{102/ps3da1 => data/kboot-06}/etc/kboot.conf (100%) rename test/parser/{102 => data/kboot-06}/expected-output (100%) rename test/parser/{103/ps3da1 => data/kboot-07}/etc/kboot.conf (100%) rename test/parser/{002/ps3da1 => data/yaboot-01}/etc/yaboot.conf (100%) rename test/parser/{002 => data/yaboot-01}/expected-output (100%) rename test/parser/{201/ps3da1 => data/yaboot-02}/etc/yaboot.conf (100%) rename test/parser/{202/ps3da1 => data/yaboot-03}/etc/yaboot.conf (100%) rename test/parser/{204/ps3da1 => data/yaboot-04}/etc/yaboot.conf (100%) rename test/parser/{205/ps3da1 => data/yaboot-05}/etc/yaboot.conf (100%) rename test/parser/{203/ps3da1 => data/yaboot-06}/etc/yaboot.conf (100%) rename test/{ => parser}/parser-test.c (100%) create mode 100755 test/parser/run-parser-tests.in diff --git a/configure.ac.in b/configure.ac.in index c62ef56..b1791cd 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -184,6 +184,7 @@ AC_CONFIG_FILES([ lib/Makefile man/Makefile test/Makefile + test/parser/Makefile ui/Makefile ui/common/Makefile ui/ncurses/Makefile diff --git a/test/Makefile.am b/test/Makefile.am index 2f0625d..731b8d7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -10,26 +10,10 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/lib \ - -I$(includedir) \ - $(DEFAULT_CPPFLAGS) - -AM_CFLAGS = \ - $(DEFAULT_CFLAGS) - -common_libs = \ - $(top_builddir)/lib/libpbcore.la \ - $(top_builddir)/discover/libparser.la -noinst_SCRIPTS = parser-test.sh hotplug-device.sh -noinst_PROGRAMS = parser-test +SUBDIRS = parser -parser_test_SOURCES = parser-test.c -parser_test_LDADD = $(common_libs) +noinst_SCRIPTS = hotplug-device.sh MAINTAINERCLEANFILES = Makefile.in diff --git a/test/parser-test.sh b/test/parser-test.sh deleted file mode 100755 index af54395..0000000 --- a/test/parser-test.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -testdir=parser -default_rootdev=ps3da1 -mnt=${PREFIX}/var/petitboot/mnt - -#set -ex - -tests=$(ls ${mnt}/${testdir}/) - -for test in $tests -do - rootdev=$default_rootdev - - if [ -e "${mnt}/${testdir}/$test/rootdev" ]; then - rootdev=$(cat "${mnt}/${testdir}/$test/rootdev") - fi - - ./test/parser-test "${testdir}/$test" $rootdev - -# ./test/parser-test "${testdir}/$test" $rootdev 2>/dev/null | -# diff -u "${mnt}/${testdir}/$test/expected-output" - -done - -echo "All tests passed" diff --git a/test/parser/004/rootdev b/test/parser/004/rootdev deleted file mode 100644 index 36cfa0d..0000000 --- a/test/parser/004/rootdev +++ /dev/null @@ -1 +0,0 @@ -sda1 diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am new file mode 100644 index 0000000..107e8f1 --- /dev/null +++ b/test/parser/Makefile.am @@ -0,0 +1,80 @@ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/lib \ + -I$(includedir) \ + $(DEFAULT_CPPFLAGS) + +AM_CFLAGS = \ + $(DEFAULT_CFLAGS) + +common_libs = \ + $(top_builddir)/lib/libpbcore.la \ + $(top_builddir)/discover/libparser.la + +noinst_PROGRAMS = parser-test + +parser_test_SOURCES = parser-test.c +parser_test_LDADD = $(common_libs) + +noinst_DATA = \ + data/kboot-01/expected-output \ + data/kboot-01/etc/kboot.conf \ + data/kboot-02/expected-output \ + data/kboot-02/etc/kboot.conf \ + data/kboot-03/expected-output \ + data/kboot-03/etc/kboot.conf \ + data/kboot-04/expected-output \ + data/kboot-04/etc/kboot.conf \ + data/kboot-05/expected-output \ + data/kboot-05/etc/kboot.conf \ + data/kboot-06/expected-output \ + data/kboot-06/etc/kboot.conf \ + data/kboot-07/etc/kboot.conf \ + data/yaboot-01/expected-output \ + data/yaboot-01/etc/yaboot.conf \ + data/yaboot-02/etc/yaboot.conf \ + data/yaboot-03/etc/yaboot.conf \ + data/yaboot-04/etc/yaboot.conf \ + data/yaboot-05/etc/yaboot.conf \ + data/yaboot-06/etc/yaboot.conf + +composed_noinst_scripts = \ + run-parser-tests + +noinst_SCRIPTS = $(composed_noinst_scripts) + +edit = sed \ + -e 's|@PACKAGE_NAME\@|$(PACKAGE_NAME)|g' \ + -e 's|@PACKAGE_VERSION\@|$(PACKAGE_VERSION)|g' \ + -e 's|@PACKAGE_BUGREPORT\@|$(PACKAGE_BUGREPORT)|g' \ + -e 's|@abs_srcdir\@|$(abs_srcdir)|g' \ + -e 's|@abs_builddir\@|$(abs_builddir)|g' \ + -e 's|@prefix\@|$(prefix)|g' + +run-parser-tests: Makefile $(srcdir)/run-parser-tests.in + rm -f $@ $@.tmp + $(edit) $(srcdir)/$@.in >$@.tmp + chmod +x $@.tmp + mv $@.tmp $@ + +composed_files = $(composed_noinst_scripts) + +EXTRA_DIST = $(addsuffix .in, $(composed_files)) + +MAINTAINERCLEANFILES = Makefile.in + +CLEANFILES = $(composed_files) $(addsuffix .tmp, $(composed_files)) diff --git a/test/parser/001/ps3da1/etc/kboot.conf b/test/parser/data/kboot-01/etc/kboot.conf similarity index 100% rename from test/parser/001/ps3da1/etc/kboot.conf rename to test/parser/data/kboot-01/etc/kboot.conf diff --git a/test/parser/001/expected-output b/test/parser/data/kboot-01/expected-output similarity index 100% rename from test/parser/001/expected-output rename to test/parser/data/kboot-01/expected-output diff --git a/test/parser/003/ps3da1/etc/kboot.conf b/test/parser/data/kboot-02/etc/kboot.conf similarity index 100% rename from test/parser/003/ps3da1/etc/kboot.conf rename to test/parser/data/kboot-02/etc/kboot.conf diff --git a/test/parser/003/expected-output b/test/parser/data/kboot-02/expected-output similarity index 100% rename from test/parser/003/expected-output rename to test/parser/data/kboot-02/expected-output diff --git a/test/parser/004/sda1/etc/kboot.conf b/test/parser/data/kboot-03/etc/kboot.conf similarity index 100% rename from test/parser/004/sda1/etc/kboot.conf rename to test/parser/data/kboot-03/etc/kboot.conf diff --git a/test/parser/004/expected-output b/test/parser/data/kboot-03/expected-output similarity index 100% rename from test/parser/004/expected-output rename to test/parser/data/kboot-03/expected-output diff --git a/test/parser/005/ps3da1/etc/kboot.conf b/test/parser/data/kboot-04/etc/kboot.conf similarity index 100% rename from test/parser/005/ps3da1/etc/kboot.conf rename to test/parser/data/kboot-04/etc/kboot.conf diff --git a/test/parser/005/expected-output b/test/parser/data/kboot-04/expected-output similarity index 100% rename from test/parser/005/expected-output rename to test/parser/data/kboot-04/expected-output diff --git a/test/parser/101/ps3da1/etc/kboot.conf b/test/parser/data/kboot-05/etc/kboot.conf similarity index 100% rename from test/parser/101/ps3da1/etc/kboot.conf rename to test/parser/data/kboot-05/etc/kboot.conf diff --git a/test/parser/101/expected-output b/test/parser/data/kboot-05/expected-output similarity index 100% rename from test/parser/101/expected-output rename to test/parser/data/kboot-05/expected-output diff --git a/test/parser/102/ps3da1/etc/kboot.conf b/test/parser/data/kboot-06/etc/kboot.conf similarity index 100% rename from test/parser/102/ps3da1/etc/kboot.conf rename to test/parser/data/kboot-06/etc/kboot.conf diff --git a/test/parser/102/expected-output b/test/parser/data/kboot-06/expected-output similarity index 100% rename from test/parser/102/expected-output rename to test/parser/data/kboot-06/expected-output diff --git a/test/parser/103/ps3da1/etc/kboot.conf b/test/parser/data/kboot-07/etc/kboot.conf similarity index 100% rename from test/parser/103/ps3da1/etc/kboot.conf rename to test/parser/data/kboot-07/etc/kboot.conf diff --git a/test/parser/002/ps3da1/etc/yaboot.conf b/test/parser/data/yaboot-01/etc/yaboot.conf similarity index 100% rename from test/parser/002/ps3da1/etc/yaboot.conf rename to test/parser/data/yaboot-01/etc/yaboot.conf diff --git a/test/parser/002/expected-output b/test/parser/data/yaboot-01/expected-output similarity index 100% rename from test/parser/002/expected-output rename to test/parser/data/yaboot-01/expected-output diff --git a/test/parser/201/ps3da1/etc/yaboot.conf b/test/parser/data/yaboot-02/etc/yaboot.conf similarity index 100% rename from test/parser/201/ps3da1/etc/yaboot.conf rename to test/parser/data/yaboot-02/etc/yaboot.conf diff --git a/test/parser/202/ps3da1/etc/yaboot.conf b/test/parser/data/yaboot-03/etc/yaboot.conf similarity index 100% rename from test/parser/202/ps3da1/etc/yaboot.conf rename to test/parser/data/yaboot-03/etc/yaboot.conf diff --git a/test/parser/204/ps3da1/etc/yaboot.conf b/test/parser/data/yaboot-04/etc/yaboot.conf similarity index 100% rename from test/parser/204/ps3da1/etc/yaboot.conf rename to test/parser/data/yaboot-04/etc/yaboot.conf diff --git a/test/parser/205/ps3da1/etc/yaboot.conf b/test/parser/data/yaboot-05/etc/yaboot.conf similarity index 100% rename from test/parser/205/ps3da1/etc/yaboot.conf rename to test/parser/data/yaboot-05/etc/yaboot.conf diff --git a/test/parser/203/ps3da1/etc/yaboot.conf b/test/parser/data/yaboot-06/etc/yaboot.conf similarity index 100% rename from test/parser/203/ps3da1/etc/yaboot.conf rename to test/parser/data/yaboot-06/etc/yaboot.conf diff --git a/test/parser-test.c b/test/parser/parser-test.c similarity index 100% rename from test/parser-test.c rename to test/parser/parser-test.c diff --git a/test/parser/run-parser-tests.in b/test/parser/run-parser-tests.in new file mode 100755 index 0000000..4c4c2be --- /dev/null +++ b/test/parser/run-parser-tests.in @@ -0,0 +1,15 @@ +#!/bin/bash + +test="@abs_builddir@/parser-test" +data_dir="@abs_srcdir@/data" +mnt_dir="@prefix@/var/petitboot/mnt" + +dirs=$(ls ${data_dir}) + +mkdir -p ${mnt_dir} +ln -s ${data_dir} ${mnt_dir}/ + +for d in ${dirs}; do + echo "##### running parser test in ${d} #####" + ${test} data ${d} +done -- 2.39.2