]> git.ozlabs.org Git - petitboot/commitdiff
test/parser: Add check_not_present_resource
authorGeoff Levand <geoff@infradead.org>
Sat, 18 May 2013 01:57:07 +0000 (09:57 +0800)
committerGeoff Levand <geoff@infradead.org>
Sat, 18 May 2013 01:57:07 +0000 (09:57 +0800)
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>
test/parser/parser-test.h
test/parser/test-grub2-multiple-resolve.c
test/parser/test-grub2-ubuntu-13_04-x86.c
test/parser/utils.c

index 5ecfefc9b6ee46f7b469515651464e7d0d649564..ab3744315f1260ddc1a5787a2aadc0436a7e925b 100644 (file)
@@ -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 */
index 3bf4eab5560b83a09aa222d00cad57369ffdeb6f..dd7869512855776be4a2f07d3a0930cad4167859 100644 (file)
@@ -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);
 }
index cc4d2838a1ba0325dfdf3c0e2d07af7b9cad39d5..45da55ff8b1686fec6b02b17d1e307cc268a5e10 100644 (file)
@@ -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);
 }
index 68fc3debb333baf36cc2560dc8668393d0effe3e..9a6b2e145061969eabaf62a9d96ebc72823825df 100644 (file)
@@ -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);
+}