summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2008-12-15 15:22:34 +1100
committerJeremy Kerr <jk@ozlabs.org>2008-12-15 15:22:34 +1100
commit32e6a41f33e5576716b351bd473a27939fe94fa1 (patch)
tree0d6b75ac0a02d2496416095405cb9498777c3beb /test
parent000a92b4fa909c432732ac3ed8f28eeeaeac70ee (diff)
downloadtalos-petitboot-32e6a41f33e5576716b351bd473a27939fe94fa1.tar.gz
talos-petitboot-32e6a41f33e5576716b351bd473a27939fe94fa1.zip
Initial support for multiple UIs
Move the device discovery code from separate udev helpers to a single process to listen on two sockets: one SOCK_DGRAM for incoming udev events, and one SOCK_STREAM for UIs to connect. Initial support for client/server infrastructure, still need to wire-up the udev messages. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'test')
-rw-r--r--test/parser-test.c85
-rwxr-xr-xtest/parser-test.sh26
-rw-r--r--test/parser/001/expected-output24
-rw-r--r--test/parser/001/ps3da1/etc/kboot.conf9
-rw-r--r--test/parser/002/expected-output9
-rw-r--r--test/parser/002/ps3da1/etc/yaboot.conf8
-rw-r--r--test/parser/003/expected-output9
-rw-r--r--test/parser/003/ps3da1/etc/kboot.conf4
-rw-r--r--test/parser/004/expected-output9
-rw-r--r--test/parser/004/rootdev1
-rw-r--r--test/parser/004/sda1/etc/kboot.conf4
-rw-r--r--test/parser/005/expected-output14
-rw-r--r--test/parser/005/ps3da1/etc/kboot.conf6
-rw-r--r--test/parser/101/expected-output24
-rw-r--r--test/parser/101/ps3da1/etc/kboot.conf12
-rw-r--r--test/parser/102/expected-output24
-rw-r--r--test/parser/102/ps3da1/etc/kboot.conf9
17 files changed, 277 insertions, 0 deletions
diff --git a/test/parser-test.c b/test/parser-test.c
new file mode 100644
index 0000000..8c94d3f
--- /dev/null
+++ b/test/parser-test.c
@@ -0,0 +1,85 @@
+#define _GNU_SOURCE
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "parser.h"
+#include "paths.h"
+
+void pb_log(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
+int mount_device(const char *dev_path)
+{
+ printf("[mount] %s\n", dev_path);
+ return 0;
+}
+
+static int device_idx;
+static int option_idx;
+
+int add_device(const struct device *dev)
+{
+ printf("[dev %2d] id: %s\n", device_idx, dev->id);
+ printf("[dev %2d] name: %s\n", device_idx, dev->name);
+ printf("[dev %2d] description: %s\n", device_idx, dev->description);
+ printf("[dev %2d] boot_image: %s\n", device_idx, dev->icon_file);
+
+ device_idx++;
+ option_idx = 0;
+ return 0;
+}
+
+
+int add_boot_option(const struct boot_option *opt)
+{
+ if (!device_idx) {
+ fprintf(stderr, "Option (%s) added before device\n",
+ opt->name);
+ exit(EXIT_FAILURE);
+ }
+
+ printf("[opt %2d] name: %s\n", option_idx, opt->name);
+ printf("[opt %2d] description: %s\n", option_idx, opt->description);
+ printf("[opt %2d] boot_image: %s\n", option_idx, opt->boot_image_file);
+ printf("[opt %2d] initrd: %s\n", option_idx, opt->initrd_file);
+ printf("[opt %2d] boot_args: %s\n", option_idx, opt->boot_args);
+
+ option_idx++;
+
+ return 0;
+}
+
+enum generic_icon_type guess_device_type(void)
+{
+ return ICON_TYPE_UNKNOWN;
+}
+
+int main(int argc, char **argv)
+{
+ char *mountpoint, *dev;
+
+ if (argc != 3) {
+ fprintf(stderr, "usage: %s <basedir> <devname>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ mountpoint = argv[1];
+ dev = argv[2];
+
+ set_mount_base(mountpoint);
+
+ iterate_parsers(dev, mountpoint);
+
+
+ return EXIT_SUCCESS;
+}
diff --git a/test/parser-test.sh b/test/parser-test.sh
new file mode 100755
index 0000000..140601e
--- /dev/null
+++ b/test/parser-test.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+testdir=devices/parser-tests
+default_rootdev=ps3da1
+
+function test_dir()
+{
+ dir="$1"
+ rootdev=$default_rootdev
+ if [ -e "$dir/rootdev" ]
+ then
+ rootdev=$(cat "$dir/rootdev")
+ fi
+ ./parser-test "$dir" /dev/$rootdev 2>/dev/null |
+ diff -u "$dir/expected-output" -
+}
+
+set -ex
+
+for test in $testdir/*
+do
+ echo $test
+ test_dir "$test"
+done
+
+echo "All tests passed"
diff --git a/test/parser/001/expected-output b/test/parser/001/expected-output
new file mode 100644
index 0000000..bace9f7
--- /dev/null
+++ b/test/parser/001/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/001/ps3da1/etc/kboot.conf b/test/parser/001/ps3da1/etc/kboot.conf
new file mode 100644
index 0000000..591c51b
--- /dev/null
+++ b/test/parser/001/ps3da1/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/002/expected-output b/test/parser/002/expected-output
new file mode 100644
index 0000000..304f15c
--- /dev/null
+++ b/test/parser/002/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/002/ps3da1/etc/yaboot.conf b/test/parser/002/ps3da1/etc/yaboot.conf
new file mode 100644
index 0000000..f13b1b3
--- /dev/null
+++ b/test/parser/002/ps3da1/etc/yaboot.conf
@@ -0,0 +1,8 @@
+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/003/expected-output b/test/parser/003/expected-output
new file mode 100644
index 0000000..4f60310
--- /dev/null
+++ b/test/parser/003/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/003/ps3da1/etc/kboot.conf b/test/parser/003/ps3da1/etc/kboot.conf
new file mode 100644
index 0000000..a7bb199
--- /dev/null
+++ b/test/parser/003/ps3da1/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/004/expected-output b/test/parser/004/expected-output
new file mode 100644
index 0000000..76a90a2
--- /dev/null
+++ b/test/parser/004/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/004/rootdev b/test/parser/004/rootdev
new file mode 100644
index 0000000..36cfa0d
--- /dev/null
+++ b/test/parser/004/rootdev
@@ -0,0 +1 @@
+sda1
diff --git a/test/parser/004/sda1/etc/kboot.conf b/test/parser/004/sda1/etc/kboot.conf
new file mode 100644
index 0000000..9755f77
--- /dev/null
+++ b/test/parser/004/sda1/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/005/expected-output b/test/parser/005/expected-output
new file mode 100644
index 0000000..bfaccc8
--- /dev/null
+++ b/test/parser/005/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/005/ps3da1/etc/kboot.conf b/test/parser/005/ps3da1/etc/kboot.conf
new file mode 100644
index 0000000..72b7db8
--- /dev/null
+++ b/test/parser/005/ps3da1/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/101/expected-output b/test/parser/101/expected-output
new file mode 100644
index 0000000..45d99a1
--- /dev/null
+++ b/test/parser/101/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/101/ps3da1/etc/kboot.conf b/test/parser/101/ps3da1/etc/kboot.conf
new file mode 100644
index 0000000..4a986c0
--- /dev/null
+++ b/test/parser/101/ps3da1/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/102/expected-output b/test/parser/102/expected-output
new file mode 100644
index 0000000..cc0d096
--- /dev/null
+++ b/test/parser/102/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/102/ps3da1/etc/kboot.conf b/test/parser/102/ps3da1/etc/kboot.conf
new file mode 100644
index 0000000..591c51b
--- /dev/null
+++ b/test/parser/102/ps3da1/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 --'
+
OpenPOWER on IntegriCloud