From: Geoff Levand Date: Mon, 19 Mar 2012 05:19:49 +0000 (-0700) Subject: Parser test cleanup X-Git-Tag: v1.0.0~771 X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=commitdiff_plain;h=8bd85461621fb0ff18059305a6c1aecdbc18016c;hp=d40cc2cc3f7c78a766c7ab26aa0cb73ae17534c0 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 --- 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.c b/test/parser-test.c deleted file mode 100644 index 90b3e3b..0000000 --- a/test/parser-test.c +++ /dev/null @@ -1,74 +0,0 @@ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include - -#include -#include "pb-protocol/pb-protocol.h" -#include - -#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 \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-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/001/expected-output b/test/parser/001/expected-output deleted file mode 100644 index bace9f7..0000000 --- a/test/parser/001/expected-output +++ /dev/null @@ -1,24 +0,0 @@ -[dev 0] id: /dev/ps3da1 -[dev 0] name: (null) -[dev 0] description: (null) -[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png -[opt 0] name: live -[opt 0] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash -- -[opt 0] boot_image: devices/parser-tests/001/ps3da1/casper/vmlinux -[opt 0] initrd: devices/parser-tests/001/ps3da1/casper/initrd.gz -[opt 0] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash -- -[opt 1] name: live_nosplash -[opt 1] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet -- -[opt 1] boot_image: devices/parser-tests/001/ps3da1/casper/vmlinux -[opt 1] initrd: devices/parser-tests/001/ps3da1/casper/initrd.gz -[opt 1] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet -- -[opt 2] name: driverupdates -[opt 2] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash -- -[opt 2] boot_image: devices/parser-tests/001/ps3da1/casper/vmlinux -[opt 2] initrd: devices/parser-tests/001/ps3da1/casper/initrd.gz -[opt 2] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash -- -[opt 3] name: check -[opt 3] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz boot=casper integrity-check quiet splash -- -[opt 3] boot_image: devices/parser-tests/001/ps3da1/casper/vmlinux -[opt 3] initrd: devices/parser-tests/001/ps3da1/casper/initrd.gz -[opt 3] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz boot=casper integrity-check quiet splash -- diff --git a/test/parser/001/ps3da1/etc/kboot.conf b/test/parser/001/ps3da1/etc/kboot.conf deleted file mode 100644 index 591c51b..0000000 --- a/test/parser/001/ps3da1/etc/kboot.conf +++ /dev/null @@ -1,9 +0,0 @@ -# Ubuntu feisty kboot.conf -message=/etc/kboot.msg -timeout=300 -default=live -live='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --' -live_nosplash='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet --' -driverupdates='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash --' -check='/casper/vmlinux initrd=/casper/initrd.gz boot=casper integrity-check quiet splash --' - diff --git a/test/parser/002/expected-output b/test/parser/002/expected-output deleted file mode 100644 index 304f15c..0000000 --- a/test/parser/002/expected-output +++ /dev/null @@ -1,9 +0,0 @@ -[dev 0] id: /dev/ps3da1 -[dev 0] name: (null) -[dev 0] description: -[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png -[opt 0] name: linux -[opt 0] description: (null) -[opt 0] boot_image: devices/parser-tests/002/ps3da1/ppc/ppc64/vmlinux -[opt 0] initrd: devices/parser-tests/002/ps3da1/ppc/ppc64/ramdisk.image.gz -[opt 0] boot_args: ro diff --git a/test/parser/002/ps3da1/etc/yaboot.conf b/test/parser/002/ps3da1/etc/yaboot.conf deleted file mode 100644 index f13b1b3..0000000 --- a/test/parser/002/ps3da1/etc/yaboot.conf +++ /dev/null @@ -1,8 +0,0 @@ -init-message = "\nWelcome to the 64-bit Yellow Dog Linux 5.0 installer!\nHit for boot options.\n\n" -timeout=6000 -default=linux - -image=/ppc/ppc64/vmlinux - label=linux - initrd=/ppc/ppc64/ramdisk.image.gz - read-only diff --git a/test/parser/003/expected-output b/test/parser/003/expected-output deleted file mode 100644 index 4f60310..0000000 --- a/test/parser/003/expected-output +++ /dev/null @@ -1,9 +0,0 @@ -[dev 0] id: /dev/ps3da1 -[dev 0] name: (null) -[dev 0] description: (null) -[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png -[opt 0] name: test -[opt 0] description: /dev/sda1:/vmlinux -[opt 0] boot_image: devices/parser-tests/003/ps3da1/vmlinux -[opt 0] initrd: (null) -[opt 0] boot_args: (null) diff --git a/test/parser/003/ps3da1/etc/kboot.conf b/test/parser/003/ps3da1/etc/kboot.conf deleted file mode 100644 index a7bb199..0000000 --- a/test/parser/003/ps3da1/etc/kboot.conf +++ /dev/null @@ -1,4 +0,0 @@ -# test remapping sda to ps3da, when mounted from a ps3da device - -test='/dev/sda1:/vmlinux' - diff --git a/test/parser/004/expected-output b/test/parser/004/expected-output deleted file mode 100644 index 76a90a2..0000000 --- a/test/parser/004/expected-output +++ /dev/null @@ -1,9 +0,0 @@ -[dev 0] id: /dev/sda1 -[dev 0] name: (null) -[dev 0] description: (null) -[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png -[opt 0] name: test -[opt 0] description: /dev/sda1:/vmlinux -[opt 0] boot_image: devices/parser-tests/004/sda1/vmlinux -[opt 0] initrd: (null) -[opt 0] boot_args: (null) 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/004/sda1/etc/kboot.conf b/test/parser/004/sda1/etc/kboot.conf deleted file mode 100644 index 9755f77..0000000 --- a/test/parser/004/sda1/etc/kboot.conf +++ /dev/null @@ -1,4 +0,0 @@ -# test remapping sda to ps3da, when mounted from a plain sd device - -test='/dev/sda1:/vmlinux' - diff --git a/test/parser/005/expected-output b/test/parser/005/expected-output deleted file mode 100644 index bfaccc8..0000000 --- a/test/parser/005/expected-output +++ /dev/null @@ -1,14 +0,0 @@ -[dev 0] id: /dev/ps3da1 -[dev 0] name: (null) -[dev 0] description: (null) -[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png -[opt 0] name: test_uuid -[opt 0] description: UUID=meep:/vmlinux -[opt 0] boot_image: devices/parser-tests/005/disk/by-uuid/meep/vmlinux -[opt 0] initrd: (null) -[opt 0] boot_args: (null) -[opt 1] name: test_label -[opt 1] description: LABEL=meep:/vmlinux -[opt 1] boot_image: devices/parser-tests/005/disk/by-label/meep/vmlinux -[opt 1] initrd: (null) -[opt 1] boot_args: (null) diff --git a/test/parser/005/ps3da1/etc/kboot.conf b/test/parser/005/ps3da1/etc/kboot.conf deleted file mode 100644 index 72b7db8..0000000 --- a/test/parser/005/ps3da1/etc/kboot.conf +++ /dev/null @@ -1,6 +0,0 @@ - -# test for LABEL= and UUID= lookups - -test_uuid='UUID=meep:/vmlinux' -test_label='LABEL=meep:/vmlinux' - diff --git a/test/parser/101/expected-output b/test/parser/101/expected-output deleted file mode 100644 index 45d99a1..0000000 --- a/test/parser/101/expected-output +++ /dev/null @@ -1,24 +0,0 @@ -[dev 0] id: /dev/ps3da1 -[dev 0] name: (null) -[dev 0] description: (null) -[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png -[opt 0] name: ydl -[opt 0] description: /dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:3 rhgb -[opt 0] boot_image: devices/parser-tests/101/ps3da1/vmlinux-2.6.22-0.ydl.rc4 -[opt 0] initrd: devices/parser-tests/101/ps3da1/initrd-2.6.22-0.ydl.rc4.img -[opt 0] boot_args: root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:3 rhgb -[opt 1] name: ydl480i -[opt 1] description: /dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:1 rhgb -[opt 1] boot_image: devices/parser-tests/101/ps3da1/vmlinux-2.6.22-0.ydl.rc4 -[opt 1] initrd: devices/parser-tests/101/ps3da1/initrd-2.6.22-0.ydl.rc4.img -[opt 1] boot_args: root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:1 rhgb -[opt 2] name: ydl1080i -[opt 2] description: /dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:4 rhgb -[opt 2] boot_image: devices/parser-tests/101/ps3da1/vmlinux-2.6.22-0.ydl.rc4 -[opt 2] initrd: devices/parser-tests/101/ps3da1/initrd-2.6.22-0.ydl.rc4.img -[opt 2] boot_args: root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:4 rhgb -[opt 3] name: ydltext -[opt 3] description: /dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init 3 -[opt 3] boot_image: devices/parser-tests/101/ps3da1/vmlinux-2.6.22-0.ydl.rc4 -[opt 3] initrd: devices/parser-tests/101/ps3da1/initrd-2.6.22-0.ydl.rc4.img -[opt 3] boot_args: root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init 3 diff --git a/test/parser/101/ps3da1/etc/kboot.conf b/test/parser/101/ps3da1/etc/kboot.conf deleted file mode 100644 index 4a986c0..0000000 --- a/test/parser/101/ps3da1/etc/kboot.conf +++ /dev/null @@ -1,12 +0,0 @@ -# kboot.conf for ydl - -default=ydl -timeout=10 -root=/dev/sda1 -ydl='/dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img root=LABEL=/ init=/sbin/init video=ps3fb:mode:3 rhgb' -ydl480i='/dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img root=LABEL=/ init=/sbin/init video=ps3fb:mode:1 rhgb' -ydl1080i='/dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img root=LABEL=/ init=/sbin/init video=ps3fb:mode:4 rhgb' -ydltext='/dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img root=LABEL=/ init=/sbin/init 3' - - - diff --git a/test/parser/102/expected-output b/test/parser/102/expected-output deleted file mode 100644 index cc0d096..0000000 --- a/test/parser/102/expected-output +++ /dev/null @@ -1,24 +0,0 @@ -[dev 0] id: /dev/ps3da1 -[dev 0] name: (null) -[dev 0] description: (null) -[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png -[opt 0] name: live -[opt 0] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash -- -[opt 0] boot_image: devices/parser-tests/102/ps3da1/casper/vmlinux -[opt 0] initrd: devices/parser-tests/102/ps3da1/casper/initrd.gz -[opt 0] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash -- -[opt 1] name: live_nosplash -[opt 1] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet -- -[opt 1] boot_image: devices/parser-tests/102/ps3da1/casper/vmlinux -[opt 1] initrd: devices/parser-tests/102/ps3da1/casper/initrd.gz -[opt 1] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet -- -[opt 2] name: driverupdates -[opt 2] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash -- -[opt 2] boot_image: devices/parser-tests/102/ps3da1/casper/vmlinux -[opt 2] initrd: devices/parser-tests/102/ps3da1/casper/initrd.gz -[opt 2] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash -- -[opt 3] name: check -[opt 3] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz boot=casper integrity-check quiet splash -- -[opt 3] boot_image: devices/parser-tests/102/ps3da1/casper/vmlinux -[opt 3] initrd: devices/parser-tests/102/ps3da1/casper/initrd.gz -[opt 3] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz boot=casper integrity-check quiet splash -- diff --git a/test/parser/102/ps3da1/etc/kboot.conf b/test/parser/102/ps3da1/etc/kboot.conf deleted file mode 100644 index 591c51b..0000000 --- a/test/parser/102/ps3da1/etc/kboot.conf +++ /dev/null @@ -1,9 +0,0 @@ -# Ubuntu feisty kboot.conf -message=/etc/kboot.msg -timeout=300 -default=live -live='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --' -live_nosplash='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet --' -driverupdates='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash --' -check='/casper/vmlinux initrd=/casper/initrd.gz boot=casper integrity-check quiet splash --' - diff --git a/test/parser/103/ps3da1/etc/kboot.conf b/test/parser/103/ps3da1/etc/kboot.conf deleted file mode 100644 index 3f8f15c..0000000 --- a/test/parser/103/ps3da1/etc/kboot.conf +++ /dev/null @@ -1,7 +0,0 @@ -default=tftp_nfs_1080p -timeout=120 - -tftp='tftp://192.168.0.5/fire/boot/vmlinux.strip root=/dev/nfs rw ip=dhcp video=1080p' -nfs='nfs://192.168.0.5/fire/boot/vmlinux.strip root=/dev/nfs rw ip=dhcp video=1080p fbcon=rotate:3' -http_nfs='http://192.168.0.5/ice/boot/vmlinux.strip nfs://192.168.0.5/ice/boot/initrd root=/dev/nfs' - diff --git a/test/parser/201/ps3da1/etc/yaboot.conf b/test/parser/201/ps3da1/etc/yaboot.conf deleted file mode 100644 index 8f44792..0000000 --- a/test/parser/201/ps3da1/etc/yaboot.conf +++ /dev/null @@ -1,27 +0,0 @@ -# yaboot.conf generated by anaconda - -boot=/dev/ps3da -init-message="Welcome to Fedora!\nHit for boot options" - -partition=1 -timeout=80 -install=/usr/lib/yaboot/yaboot -enablecdboot -enableofboot -enablenetboot -nonvram -mntpoint=/boot/yaboot -usemount - -image=/boot/vmlinuz-2.6.25-1.fc9.ppc64 - label=2.6.25-1.fc9.pp - read-only - initrd=/boot/initrd-2.6.25-1.fc9.ppc64.img - append="root=UUID=0f1335f2-eaba-4495-8eee-29229bb8ba03" - -image=/boot/vmlinuz-2.6.25-0.234.rc9.git1.fc9.ppc64 - label=linux - read-only - initrd=/boot/initrd-2.6.25-0.234.rc9.git1.fc9.ppc64.img - append="root=UUID=0f1335f2-eaba-4495-8eee-29229bb8ba03" - diff --git a/test/parser/202/ps3da1/etc/yaboot.conf b/test/parser/202/ps3da1/etc/yaboot.conf deleted file mode 100644 index 56d7062..0000000 --- a/test/parser/202/ps3da1/etc/yaboot.conf +++ /dev/null @@ -1,22 +0,0 @@ -# yaboot.conf generated by anaconda - -boot=/dev/ps3da -init-message="Welcome to Fedora!\nHit for boot options" - -partition=1 -timeout=80 -install=/usr/lib/yaboot/yaboot -delay=5 -enablecdboot -enableofboot -enablenetboot -nonvram -mntpoint=/boot/yaboot -usemount - -image=/boot/vmlinuz-2.6.27.5-117.fc10.ppc64 - label=linux - read-only - initrd=/boot/initrd-2.6.27.5-117.fc10.ppc64.img - append="rhgb quiet root=UUID=ebb54ca2-aa3e-4f67-b1d4-184cdc5d0638" - diff --git a/test/parser/203/ps3da1/etc/yaboot.conf b/test/parser/203/ps3da1/etc/yaboot.conf deleted file mode 100644 index 57a2f0d..0000000 --- a/test/parser/203/ps3da1/etc/yaboot.conf +++ /dev/null @@ -1,25 +0,0 @@ -# from openSUSE - -message=yaboot.txt - -image[32bit]=inst32 - label=install - append="quiet sysrq=1 insmod=sym53c8xx insmod=ipr " -image[32bit]=inst32 - label=slp - append="quiet sysrq=1 install=slp " -image[32bit]=inst32 - label=rescue - append="quiet sysrq=1 rescue=1 " - - -image[64bit]=inst64 - label=install - append="quiet sysrq=1 insmod=sym53c8xx insmod=ipr " -image[64bit]=inst64 - label=slp - append="quiet sysrq=1 install=slp " -image[64bit]=inst64 - label=rescue - append="quiet sysrq=1 rescue=1 " - diff --git a/test/parser/204/ps3da1/etc/yaboot.conf b/test/parser/204/ps3da1/etc/yaboot.conf deleted file mode 100644 index 7537646..0000000 --- a/test/parser/204/ps3da1/etc/yaboot.conf +++ /dev/null @@ -1,10 +0,0 @@ - -image=111 - read-only - label=linux1 - label = linux2 - append="abc1" - append='abc2' - # read-only - # label=linux3 - # label = linux4 diff --git a/test/parser/205/ps3da1/etc/yaboot.conf b/test/parser/205/ps3da1/etc/yaboot.conf deleted file mode 100644 index fd46206..0000000 --- a/test/parser/205/ps3da1/etc/yaboot.conf +++ /dev/null @@ -1,6 +0,0 @@ -# yaboot.conf generated by anaconda -# from a failed fedora install - -boot=/dev/sda2 -init-message="Welcome to Fedora!\nHit for boot options" - 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/data/kboot-01/etc/kboot.conf b/test/parser/data/kboot-01/etc/kboot.conf new file mode 100644 index 0000000..591c51b --- /dev/null +++ b/test/parser/data/kboot-01/etc/kboot.conf @@ -0,0 +1,9 @@ +# Ubuntu feisty kboot.conf +message=/etc/kboot.msg +timeout=300 +default=live +live='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --' +live_nosplash='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet --' +driverupdates='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash --' +check='/casper/vmlinux initrd=/casper/initrd.gz boot=casper integrity-check quiet splash --' + diff --git a/test/parser/data/kboot-01/expected-output b/test/parser/data/kboot-01/expected-output new file mode 100644 index 0000000..bace9f7 --- /dev/null +++ b/test/parser/data/kboot-01/expected-output @@ -0,0 +1,24 @@ +[dev 0] id: /dev/ps3da1 +[dev 0] name: (null) +[dev 0] description: (null) +[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png +[opt 0] name: live +[opt 0] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash -- +[opt 0] boot_image: devices/parser-tests/001/ps3da1/casper/vmlinux +[opt 0] initrd: devices/parser-tests/001/ps3da1/casper/initrd.gz +[opt 0] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash -- +[opt 1] name: live_nosplash +[opt 1] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet -- +[opt 1] boot_image: devices/parser-tests/001/ps3da1/casper/vmlinux +[opt 1] initrd: devices/parser-tests/001/ps3da1/casper/initrd.gz +[opt 1] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet -- +[opt 2] name: driverupdates +[opt 2] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash -- +[opt 2] boot_image: devices/parser-tests/001/ps3da1/casper/vmlinux +[opt 2] initrd: devices/parser-tests/001/ps3da1/casper/initrd.gz +[opt 2] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash -- +[opt 3] name: check +[opt 3] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz boot=casper integrity-check quiet splash -- +[opt 3] boot_image: devices/parser-tests/001/ps3da1/casper/vmlinux +[opt 3] initrd: devices/parser-tests/001/ps3da1/casper/initrd.gz +[opt 3] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz boot=casper integrity-check quiet splash -- diff --git a/test/parser/data/kboot-02/etc/kboot.conf b/test/parser/data/kboot-02/etc/kboot.conf new file mode 100644 index 0000000..a7bb199 --- /dev/null +++ b/test/parser/data/kboot-02/etc/kboot.conf @@ -0,0 +1,4 @@ +# test remapping sda to ps3da, when mounted from a ps3da device + +test='/dev/sda1:/vmlinux' + diff --git a/test/parser/data/kboot-02/expected-output b/test/parser/data/kboot-02/expected-output new file mode 100644 index 0000000..4f60310 --- /dev/null +++ b/test/parser/data/kboot-02/expected-output @@ -0,0 +1,9 @@ +[dev 0] id: /dev/ps3da1 +[dev 0] name: (null) +[dev 0] description: (null) +[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png +[opt 0] name: test +[opt 0] description: /dev/sda1:/vmlinux +[opt 0] boot_image: devices/parser-tests/003/ps3da1/vmlinux +[opt 0] initrd: (null) +[opt 0] boot_args: (null) diff --git a/test/parser/data/kboot-03/etc/kboot.conf b/test/parser/data/kboot-03/etc/kboot.conf new file mode 100644 index 0000000..9755f77 --- /dev/null +++ b/test/parser/data/kboot-03/etc/kboot.conf @@ -0,0 +1,4 @@ +# test remapping sda to ps3da, when mounted from a plain sd device + +test='/dev/sda1:/vmlinux' + diff --git a/test/parser/data/kboot-03/expected-output b/test/parser/data/kboot-03/expected-output new file mode 100644 index 0000000..76a90a2 --- /dev/null +++ b/test/parser/data/kboot-03/expected-output @@ -0,0 +1,9 @@ +[dev 0] id: /dev/sda1 +[dev 0] name: (null) +[dev 0] description: (null) +[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png +[opt 0] name: test +[opt 0] description: /dev/sda1:/vmlinux +[opt 0] boot_image: devices/parser-tests/004/sda1/vmlinux +[opt 0] initrd: (null) +[opt 0] boot_args: (null) diff --git a/test/parser/data/kboot-04/etc/kboot.conf b/test/parser/data/kboot-04/etc/kboot.conf new file mode 100644 index 0000000..72b7db8 --- /dev/null +++ b/test/parser/data/kboot-04/etc/kboot.conf @@ -0,0 +1,6 @@ + +# test for LABEL= and UUID= lookups + +test_uuid='UUID=meep:/vmlinux' +test_label='LABEL=meep:/vmlinux' + diff --git a/test/parser/data/kboot-04/expected-output b/test/parser/data/kboot-04/expected-output new file mode 100644 index 0000000..bfaccc8 --- /dev/null +++ b/test/parser/data/kboot-04/expected-output @@ -0,0 +1,14 @@ +[dev 0] id: /dev/ps3da1 +[dev 0] name: (null) +[dev 0] description: (null) +[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png +[opt 0] name: test_uuid +[opt 0] description: UUID=meep:/vmlinux +[opt 0] boot_image: devices/parser-tests/005/disk/by-uuid/meep/vmlinux +[opt 0] initrd: (null) +[opt 0] boot_args: (null) +[opt 1] name: test_label +[opt 1] description: LABEL=meep:/vmlinux +[opt 1] boot_image: devices/parser-tests/005/disk/by-label/meep/vmlinux +[opt 1] initrd: (null) +[opt 1] boot_args: (null) diff --git a/test/parser/data/kboot-05/etc/kboot.conf b/test/parser/data/kboot-05/etc/kboot.conf new file mode 100644 index 0000000..4a986c0 --- /dev/null +++ b/test/parser/data/kboot-05/etc/kboot.conf @@ -0,0 +1,12 @@ +# kboot.conf for ydl + +default=ydl +timeout=10 +root=/dev/sda1 +ydl='/dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img root=LABEL=/ init=/sbin/init video=ps3fb:mode:3 rhgb' +ydl480i='/dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img root=LABEL=/ init=/sbin/init video=ps3fb:mode:1 rhgb' +ydl1080i='/dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img root=LABEL=/ init=/sbin/init video=ps3fb:mode:4 rhgb' +ydltext='/dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img root=LABEL=/ init=/sbin/init 3' + + + diff --git a/test/parser/data/kboot-05/expected-output b/test/parser/data/kboot-05/expected-output new file mode 100644 index 0000000..45d99a1 --- /dev/null +++ b/test/parser/data/kboot-05/expected-output @@ -0,0 +1,24 @@ +[dev 0] id: /dev/ps3da1 +[dev 0] name: (null) +[dev 0] description: (null) +[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png +[opt 0] name: ydl +[opt 0] description: /dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:3 rhgb +[opt 0] boot_image: devices/parser-tests/101/ps3da1/vmlinux-2.6.22-0.ydl.rc4 +[opt 0] initrd: devices/parser-tests/101/ps3da1/initrd-2.6.22-0.ydl.rc4.img +[opt 0] boot_args: root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:3 rhgb +[opt 1] name: ydl480i +[opt 1] description: /dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:1 rhgb +[opt 1] boot_image: devices/parser-tests/101/ps3da1/vmlinux-2.6.22-0.ydl.rc4 +[opt 1] initrd: devices/parser-tests/101/ps3da1/initrd-2.6.22-0.ydl.rc4.img +[opt 1] boot_args: root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:1 rhgb +[opt 2] name: ydl1080i +[opt 2] description: /dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:4 rhgb +[opt 2] boot_image: devices/parser-tests/101/ps3da1/vmlinux-2.6.22-0.ydl.rc4 +[opt 2] initrd: devices/parser-tests/101/ps3da1/initrd-2.6.22-0.ydl.rc4.img +[opt 2] boot_args: root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init video=ps3fb:mode:4 rhgb +[opt 3] name: ydltext +[opt 3] description: /dev/sda1:/vmlinux-2.6.22-0.ydl.rc4 root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init 3 +[opt 3] boot_image: devices/parser-tests/101/ps3da1/vmlinux-2.6.22-0.ydl.rc4 +[opt 3] initrd: devices/parser-tests/101/ps3da1/initrd-2.6.22-0.ydl.rc4.img +[opt 3] boot_args: root=LABEL=/ initrd=/dev/sda1:/initrd-2.6.22-0.ydl.rc4.img init=/sbin/init 3 diff --git a/test/parser/data/kboot-06/etc/kboot.conf b/test/parser/data/kboot-06/etc/kboot.conf new file mode 100644 index 0000000..591c51b --- /dev/null +++ b/test/parser/data/kboot-06/etc/kboot.conf @@ -0,0 +1,9 @@ +# Ubuntu feisty kboot.conf +message=/etc/kboot.msg +timeout=300 +default=live +live='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --' +live_nosplash='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet --' +driverupdates='/casper/vmlinux initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash --' +check='/casper/vmlinux initrd=/casper/initrd.gz boot=casper integrity-check quiet splash --' + diff --git a/test/parser/data/kboot-06/expected-output b/test/parser/data/kboot-06/expected-output new file mode 100644 index 0000000..cc0d096 --- /dev/null +++ b/test/parser/data/kboot-06/expected-output @@ -0,0 +1,24 @@ +[dev 0] id: /dev/ps3da1 +[dev 0] name: (null) +[dev 0] description: (null) +[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png +[opt 0] name: live +[opt 0] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash -- +[opt 0] boot_image: devices/parser-tests/102/ps3da1/casper/vmlinux +[opt 0] initrd: devices/parser-tests/102/ps3da1/casper/initrd.gz +[opt 0] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash -- +[opt 1] name: live_nosplash +[opt 1] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet -- +[opt 1] boot_image: devices/parser-tests/102/ps3da1/casper/vmlinux +[opt 1] initrd: devices/parser-tests/102/ps3da1/casper/initrd.gz +[opt 1] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper quiet -- +[opt 2] name: driverupdates +[opt 2] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash -- +[opt 2] boot_image: devices/parser-tests/102/ps3da1/casper/vmlinux +[opt 2] initrd: devices/parser-tests/102/ps3da1/casper/initrd.gz +[opt 2] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper debian-installer/driver-update=true quiet splash -- +[opt 3] name: check +[opt 3] description: /casper/vmlinux root=/dev/ram0 initrd=/casper/initrd.gz boot=casper integrity-check quiet splash -- +[opt 3] boot_image: devices/parser-tests/102/ps3da1/casper/vmlinux +[opt 3] initrd: devices/parser-tests/102/ps3da1/casper/initrd.gz +[opt 3] boot_args: root=/dev/ram0 initrd=/casper/initrd.gz boot=casper integrity-check quiet splash -- diff --git a/test/parser/data/kboot-07/etc/kboot.conf b/test/parser/data/kboot-07/etc/kboot.conf new file mode 100644 index 0000000..3f8f15c --- /dev/null +++ b/test/parser/data/kboot-07/etc/kboot.conf @@ -0,0 +1,7 @@ +default=tftp_nfs_1080p +timeout=120 + +tftp='tftp://192.168.0.5/fire/boot/vmlinux.strip root=/dev/nfs rw ip=dhcp video=1080p' +nfs='nfs://192.168.0.5/fire/boot/vmlinux.strip root=/dev/nfs rw ip=dhcp video=1080p fbcon=rotate:3' +http_nfs='http://192.168.0.5/ice/boot/vmlinux.strip nfs://192.168.0.5/ice/boot/initrd root=/dev/nfs' + diff --git a/test/parser/data/yaboot-01/etc/yaboot.conf b/test/parser/data/yaboot-01/etc/yaboot.conf new file mode 100644 index 0000000..f13b1b3 --- /dev/null +++ b/test/parser/data/yaboot-01/etc/yaboot.conf @@ -0,0 +1,8 @@ +init-message = "\nWelcome to the 64-bit Yellow Dog Linux 5.0 installer!\nHit for boot options.\n\n" +timeout=6000 +default=linux + +image=/ppc/ppc64/vmlinux + label=linux + initrd=/ppc/ppc64/ramdisk.image.gz + read-only diff --git a/test/parser/data/yaboot-01/expected-output b/test/parser/data/yaboot-01/expected-output new file mode 100644 index 0000000..304f15c --- /dev/null +++ b/test/parser/data/yaboot-01/expected-output @@ -0,0 +1,9 @@ +[dev 0] id: /dev/ps3da1 +[dev 0] name: (null) +[dev 0] description: +[dev 0] boot_image: /usr/share/petitboot/artwork/hdd.png +[opt 0] name: linux +[opt 0] description: (null) +[opt 0] boot_image: devices/parser-tests/002/ps3da1/ppc/ppc64/vmlinux +[opt 0] initrd: devices/parser-tests/002/ps3da1/ppc/ppc64/ramdisk.image.gz +[opt 0] boot_args: ro diff --git a/test/parser/data/yaboot-02/etc/yaboot.conf b/test/parser/data/yaboot-02/etc/yaboot.conf new file mode 100644 index 0000000..8f44792 --- /dev/null +++ b/test/parser/data/yaboot-02/etc/yaboot.conf @@ -0,0 +1,27 @@ +# yaboot.conf generated by anaconda + +boot=/dev/ps3da +init-message="Welcome to Fedora!\nHit for boot options" + +partition=1 +timeout=80 +install=/usr/lib/yaboot/yaboot +enablecdboot +enableofboot +enablenetboot +nonvram +mntpoint=/boot/yaboot +usemount + +image=/boot/vmlinuz-2.6.25-1.fc9.ppc64 + label=2.6.25-1.fc9.pp + read-only + initrd=/boot/initrd-2.6.25-1.fc9.ppc64.img + append="root=UUID=0f1335f2-eaba-4495-8eee-29229bb8ba03" + +image=/boot/vmlinuz-2.6.25-0.234.rc9.git1.fc9.ppc64 + label=linux + read-only + initrd=/boot/initrd-2.6.25-0.234.rc9.git1.fc9.ppc64.img + append="root=UUID=0f1335f2-eaba-4495-8eee-29229bb8ba03" + diff --git a/test/parser/data/yaboot-03/etc/yaboot.conf b/test/parser/data/yaboot-03/etc/yaboot.conf new file mode 100644 index 0000000..56d7062 --- /dev/null +++ b/test/parser/data/yaboot-03/etc/yaboot.conf @@ -0,0 +1,22 @@ +# yaboot.conf generated by anaconda + +boot=/dev/ps3da +init-message="Welcome to Fedora!\nHit for boot options" + +partition=1 +timeout=80 +install=/usr/lib/yaboot/yaboot +delay=5 +enablecdboot +enableofboot +enablenetboot +nonvram +mntpoint=/boot/yaboot +usemount + +image=/boot/vmlinuz-2.6.27.5-117.fc10.ppc64 + label=linux + read-only + initrd=/boot/initrd-2.6.27.5-117.fc10.ppc64.img + append="rhgb quiet root=UUID=ebb54ca2-aa3e-4f67-b1d4-184cdc5d0638" + diff --git a/test/parser/data/yaboot-04/etc/yaboot.conf b/test/parser/data/yaboot-04/etc/yaboot.conf new file mode 100644 index 0000000..7537646 --- /dev/null +++ b/test/parser/data/yaboot-04/etc/yaboot.conf @@ -0,0 +1,10 @@ + +image=111 + read-only + label=linux1 + label = linux2 + append="abc1" + append='abc2' + # read-only + # label=linux3 + # label = linux4 diff --git a/test/parser/data/yaboot-05/etc/yaboot.conf b/test/parser/data/yaboot-05/etc/yaboot.conf new file mode 100644 index 0000000..fd46206 --- /dev/null +++ b/test/parser/data/yaboot-05/etc/yaboot.conf @@ -0,0 +1,6 @@ +# yaboot.conf generated by anaconda +# from a failed fedora install + +boot=/dev/sda2 +init-message="Welcome to Fedora!\nHit for boot options" + diff --git a/test/parser/data/yaboot-06/etc/yaboot.conf b/test/parser/data/yaboot-06/etc/yaboot.conf new file mode 100644 index 0000000..57a2f0d --- /dev/null +++ b/test/parser/data/yaboot-06/etc/yaboot.conf @@ -0,0 +1,25 @@ +# from openSUSE + +message=yaboot.txt + +image[32bit]=inst32 + label=install + append="quiet sysrq=1 insmod=sym53c8xx insmod=ipr " +image[32bit]=inst32 + label=slp + append="quiet sysrq=1 install=slp " +image[32bit]=inst32 + label=rescue + append="quiet sysrq=1 rescue=1 " + + +image[64bit]=inst64 + label=install + append="quiet sysrq=1 insmod=sym53c8xx insmod=ipr " +image[64bit]=inst64 + label=slp + append="quiet sysrq=1 install=slp " +image[64bit]=inst64 + label=rescue + append="quiet sysrq=1 rescue=1 " + 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 +#include +#include +#include +#include + +#include +#include "pb-protocol/pb-protocol.h" +#include + +#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 \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