diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-09-20 14:25:30 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-09-20 14:25:30 +0800 |
commit | 85d8a6966cbf5c97023c11620cabd8a63b883e07 (patch) | |
tree | 57bdd1d68bf39316479529239abf284d4a17a565 /test | |
parent | 402884d9d5835879f3c75657a46492cc03261255 (diff) | |
download | petitboot-85d8a6966cbf5c97023c11620cabd8a63b883e07.zip petitboot-85d8a6966cbf5c97023c11620cabd8a63b883e07.tar.gz |
test/parser: check for multiple default options
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/parser/utils.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/parser/utils.c b/test/parser/utils.c index de1dc13..7ebb411 100644 --- a/test/parser/utils.c +++ b/test/parser/utils.c @@ -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; |