diff options
author | Geoff Levand <geoff@infradead.org> | 2013-05-18 09:57:07 +0800 |
---|---|---|
committer | Geoff Levand <geoff@infradead.org> | 2013-05-18 09:57:07 +0800 |
commit | 7d20772cc7b4d258ee878b4cb30b313f14502dc7 (patch) | |
tree | ce54ffe159a30ebd887fd015d91434e222664969 /test | |
parent | 9974f2d82b9450eaccd7661b3bfabb686ab8e161 (diff) | |
download | petitboot-7d20772cc7b4d258ee878b4cb30b313f14502dc7.zip petitboot-7d20772cc7b4d258ee878b4cb30b313f14502dc7.tar.gz |
test/parser: Add check_not_present_resource
Add a new routine check_not_present_resource() to check
that a resource is not present. This is typically used
to check that an initrd entry has not been found.
Also add any needed checks for no initrd to the existing
tests.
Signed-off-by: Geoff Levand <geoff@infradead.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/parser/parser-test.h | 8 | ||||
-rw-r--r-- | test/parser/test-grub2-multiple-resolve.c | 4 | ||||
-rw-r--r-- | test/parser/test-grub2-ubuntu-13_04-x86.c | 4 | ||||
-rw-r--r-- | test/parser/utils.c | 7 |
4 files changed, 23 insertions, 0 deletions
diff --git a/test/parser/parser-test.h b/test/parser/parser-test.h index 5ecfefc..ab37443 100644 --- a/test/parser/parser-test.h +++ b/test/parser/parser-test.h @@ -92,4 +92,12 @@ void __check_unresolved_resource(struct resource *res, #define check_unresolved_resource(res) \ __check_unresolved_resource(res, __FILE__, __LINE__) +/** + * Check that a resource (@res) is not present + */ +void __check_not_present_resource(struct resource *res, + const char *file, int line); +#define check_not_present_resource(res) \ + __check_not_present_resource(res, __FILE__, __LINE__) + #endif /* PARSER_TEST_H */ diff --git a/test/parser/test-grub2-multiple-resolve.c b/test/parser/test-grub2-multiple-resolve.c index 3bf4eab..dd78695 100644 --- a/test/parser/test-grub2-multiple-resolve.c +++ b/test/parser/test-grub2-multiple-resolve.c @@ -30,12 +30,16 @@ void run_test(struct parser_test *test) opt[1] = get_boot_option(ctx, 1); check_unresolved_resource(opt[0]->boot_image); + check_not_present_resource(opt[0]->initrd); check_unresolved_resource(opt[1]->boot_image); + check_not_present_resource(opt[1]->initrd); dev = test_create_device(ctx, "external"); dev->uuid = "48c1b787-20ad-47ce-b9eb-b108dddc3535"; test_hotplug_device(test, dev); check_resolved_local_resource(opt[0]->boot_image, dev, "/vmlinux"); + check_not_present_resource(opt[0]->initrd); check_resolved_local_resource(opt[1]->boot_image, dev, "/vmlinux"); + check_not_present_resource(opt[1]->initrd); } diff --git a/test/parser/test-grub2-ubuntu-13_04-x86.c b/test/parser/test-grub2-ubuntu-13_04-x86.c index cc4d283..45da55f 100644 --- a/test/parser/test-grub2-ubuntu-13_04-x86.c +++ b/test/parser/test-grub2-ubuntu-13_04-x86.c @@ -32,11 +32,13 @@ void run_test(struct parser_test *test) opt = get_boot_option(ctx, 3); check_unresolved_resource(opt->boot_image); + check_not_present_resource(opt->initrd); check_name(opt, "Memory test (memtest86+)"); check_args(opt, ""); opt = get_boot_option(ctx, 4); check_unresolved_resource(opt->boot_image); + check_not_present_resource(opt->initrd); check_name(opt, "Memory test (memtest86+, serial console 115200)"); check_args(opt, "console=ttyS0,115200n8"); @@ -67,8 +69,10 @@ void run_test(struct parser_test *test) opt = get_boot_option(ctx, 3); check_resolved_local_resource(opt->boot_image, dev, "/boot/memtest86+.bin"); + check_not_present_resource(opt->initrd); opt = get_boot_option(ctx, 4); check_resolved_local_resource(opt->boot_image, dev, "/boot/memtest86+.bin"); + check_not_present_resource(opt->initrd); } diff --git a/test/parser/utils.c b/test/parser/utils.c index 68fc3de..9a6b2e1 100644 --- a/test/parser/utils.c +++ b/test/parser/utils.c @@ -282,3 +282,10 @@ void __check_unresolved_resource(struct resource *res, if (res->resolved) errx(EXIT_FAILURE, "%s:%d: Resource is resolved", file, line); } + +void __check_not_present_resource(struct resource *res, + const char *file, int line) +{ + if (res) + errx(EXIT_FAILURE, "%s:%d: Resource present", file, line); +} |