diff options
author | Geoff Levand <geoff@infradead.org> | 2012-03-18 22:19:49 -0700 |
---|---|---|
committer | Geoff Levand <geoff@infradead.org> | 2012-03-18 22:19:49 -0700 |
commit | 8bd85461621fb0ff18059305a6c1aecdbc18016c (patch) | |
tree | ef74fc1a811fc1c14797b0a2ab0735d37475e0dd /test/parser | |
parent | d40cc2cc3f7c78a766c7ab26aa0cb73ae17534c0 (diff) | |
download | talos-petitboot-8bd85461621fb0ff18059305a6c1aecdbc18016c.tar.gz talos-petitboot-8bd85461621fb0ff18059305a6c1aecdbc18016c.zip |
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 <geoff@infradead.org>
Diffstat (limited to 'test/parser')
-rw-r--r-- | test/parser/004/rootdev | 1 | ||||
-rw-r--r-- | test/parser/Makefile.am | 80 | ||||
-rw-r--r-- | test/parser/data/kboot-01/etc/kboot.conf (renamed from test/parser/001/ps3da1/etc/kboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-01/expected-output (renamed from test/parser/001/expected-output) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-02/etc/kboot.conf (renamed from test/parser/003/ps3da1/etc/kboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-02/expected-output (renamed from test/parser/003/expected-output) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-03/etc/kboot.conf (renamed from test/parser/004/sda1/etc/kboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-03/expected-output (renamed from test/parser/004/expected-output) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-04/etc/kboot.conf (renamed from test/parser/005/ps3da1/etc/kboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-04/expected-output (renamed from test/parser/005/expected-output) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-05/etc/kboot.conf (renamed from test/parser/101/ps3da1/etc/kboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-05/expected-output (renamed from test/parser/101/expected-output) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-06/etc/kboot.conf (renamed from test/parser/102/ps3da1/etc/kboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-06/expected-output (renamed from test/parser/102/expected-output) | 0 | ||||
-rw-r--r-- | test/parser/data/kboot-07/etc/kboot.conf (renamed from test/parser/103/ps3da1/etc/kboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/yaboot-01/etc/yaboot.conf (renamed from test/parser/002/ps3da1/etc/yaboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/yaboot-01/expected-output (renamed from test/parser/002/expected-output) | 0 | ||||
-rw-r--r-- | test/parser/data/yaboot-02/etc/yaboot.conf (renamed from test/parser/201/ps3da1/etc/yaboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/yaboot-03/etc/yaboot.conf (renamed from test/parser/202/ps3da1/etc/yaboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/yaboot-04/etc/yaboot.conf (renamed from test/parser/204/ps3da1/etc/yaboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/yaboot-05/etc/yaboot.conf (renamed from test/parser/205/ps3da1/etc/yaboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/data/yaboot-06/etc/yaboot.conf (renamed from test/parser/203/ps3da1/etc/yaboot.conf) | 0 | ||||
-rw-r--r-- | test/parser/parser-test.c | 74 | ||||
-rwxr-xr-x | test/parser/run-parser-tests.in | 15 |
24 files changed, 169 insertions, 1 deletions
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 index 591c51b..591c51b 100644 --- a/test/parser/001/ps3da1/etc/kboot.conf +++ b/test/parser/data/kboot-01/etc/kboot.conf diff --git a/test/parser/001/expected-output b/test/parser/data/kboot-01/expected-output index bace9f7..bace9f7 100644 --- a/test/parser/001/expected-output +++ b/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 index a7bb199..a7bb199 100644 --- a/test/parser/003/ps3da1/etc/kboot.conf +++ b/test/parser/data/kboot-02/etc/kboot.conf diff --git a/test/parser/003/expected-output b/test/parser/data/kboot-02/expected-output index 4f60310..4f60310 100644 --- a/test/parser/003/expected-output +++ b/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 index 9755f77..9755f77 100644 --- a/test/parser/004/sda1/etc/kboot.conf +++ b/test/parser/data/kboot-03/etc/kboot.conf diff --git a/test/parser/004/expected-output b/test/parser/data/kboot-03/expected-output index 76a90a2..76a90a2 100644 --- a/test/parser/004/expected-output +++ b/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 index 72b7db8..72b7db8 100644 --- a/test/parser/005/ps3da1/etc/kboot.conf +++ b/test/parser/data/kboot-04/etc/kboot.conf diff --git a/test/parser/005/expected-output b/test/parser/data/kboot-04/expected-output index bfaccc8..bfaccc8 100644 --- a/test/parser/005/expected-output +++ b/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 index 4a986c0..4a986c0 100644 --- a/test/parser/101/ps3da1/etc/kboot.conf +++ b/test/parser/data/kboot-05/etc/kboot.conf diff --git a/test/parser/101/expected-output b/test/parser/data/kboot-05/expected-output index 45d99a1..45d99a1 100644 --- a/test/parser/101/expected-output +++ b/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 index 591c51b..591c51b 100644 --- a/test/parser/102/ps3da1/etc/kboot.conf +++ b/test/parser/data/kboot-06/etc/kboot.conf diff --git a/test/parser/102/expected-output b/test/parser/data/kboot-06/expected-output index cc0d096..cc0d096 100644 --- a/test/parser/102/expected-output +++ b/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 index 3f8f15c..3f8f15c 100644 --- a/test/parser/103/ps3da1/etc/kboot.conf +++ b/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 index f13b1b3..f13b1b3 100644 --- a/test/parser/002/ps3da1/etc/yaboot.conf +++ b/test/parser/data/yaboot-01/etc/yaboot.conf diff --git a/test/parser/002/expected-output b/test/parser/data/yaboot-01/expected-output index 304f15c..304f15c 100644 --- a/test/parser/002/expected-output +++ b/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 index 8f44792..8f44792 100644 --- a/test/parser/201/ps3da1/etc/yaboot.conf +++ b/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 index 56d7062..56d7062 100644 --- a/test/parser/202/ps3da1/etc/yaboot.conf +++ b/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 index 7537646..7537646 100644 --- a/test/parser/204/ps3da1/etc/yaboot.conf +++ b/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 index fd46206..fd46206 100644 --- a/test/parser/205/ps3da1/etc/yaboot.conf +++ b/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 index 57a2f0d..57a2f0d 100644 --- a/test/parser/203/ps3da1/etc/yaboot.conf +++ b/test/parser/data/yaboot-06/etc/yaboot.conf diff --git a/test/parser/parser-test.c b/test/parser/parser-test.c new file mode 100644 index 0000000..90b3e3b --- /dev/null +++ b/test/parser/parser-test.c @@ -0,0 +1,74 @@ +#define _GNU_SOURCE + +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include <log/log.h> +#include "pb-protocol/pb-protocol.h" +#include <talloc/talloc.h> + +#include "discover/device-handler.h" +#include "discover/parser.h" +#include "discover/parser-utils.h" +#include "discover/paths.h" + +static FILE *testf; + +void device_add_boot_option(struct device *device, + struct boot_option *boot_option) +{ + fprintf(testf, "%s: %s\n", __func__, device->id); + fprintf(testf, " id '%s'\n", boot_option->id); + fprintf(testf, " name '%s'\n", boot_option->name); + fprintf(testf, " descr '%s'\n", boot_option->description); + fprintf(testf, " icon '%s'\n", boot_option->icon_file); + fprintf(testf, " image '%s'\n", boot_option->boot_image_file); + fprintf(testf, " initrd '%s'\n", boot_option->initrd_file); + fprintf(testf, " args '%s'\n", boot_option->boot_args); + fflush(testf); +} + +const char *generic_icon_file( + enum generic_icon_type __attribute__((unused)) type) +{ + return "tester.png"; +} + +enum generic_icon_type guess_device_type( + struct discover_context __attribute__((unused)) *ctx) +{ + return ICON_TYPE_UNKNOWN; +} + +int main(int argc, char **argv) +{ + struct discover_context *ctx; + + if (argc != 3) { + fprintf(stderr, "usage: %s <basedir> <devname>\n", argv[0]); + return EXIT_FAILURE; + } + + /* Default to test on stdout, pb_log on stderr. */ + + testf = stdout; + + pb_log_set_stream(stderr); + pb_log_always_flush(1); + pb_log("--- parser-test ---\n"); + + ctx = talloc_zero(NULL, struct discover_context); + + ctx->device_path = talloc_asprintf(ctx, "%s/%s", argv[1], argv[2]); + ctx->device = talloc_zero(ctx, struct device); + ctx->device->id = talloc_strdup(ctx->device, argv[2]); + + iterate_parsers(ctx); + + pb_log("--- end ---\n"); + + return EXIT_SUCCESS; +} 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 |