]> git.ozlabs.org Git - petitboot/blobdiff - test/parser/utils.c
test/parser: Allow checks for NULL boot_args
[petitboot] / test / parser / utils.c
index de1dc13e8da60cfd789fb1b28ab62dd4d977e49d..f6939828337cfde8aa3ce31b8f1687cea2542e34 100644 (file)
@@ -206,10 +206,19 @@ void __check_boot_option_count(struct discover_context *ctx, int count,
                const char *file, int line)
 {
        struct discover_boot_option *opt;
-       int i = 0;
+       int defaults = 0, i = 0;
 
-       list_for_each_entry(&ctx->boot_options, opt, list)
+       list_for_each_entry(&ctx->boot_options, opt, list) {
                i++;
+               if (opt->option->is_default)
+                       defaults++;
+       }
+
+       if (defaults > 1) {
+               fprintf(stderr, "%s:%d: parser returned multiple default "
+                               "options\n", file, line);
+               exit(EXIT_FAILURE);
+       }
 
        if (i == count)
                return;
@@ -230,6 +239,9 @@ void __check_args(struct discover_boot_option *opt, const char *args,
 {
        int rc;
 
+       if (!opt->option->boot_args && !args)
+               return;
+
        if (!opt->option->boot_args) {
                fprintf(stderr, "%s:%d: arg check failed\n", file, line);
                fprintf(stderr, "  no arguments parsed\n");