]> git.ozlabs.org Git - petitboot/commitdiff
test: Replace parser tests with empty framework
authorJeremy Kerr <jk@ozlabs.org>
Wed, 15 May 2013 07:28:57 +0000 (15:28 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 16 May 2013 03:53:25 +0000 (11:53 +0800)
This change is a major rework of the parser tests. Currently, the parser
tests just run the parsers on each subdir of data/, but we don't
actually check the results.

Rather than just running parsers and expecting a certain fixed output,
the new tests are arbitraty (short!) C programs. This allows us to set
up the device configuration / discover context etc in whatever manner
necessary, and check that the boot options that the parsers emit are
correct.

This change removes all of the old tests, and adds a new "null" test.
Actual tests will be added in subsequent changes.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
30 files changed:
test/parser/Makefile.am
test/parser/data/grub-01/grub.cfg [deleted file]
test/parser/data/grub-02/grub.cfg [deleted file]
test/parser/data/kboot-01/etc/kboot.conf [deleted file]
test/parser/data/kboot-01/expected-output [deleted file]
test/parser/data/kboot-02/etc/kboot.conf [deleted file]
test/parser/data/kboot-02/expected-output [deleted file]
test/parser/data/kboot-03/etc/kboot.conf [deleted file]
test/parser/data/kboot-03/expected-output [deleted file]
test/parser/data/kboot-04/etc/kboot.conf [deleted file]
test/parser/data/kboot-04/expected-output [deleted file]
test/parser/data/kboot-05/etc/kboot.conf [deleted file]
test/parser/data/kboot-05/expected-output [deleted file]
test/parser/data/kboot-06/etc/kboot.conf [deleted file]
test/parser/data/kboot-06/expected-output [deleted file]
test/parser/data/kboot-07/etc/kboot.conf [deleted file]
test/parser/data/yaboot-01/etc/yaboot.conf [deleted file]
test/parser/data/yaboot-01/expected-output [deleted file]
test/parser/data/yaboot-02/etc/yaboot.conf [deleted file]
test/parser/data/yaboot-03/etc/yaboot.conf [deleted file]
test/parser/data/yaboot-04/etc/yaboot.conf [deleted file]
test/parser/data/yaboot-05/etc/yaboot.conf [deleted file]
test/parser/data/yaboot-06/etc/yaboot.conf [deleted file]
test/parser/handler.c [new file with mode: 0644]
test/parser/main.c [new file with mode: 0644]
test/parser/parser-test.c [deleted file]
test/parser/parser-test.h [new file with mode: 0644]
test/parser/run-parser-tests.in [deleted file]
test/parser/test-null.c [new file with mode: 0644]
test/parser/utils.c [new file with mode: 0644]

index 5e7c76583192738b395af237f047e39dd6eac317..aa4591f9f2d707305e4b4f9e7e2e03c980d4de19 100644 (file)
 #  along with this program; if not, write to the Free Software
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+AUTOMAKE_OPTIONS = parallel-tests
 
 AM_CPPFLAGS = \
        -I$(top_srcdir) \
        -I$(top_srcdir)/lib \
-       $(DEFAULT_CPPFLAGS)
+       -I$(top_srcdir)/discover \
+       -DLOCAL_STATE_DIR='"$(localstatedir)"' \
+       -DTEST_CONF_BASE='"$(srcdir)/data"' \
+       -DDEBUG -DPETITBOOT_TEST
 
-AM_CFLAGS = \
-       $(DEFAULT_CFLAGS)
 
-common_libs = \
-       $(top_builddir)/lib/libpbcore.la \
-       $(top_builddir)/discover/libparser.o
+AM_CFLAGS = -O0 -ggdb -Wall -Wextra -Werror
 
-noinst_PROGRAMS = parser-test
+TESTS = test-null
 
-parser_test_SOURCES = parser-test.c
-parser_test_LDADD = $(common_libs)
+check_PROGRAMS = $(TESTS)
+check_LIBRARIES = $(test_libs)
+check_DATA =
 
-noinst_DATA = \
-       data/grub-01/grub.cfg \
-       data/grub-02/grub.cfg \
-       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
+common_libs = $(top_builddir)/lib/libpbcore.la
+test_libs = libtest.o
 
-composed_noinst_scripts = \
-       run-parser-tests
+libtest.o: $(libtest_o_OBJECTS)
+       $(LD) -o $@ -r $^
 
-noinst_SCRIPTS = $(composed_noinst_scripts)
+# objects under test
+parser_test_objs = $(top_srcdir)/discover/resource.c \
+                  $(top_srcdir)/discover/paths.c \
+                  $(top_srcdir)/discover/device-handler.c \
+                  $(top_srcdir)/discover/parser-conf.c
 
-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 $@
+LDADD = $(common_libs) $(test_libs)
 
-composed_files = $(composed_noinst_scripts)
+libtest_o_SOURCES = utils.c parser-test.h handler.c main.c $(parser_test_objs)
 
-EXTRA_DIST = $(addsuffix .in, $(composed_files)) $(noinst_DATA)
 
-MAINTAINERCLEANFILES = Makefile.in
-
-CLEANFILES = $(composed_files) $(addsuffix .tmp, $(composed_files))
+EXTRA_DIST = $(check_DATA)
diff --git a/test/parser/data/grub-01/grub.cfg b/test/parser/data/grub-01/grub.cfg
deleted file mode 100644 (file)
index 57d6a8b..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-#
-# DO NOT EDIT THIS FILE
-#
-# It is automatically generated by grub-mkconfig using templates
-# from /etc/grub.d and settings from /etc/default/grub
-#
-
-### BEGIN /etc/grub.d/00_header ###
-if [ -s $prefix/grubenv ]; then
-  set have_grubenv=true
-  load_env
-fi
-set default="0"
-if [ "${prev_saved_entry}" ]; then
-  set saved_entry="${prev_saved_entry}"
-  save_env saved_entry
-  set prev_saved_entry=
-  save_env prev_saved_entry
-  set boot_once=true
-fi
-
-function savedefault {
-  if [ -z "${boot_once}" ]; then
-    saved_entry="${chosen}"
-    save_env saved_entry
-  fi
-}
-
-function recordfail {
-  set recordfail=1
-  if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
-}
-
-function load_video {
-  insmod vbe
-  insmod vga
-  insmod video_bochs
-  insmod video_cirrus
-}
-
-terminal_input console
-terminal_output console
-if [ "${recordfail}" = 1 ]; then
-  set timeout=-1
-else
-  set timeout=30
-fi
-play 480 440 1
-### END /etc/grub.d/00_header ###
-
-### BEGIN /etc/grub.d/05_debian_theme ###
-set menu_color_normal=white/black
-set menu_color_highlight=black/light-gray
-if background_color 0,71,115; then
-  clear
-fi
-### END /etc/grub.d/05_debian_theme ###
-
-### BEGIN /etc/grub.d/10_linux ###
-if [ ${recordfail} != 1 ]; then
-  if [ -e ${prefix}/gfxblacklist.txt ]; then
-    if hwmatch ${prefix}/gfxblacklist.txt 3; then
-      if [ ${match} = 0 ]; then
-        set linux_gfx_mode=keep
-      else
-        set linux_gfx_mode=text
-      fi
-    else
-      set linux_gfx_mode=text
-    fi
-  else
-    set linux_gfx_mode=keep
-  fi
-else
-  set linux_gfx_mode=text
-fi
-export linux_gfx_mode
-if [ "$linux_gfx_mode" != "text" ]; then load_video; fi
-menuentry 'Ubuntu, with Linux 3.2.0-18-generic' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       set gfxpayload=$linux_gfx_mode
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       linux   /boot/vmlinuz-3.2.0-18-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro   
-       initrd  /boot/initrd.img-3.2.0-18-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-18-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       echo    'Loading Linux 3.2.0-18-generic ...'
-       linux   /boot/vmlinuz-3.2.0-18-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro recovery nomodeset 
-       echo    'Loading initial ramdisk ...'
-       initrd  /boot/initrd.img-3.2.0-18-generic
-}
-submenu "Previous Linux versions" {
-menuentry 'Ubuntu, with Linux 3.2.0-17-generic' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       set gfxpayload=$linux_gfx_mode
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       linux   /boot/vmlinuz-3.2.0-17-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro   
-       initrd  /boot/initrd.img-3.2.0-17-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-17-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       echo    'Loading Linux 3.2.0-17-generic ...'
-       linux   /boot/vmlinuz-3.2.0-17-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro recovery nomodeset 
-       echo    'Loading initial ramdisk ...'
-       initrd  /boot/initrd.img-3.2.0-17-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-16-generic' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       set gfxpayload=$linux_gfx_mode
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       linux   /boot/vmlinuz-3.2.0-16-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro   
-       initrd  /boot/initrd.img-3.2.0-16-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-16-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       echo    'Loading Linux 3.2.0-16-generic ...'
-       linux   /boot/vmlinuz-3.2.0-16-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro recovery nomodeset 
-       echo    'Loading initial ramdisk ...'
-       initrd  /boot/initrd.img-3.2.0-16-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-15-generic' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       set gfxpayload=$linux_gfx_mode
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       linux   /boot/vmlinuz-3.2.0-15-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro   
-       initrd  /boot/initrd.img-3.2.0-15-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-15-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       echo    'Loading Linux 3.2.0-15-generic ...'
-       linux   /boot/vmlinuz-3.2.0-15-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro recovery nomodeset 
-       echo    'Loading initial ramdisk ...'
-       initrd  /boot/initrd.img-3.2.0-15-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-12-generic' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       set gfxpayload=$linux_gfx_mode
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       linux   /boot/vmlinuz-3.2.0-12-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro   
-       initrd  /boot/initrd.img-3.2.0-12-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-12-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       echo    'Loading Linux 3.2.0-12-generic ...'
-       linux   /boot/vmlinuz-3.2.0-12-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro recovery nomodeset 
-       echo    'Loading initial ramdisk ...'
-       initrd  /boot/initrd.img-3.2.0-12-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-11-generic' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       set gfxpayload=$linux_gfx_mode
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       linux   /boot/vmlinuz-3.2.0-11-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro   
-       initrd  /boot/initrd.img-3.2.0-11-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-11-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       echo    'Loading Linux 3.2.0-11-generic ...'
-       linux   /boot/vmlinuz-3.2.0-11-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro recovery nomodeset 
-       echo    'Loading initial ramdisk ...'
-       initrd  /boot/initrd.img-3.2.0-11-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-10-generic' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       set gfxpayload=$linux_gfx_mode
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       linux   /boot/vmlinuz-3.2.0-10-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro   
-       initrd  /boot/initrd.img-3.2.0-10-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-10-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       echo    'Loading Linux 3.2.0-10-generic ...'
-       linux   /boot/vmlinuz-3.2.0-10-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro recovery nomodeset 
-       echo    'Loading initial ramdisk ...'
-       initrd  /boot/initrd.img-3.2.0-10-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-9-generic' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       set gfxpayload=$linux_gfx_mode
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       linux   /boot/vmlinuz-3.2.0-9-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro   
-       initrd  /boot/initrd.img-3.2.0-9-generic
-}
-menuentry 'Ubuntu, with Linux 3.2.0-9-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
-       recordfail
-       insmod gzio
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       echo    'Loading Linux 3.2.0-9-generic ...'
-       linux   /boot/vmlinuz-3.2.0-9-generic root=UUID=2ceaeb4b-f75d-431c-bcde-210f83d7c1e1 ro recovery nomodeset 
-       echo    'Loading initial ramdisk ...'
-       initrd  /boot/initrd.img-3.2.0-9-generic
-}
-}
-### END /etc/grub.d/10_linux ###
-
-### BEGIN /etc/grub.d/20_linux_xen ###
-### END /etc/grub.d/20_linux_xen ###
-
-### BEGIN /etc/grub.d/20_memtest86+ ###
-menuentry "Memory test (memtest86+)" {
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       linux16 /boot/memtest86+.bin
-}
-menuentry "Memory test (memtest86+, serial console 115200)" {
-       insmod part_gpt
-       insmod ext2
-       set root='(hd0,gpt2)'
-       search --no-floppy --fs-uuid --set=root 2ceaeb4b-f75d-431c-bcde-210f83d7c1e1
-       linux16 /boot/memtest86+.bin console=ttyS0,115200n8
-}
-### END /etc/grub.d/20_memtest86+ ###
-
-### BEGIN /etc/grub.d/30_os-prober ###
-### END /etc/grub.d/30_os-prober ###
-
-### BEGIN /etc/grub.d/40_custom ###
-# This file provides an easy way to add custom menu entries.  Simply type the
-# menu entries you want to add after this comment.  Be careful not to change
-# the 'exec tail' line above.
-### END /etc/grub.d/40_custom ###
-
-### BEGIN /etc/grub.d/41_custom ###
-if [ -f  $prefix/custom.cfg ]; then
-  source $prefix/custom.cfg;
-fi
-### END /etc/grub.d/41_custom ###
diff --git a/test/parser/data/grub-02/grub.cfg b/test/parser/data/grub-02/grub.cfg
deleted file mode 100644 (file)
index 85b5cf2..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-# Modified by YaST2. Last modification on Fri Mar  9 11:38:54 PST 2012
-# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
-# For the new kernel it try to figure out old parameters. In case we are not able to recognize it (e.g. change of flavor or strange install order ) it it use as fallback installation parameters from /etc/sysconfig/bootloader
-
-default 2
-timeout 8
-##YaST - generic_mbr
-#gfxmenu (hd0,1)/boot/message
-serial --unit=0 --speed=115200
-terminal --timeout=10 serial console
-##YaST - activate
-
-###Don't change this comment - YaST2 identifier: Original name: linux###
-title G2f9b620 -- openSUSE 12.1 - 3.2.0-rc3-11771
-    root (hd0,1)
-    kernel /boot/vmlinuz-3.2.0-rc3 root=/dev/disk/by-id/ata-GB1000EAMYC_WMATV7016365-part2 resume=/dev/disk/by-id/ata-GB1000EAMYC_WMATV7016365-part1 splash=silent console=ttyS0,115200 showopts maxcpus=4 vga=0x31d
-    initrd /boot/initrd-3.2.0-rc3
-
-###Don't change this comment - YaST2 identifier: Original name: linux###
-title Gf91961f -- openSUSE 12.1 - 3.2.0-11770
-    root (hd0,1)
-    kernel /boot/vmlinuz-3.2. root=/dev/disk/by-id/ata-GB1000EAMYC_WMATV7016365-part2 resume=/dev/disk/by-id/ata-GB1000EAMYC_WMATV7016365-part1 splash=silent console=ttyS0,115200 showopts maxcpus=4 vga=0x31d
-    initrd /boot/initrd-3.2.
-
-###Don't change this comment - YaST2 identifier: Original name: linux###
-title Desktop -- openSUSE 12.1 - 3.1.9-1.4
-    root (hd0,1)
-    kernel /boot/vmlinuz-3.1.9-1.4-desktop root=/dev/disk/by-id/ata-GB1000EAMYC_WMATV7016365-part2 resume=/dev/disk/by-id/ata-GB1000EAMYC_WMATV7016365-part1 splash=silent quiet clocksource=jiffies  showopts vga=0x31a console=ttyS0,115200
-    initrd /boot/initrd-3.1.9-1.4-desktop
-
-###Don't change this comment - YaST2 identifier: Original name: failsafe###
-title Failsafe -- openSUSE 12.1 - 3.1.9-1.4
-    root (hd0,1)
-    kernel /boot/vmlinuz-3.1.9-1.4-desktop root=/dev/disk/by-id/ata-GB1000EAMYC_WMATV7016365-part2 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe vga=0x31a
-    initrd /boot/initrd-3.1.9-1.4-desktop
diff --git a/test/parser/data/kboot-01/etc/kboot.conf b/test/parser/data/kboot-01/etc/kboot.conf
deleted file mode 100644 (file)
index 591c51b..0000000
+++ /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/data/kboot-01/expected-output b/test/parser/data/kboot-01/expected-output
deleted file mode 100644 (file)
index bace9f7..0000000
+++ /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/data/kboot-02/etc/kboot.conf b/test/parser/data/kboot-02/etc/kboot.conf
deleted file mode 100644 (file)
index a7bb199..0000000
+++ /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/data/kboot-02/expected-output b/test/parser/data/kboot-02/expected-output
deleted file mode 100644 (file)
index 4f60310..0000000
+++ /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/data/kboot-03/etc/kboot.conf b/test/parser/data/kboot-03/etc/kboot.conf
deleted file mode 100644 (file)
index 9755f77..0000000
+++ /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/data/kboot-03/expected-output b/test/parser/data/kboot-03/expected-output
deleted file mode 100644 (file)
index 76a90a2..0000000
+++ /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/data/kboot-04/etc/kboot.conf b/test/parser/data/kboot-04/etc/kboot.conf
deleted file mode 100644 (file)
index 72b7db8..0000000
+++ /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/data/kboot-04/expected-output b/test/parser/data/kboot-04/expected-output
deleted file mode 100644 (file)
index bfaccc8..0000000
+++ /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/data/kboot-05/etc/kboot.conf b/test/parser/data/kboot-05/etc/kboot.conf
deleted file mode 100644 (file)
index 4a986c0..0000000
+++ /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/data/kboot-05/expected-output b/test/parser/data/kboot-05/expected-output
deleted file mode 100644 (file)
index 45d99a1..0000000
+++ /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/data/kboot-06/etc/kboot.conf b/test/parser/data/kboot-06/etc/kboot.conf
deleted file mode 100644 (file)
index 591c51b..0000000
+++ /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/data/kboot-06/expected-output b/test/parser/data/kboot-06/expected-output
deleted file mode 100644 (file)
index cc0d096..0000000
+++ /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/data/kboot-07/etc/kboot.conf b/test/parser/data/kboot-07/etc/kboot.conf
deleted file mode 100644 (file)
index 3f8f15c..0000000
+++ /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/data/yaboot-01/etc/yaboot.conf b/test/parser/data/yaboot-01/etc/yaboot.conf
deleted file mode 100644 (file)
index f13b1b3..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-init-message = "\nWelcome to the 64-bit Yellow Dog Linux 5.0 installer!\nHit <TAB> 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
deleted file mode 100644 (file)
index 304f15c..0000000
+++ /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/data/yaboot-02/etc/yaboot.conf b/test/parser/data/yaboot-02/etc/yaboot.conf
deleted file mode 100644 (file)
index 8f44792..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-# yaboot.conf generated by anaconda
-
-boot=/dev/ps3da
-init-message="Welcome to Fedora!\nHit <TAB> 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
deleted file mode 100644 (file)
index 56d7062..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# yaboot.conf generated by anaconda
-
-boot=/dev/ps3da
-init-message="Welcome to Fedora!\nHit <TAB> 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
deleted file mode 100644 (file)
index 7537646..0000000
+++ /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/data/yaboot-05/etc/yaboot.conf b/test/parser/data/yaboot-05/etc/yaboot.conf
deleted file mode 100644 (file)
index fd46206..0000000
+++ /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 <TAB> for boot options"
-
diff --git a/test/parser/data/yaboot-06/etc/yaboot.conf b/test/parser/data/yaboot-06/etc/yaboot.conf
deleted file mode 100644 (file)
index 57a2f0d..0000000
+++ /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/handler.c b/test/parser/handler.c
new file mode 100644 (file)
index 0000000..f585c31
--- /dev/null
@@ -0,0 +1,28 @@
+
+#include <talloc/talloc.h>
+#include <types/types.h>
+
+#include "device-handler.h"
+
+
+void discover_server_notify_device_add(struct discover_server *server,
+               struct device *device)
+{
+       (void)server;
+       (void)device;
+}
+
+void discover_server_notify_boot_option_add(struct discover_server *server,
+               struct boot_option *option)
+{
+       (void)server;
+       (void)option;
+}
+
+void discover_server_notify_device_remove(struct discover_server *server,
+               struct device *device)
+{
+       (void)server;
+       (void)device;
+}
+
diff --git a/test/parser/main.c b/test/parser/main.c
new file mode 100644 (file)
index 0000000..0fdafb4
--- /dev/null
@@ -0,0 +1,21 @@
+
+#include <talloc/talloc.h>
+
+#include "parser-test.h"
+
+extern struct parser_test *test_init(void);
+extern void test_fini(struct parser_test *test);
+extern void run_test(struct parser_test *test);
+
+int main(void)
+{
+       struct parser_test *test;
+
+       test = test_init();
+
+       run_test(test);
+
+       test_fini(test);
+
+       return EXIT_SUCCESS;
+}
diff --git a/test/parser/parser-test.c b/test/parser/parser-test.c
deleted file mode 100644 (file)
index bf4ac6c..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-#define _GNU_SOURCE
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <log/log.h>
-#include <types/types.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;
-
-struct device *discover_context_device(struct discover_context *ctx)
-{
-       return ctx->device->device;
-}
-
-struct discover_boot_option *discover_boot_option_create(
-               struct discover_context *ctx,
-               struct discover_device *dev)
-{
-       struct discover_boot_option *opt;
-
-       opt = talloc_zero(ctx, struct discover_boot_option);
-       opt->option = talloc(opt, struct boot_option);
-       opt->device = dev;
-
-       return opt;
-}
-
-struct discover_device *device_lookup_by_name(
-               struct device_handler *handler __attribute__((unused)),
-               const char *name __attribute__((unused)))
-{
-       return NULL;
-}
-
-struct discover_device *device_lookup_by_label(
-               struct device_handler *handler __attribute__((unused)),
-               const char *label __attribute__((unused)))
-{
-       return NULL;
-}
-
-struct discover_device *device_lookup_by_uuid(
-               struct device_handler *handler __attribute__((unused)),
-               const char *uuid __attribute__((unused)))
-{
-       return NULL;
-}
-
-
-void discover_context_add_boot_option(struct discover_context *ctx,
-               struct discover_boot_option *boot_option)
-{
-       struct boot_option *opt = boot_option->option;
-
-       fprintf(testf, "%s: %s\n", __func__, ctx->device->device->id);
-       fprintf(testf, " id     '%s'\n", opt->id);
-       fprintf(testf, " name   '%s'\n", opt->name);
-       fprintf(testf, " descr  '%s'\n", opt->description);
-       fprintf(testf, " icon   '%s'\n", opt->icon_file);
-       fprintf(testf, " image  '%s'\n", opt->boot_image_file);
-       fprintf(testf, " initrd '%s'\n", opt->initrd_file);
-       fprintf(testf, " args   '%s'\n", opt->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 = talloc_zero(ctx, struct discover_device);
-       ctx->device->device = talloc_zero(ctx->device, struct device);
-       ctx->device->mount_path = talloc_asprintf(ctx, "%s/%s",
-                                                       argv[1], argv[2]);
-       ctx->device->device->id = talloc_strdup(ctx->device->device, argv[2]);
-
-       iterate_parsers(ctx, CONF_METHOD_LOCAL_FILE);
-
-       pb_log("--- end ---\n");
-
-       return EXIT_SUCCESS;
-}
diff --git a/test/parser/parser-test.h b/test/parser/parser-test.h
new file mode 100644 (file)
index 0000000..e17cbbc
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef PARSER_TEST_H
+#define PARSER_TEST_H
+
+#include <stdlib.h>
+
+#include "device-handler.h"
+#include "resource.h"
+
+struct parser_test {
+       struct device_handler *handler;
+       struct discover_context *ctx;
+       struct {
+               void    *buf;
+               size_t  size;
+       } conf;
+};
+
+/* interface required for parsers */
+void __register_parser(struct parser *parser);
+
+/* test functions */
+struct discover_device *test_create_device(struct discover_context *ctx,
+               const char *name);
+
+void test_read_conf_file(struct parser_test *test, const char *filename);
+
+int test_run_parser(struct parser_test *test, const char *parser_name);
+
+#endif /* PARSER_TEST_H */
diff --git a/test/parser/run-parser-tests.in b/test/parser/run-parser-tests.in
deleted file mode 100755 (executable)
index 4c4c2be..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/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
diff --git a/test/parser/test-null.c b/test/parser/test-null.c
new file mode 100644 (file)
index 0000000..954ddc3
--- /dev/null
@@ -0,0 +1,7 @@
+
+#include "parser-test.h"
+
+void run_test(struct parser_test *test)
+{
+       (void)test;
+}
diff --git a/test/parser/utils.c b/test/parser/utils.c
new file mode 100644 (file)
index 0000000..16c415a
--- /dev/null
@@ -0,0 +1,130 @@
+
+#include <assert.h>
+#include <err.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <talloc/talloc.h>
+#include <types/types.h>
+#include <url/url.h>
+
+#include "device-handler.h"
+#include "parser.h"
+#include "resource.h"
+
+#include "parser-test.h"
+
+static int n_parsers;
+static struct parser **parsers;
+
+void __register_parser(struct parser *parser)
+{
+       parsers = talloc_realloc(NULL, parsers, struct parser *, n_parsers + 1);
+       parsers[n_parsers] = parser;
+       n_parsers++;
+}
+
+static struct discover_device *test_create_device_simple(
+               struct discover_context *ctx)
+{
+       static int dev_idx;
+       char name[10];
+
+       sprintf(name, "__test%d", dev_idx++);
+
+       return test_create_device(ctx, name);
+}
+
+struct discover_device *test_create_device(struct discover_context *ctx,
+               const char *name)
+{
+       struct discover_device *dev;
+
+       dev = talloc_zero(ctx, struct discover_device);
+       dev->device = talloc_zero(dev, struct device);
+
+       list_init(&dev->boot_options);
+
+       dev->device->id = talloc_strdup(dev, name);
+       dev->device_path = talloc_asprintf(dev, "/dev/%s", name);
+       dev->mount_path = talloc_asprintf(dev, "/test/mount/%s", name);
+
+       return dev;
+}
+
+static struct discover_context *test_create_context(struct parser_test *test)
+{
+       struct discover_context *ctx;
+
+       ctx = talloc_zero(test, struct discover_context);
+       assert(ctx);
+
+       list_init(&ctx->boot_options);
+       ctx->device = test_create_device_simple(ctx);
+
+       return ctx;
+}
+
+struct parser_test *test_init(void)
+{
+       struct parser_test *test;
+
+       test = talloc_zero(NULL, struct parser_test);
+       test->handler = device_handler_init(NULL, 0);
+       test->ctx = test_create_context(test);
+
+       return test;
+}
+
+void test_fini(struct parser_test *test)
+{
+       device_handler_destroy(test->handler);
+       talloc_free(test);
+}
+
+void test_read_conf_file(struct parser_test *test, const char *filename)
+{
+       struct stat stat;
+       char *path;
+       int fd, rc;
+
+       path = talloc_asprintf(test, "%s/%s", TEST_CONF_BASE, filename);
+
+       fd = open(path, O_RDONLY);
+       if (fd < 0)
+               err(EXIT_FAILURE, "Can't open test conf file %s\n", path);
+
+       rc = fstat(fd, &stat);
+       assert(!rc);
+       (void)rc;
+
+       test->conf.size = stat.st_size;
+       test->conf.buf = talloc_array(test, char, test->conf.size + 1);
+
+       rc = read(fd, test->conf.buf, test->conf.size);
+       assert(rc == (ssize_t)test->conf.size);
+
+       *(char *)(test->conf.buf + test->conf.size) = '\0';
+
+       close(fd);
+       talloc_free(path);
+}
+
+int test_run_parser(struct parser_test *test, const char *parser_name)
+{
+       struct parser *parser;
+       int i, rc = 0;
+
+       for (i = 0; i < n_parsers; i++) {
+               parser = parsers[i];
+               if (strcmp(parser->name, parser_name))
+                       continue;
+               test->ctx->parser = parser;
+               rc = parser->parse(test->ctx, test->conf.buf, test->conf.size);
+       }
+
+       return rc;
+}