summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-08-07 14:39:40 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-08-07 14:39:40 +0800
commitd6166b471a9356355ed16747de3c0febd4b8cd3e (patch)
treef7cb0113174e607469f7ddf9b06201a5aa3ddf03 /test
parentcdaae762f23d137eef7de73f2226f55090ddbec0 (diff)
downloadtalos-petitboot-d6166b471a9356355ed16747de3c0febd4b8cd3e.tar.gz
talos-petitboot-d6166b471a9356355ed16747de3c0febd4b8cd3e.zip
discover/yaboot: implement default options
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'test')
-rw-r--r--test/parser/Makefile.am1
-rw-r--r--test/parser/parser-test.h8
-rw-r--r--test/parser/test-yaboot-default.c28
-rw-r--r--test/parser/utils.c10
4 files changed, 47 insertions, 0 deletions
diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am
index 3c6d73b..9bb7c16 100644
--- a/test/parser/Makefile.am
+++ b/test/parser/Makefile.am
@@ -37,6 +37,7 @@ TESTS = \
test-yaboot-root-global \
test-yaboot-root-override \
test-yaboot-device-override \
+ test-yaboot-default \
test-yaboot-rh8-ppc64 \
test-pxe-single \
test-pxe-initrd-in-append
diff --git a/test/parser/parser-test.h b/test/parser/parser-test.h
index 5329618..df9670f 100644
--- a/test/parser/parser-test.h
+++ b/test/parser/parser-test.h
@@ -75,6 +75,14 @@ void __check_name(struct discover_boot_option *opt, const char *name,
__check_name(opt, name, __FILE__, __LINE__)
/**
+ * Check that a boot option @opt is marked as default
+ */
+void __check_is_default(struct discover_boot_option *opt,
+ const char *file, int line);
+#define check_is_default(opt) \
+ __check_is_default(opt, __FILE__, __LINE__)
+
+/**
* Check that a resource (@res) is present, resolved, and has a local path
* (within @dev's mount point) of @path.
*/
diff --git a/test/parser/test-yaboot-default.c b/test/parser/test-yaboot-default.c
new file mode 100644
index 0000000..66ba3a2
--- /dev/null
+++ b/test/parser/test-yaboot-default.c
@@ -0,0 +1,28 @@
+#include "parser-test.h"
+
+#if 0 /* PARSER_EMBEDDED_CONFIG */
+default=linux.2
+
+image=/vmlinux
+ label=linux.1
+
+image=/vmlinux
+ label=linux.2
+#endif
+
+void run_test(struct parser_test *test)
+{
+ struct discover_boot_option *opt;
+ struct discover_context *ctx;
+
+ test_read_conf_embedded(test);
+ test_run_parser(test, "yaboot");
+
+ ctx = test->ctx;
+
+ check_boot_option_count(ctx, 2);
+
+ opt = get_boot_option(ctx, 1);
+ check_name(opt, "linux.2");
+ check_is_default(opt);
+}
diff --git a/test/parser/utils.c b/test/parser/utils.c
index 3e218e4..407ac80 100644
--- a/test/parser/utils.c
+++ b/test/parser/utils.c
@@ -262,6 +262,16 @@ void __check_name(struct discover_boot_option *opt, const char *name,
}
}
+void __check_is_default(struct discover_boot_option *opt,
+ const char *file, int line)
+{
+ if (opt->option->is_default)
+ return;
+
+ fprintf(stderr, "%s:%d: default check failed\n", file, line);
+ exit(EXIT_FAILURE);
+}
+
void __check_resolved_local_resource(struct resource *res,
struct discover_device *dev, const char *local_path,
const char *file, int line)
OpenPOWER on IntegriCloud