summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-08-07 14:00:16 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-08-07 14:30:06 +0800
commitcdaae762f23d137eef7de73f2226f55090ddbec0 (patch)
tree877449205547d353f0080d9c890baab7af0dbb6d /test
parent38d7d1a97d46aacf67675038c927e579bb589310 (diff)
downloadtalos-petitboot-cdaae762f23d137eef7de73f2226f55090ddbec0.tar.gz
talos-petitboot-cdaae762f23d137eef7de73f2226f55090ddbec0.zip
discover/yaboot: fix device parsing
A couple of fixes for yaboot's device-handling code. Firstly, we need to use 'device=' rather than 'root=', as the latter is purely for ybin, to define where the yaboot binary goes. Secondly, we need to respect global and option-specific device= parameters. To do this, we keep all boot_image and initrd strings in the state, and create the actual resources in yaboot_finish. Add a test for all override cases, and fix the incorrect boot= parsing in the rh8 test. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'test')
-rw-r--r--test/parser/Makefile.am1
-rw-r--r--test/parser/test-yaboot-device-override.c79
-rw-r--r--test/parser/test-yaboot-rh8-ppc64.c11
3 files changed, 82 insertions, 9 deletions
diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am
index 4319705..3c6d73b 100644
--- a/test/parser/Makefile.am
+++ b/test/parser/Makefile.am
@@ -36,6 +36,7 @@ TESTS = \
test-yaboot-external \
test-yaboot-root-global \
test-yaboot-root-override \
+ test-yaboot-device-override \
test-yaboot-rh8-ppc64 \
test-pxe-single \
test-pxe-initrd-in-append
diff --git a/test/parser/test-yaboot-device-override.c b/test/parser/test-yaboot-device-override.c
new file mode 100644
index 0000000..5db5788
--- /dev/null
+++ b/test/parser/test-yaboot-device-override.c
@@ -0,0 +1,79 @@
+#include "parser-test.h"
+
+#include <talloc/talloc.h>
+
+#if 0 /* PARSER_EMBEDDED_CONFIG */
+default=
+device=/dev/sda1
+
+image=/vmlinux.1
+ label=linux.1
+ initrd=initrd.1
+
+image=/vmlinux.2
+ device=/dev/sda2
+ label=linux.2
+ initrd=initrd.2
+
+image=sda3:/vmlinux.3
+ device=/dev/sda2
+ label=linux.3
+ initrd=sda3:initrd.3
+
+image=sda4:/vmlinux.4
+ device=/dev/sda3
+ label=linux.4
+ initrd=initrd.4
+#endif
+
+void run_test(struct parser_test *test)
+{
+ struct discover_boot_option *opt[4];
+ struct discover_device *dev[4];
+ struct discover_context *ctx;
+ char *devname;
+ int i;
+
+ test_read_conf_embedded(test);
+ test_run_parser(test, "yaboot");
+
+ ctx = test->ctx;
+
+ check_boot_option_count(ctx, 4);
+
+ for (i = 0; i < 4; i++)
+ opt[i] = get_boot_option(ctx, i);
+
+ check_name(opt[0], "linux.1");
+ check_unresolved_resource(opt[0]->boot_image);
+ check_unresolved_resource(opt[0]->initrd);
+
+ check_name(opt[1], "linux.2");
+ check_unresolved_resource(opt[1]->boot_image);
+ check_unresolved_resource(opt[1]->initrd);
+
+ check_name(opt[2], "linux.3");
+ check_unresolved_resource(opt[2]->boot_image);
+ check_unresolved_resource(opt[2]->initrd);
+
+ check_name(opt[3], "linux.4");
+ check_unresolved_resource(opt[3]->boot_image);
+ check_unresolved_resource(opt[3]->initrd);
+
+ /* hotplug all dependent devices */
+ for (i = 0; i < 4; i++) {
+ devname = talloc_asprintf(test, "sda%d", i + 1);
+ dev[i] = test_create_device(ctx, devname);
+ test_hotplug_device(test, dev[i]);
+ }
+
+ check_resolved_local_resource(opt[0]->boot_image, dev[0], "/vmlinux.1");
+ check_resolved_local_resource(opt[1]->boot_image, dev[1], "/vmlinux.2");
+ check_resolved_local_resource(opt[2]->boot_image, dev[2], "/vmlinux.3");
+ check_resolved_local_resource(opt[3]->boot_image, dev[3], "/vmlinux.4");
+
+ check_resolved_local_resource(opt[0]->initrd, dev[0], "/initrd.1");
+ check_resolved_local_resource(opt[1]->initrd, dev[1], "/initrd.2");
+ check_resolved_local_resource(opt[2]->initrd, dev[2], "/initrd.3");
+ check_resolved_local_resource(opt[3]->initrd, dev[2], "/initrd.4");
+}
diff --git a/test/parser/test-yaboot-rh8-ppc64.c b/test/parser/test-yaboot-rh8-ppc64.c
index 97d0162..8966cfd 100644
--- a/test/parser/test-yaboot-rh8-ppc64.c
+++ b/test/parser/test-yaboot-rh8-ppc64.c
@@ -5,7 +5,6 @@ void run_test(struct parser_test *test)
{
struct discover_boot_option *opt;
struct discover_context *ctx;
- struct discover_device *dev;
test_read_conf_file(test, "yaboot-rh8-ppc64.conf");
test_run_parser(test, "yaboot");
@@ -16,15 +15,9 @@ void run_test(struct parser_test *test)
opt = get_boot_option(ctx, 0);
- check_unresolved_resource(opt->boot_image);
- check_unresolved_resource(opt->initrd);
-
- dev = test_create_device(ctx, "sdb1");
- test_hotplug_device(test, dev);
-
- check_resolved_local_resource(opt->boot_image, dev,
+ check_resolved_local_resource(opt->boot_image, test->ctx->device,
"/boot/vmlinuz-1.0-20121219-1");
- check_resolved_local_resource(opt->initrd, dev,
+ check_resolved_local_resource(opt->initrd, test->ctx->device,
"/boot/initrd-1.0-20121219-1.img");
check_args(opt, "root=/dev/sdb2 root=/dev/sdb2 ro crashkernel=auto "
OpenPOWER on IntegriCloud