test/parser: check for multiple default options
authorJeremy Kerr <jk@ozlabs.org>
Fri, 20 Sep 2013 06:25:30 +0000 (14:25 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Fri, 20 Sep 2013 06:25:30 +0000 (14:25 +0800)
Update check_boot_option_count to check if a parser returned more than
one boot option with is_default set.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
test/parser/utils.c

index de1dc13e8da60cfd789fb1b28ab62dd4d977e49d..7ebb411c0c9f6eb664991da10e75b7fb684a64c3 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;