X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=test%2Fparser%2Futils.c;h=40737c4f17c8ef6dd0ca00b8ace225f60c7caf3d;hp=de1dc13e8da60cfd789fb1b28ab62dd4d977e49d;hb=e28232f4b8941ccd151abaaae3f18c32400436f3;hpb=f611bde3f182e9a4befb48a0160d1831708aca67 diff --git a/test/parser/utils.c b/test/parser/utils.c index de1dc13..40737c4 100644 --- a/test/parser/utils.c +++ b/test/parser/utils.c @@ -61,6 +61,7 @@ struct discover_device *test_create_device(struct parser_test *test, dev->device->id = talloc_strdup(dev, name); dev->device_path = talloc_asprintf(dev, "/dev/%s", name); dev->mount_path = talloc_asprintf(dev, "/test/mount/%s", name); + dev->mounted = true; return dev; } @@ -74,6 +75,7 @@ static struct discover_context *test_create_context(struct parser_test *test) list_init(&ctx->boot_options); ctx->device = test_create_device_simple(test); + ctx->test_data = test; device_handler_add_device(test->handler, ctx->device); return ctx; @@ -206,10 +208,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 +241,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");