diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-05-06 11:10:36 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-05-16 11:53:34 +0800 |
commit | 29452d63438ec97e5332caf1f45e5e12b1e873f8 (patch) | |
tree | 34b141c6491e645a5d1225b92eb3fbc9f0e85606 /test | |
parent | ca5ea96894c8b50e495d919db2737551e581120c (diff) | |
download | petitboot-29452d63438ec97e5332caf1f45e5e12b1e873f8.zip petitboot-29452d63438ec97e5332caf1f45e5e12b1e873f8.tar.gz |
test/parser: Add check_args helper
Add a small helper to check boot option arguments.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/parser/parser-test.h | 7 | ||||
-rw-r--r-- | test/parser/utils.c | 21 |
2 files changed, 28 insertions, 0 deletions
diff --git a/test/parser/parser-test.h b/test/parser/parser-test.h index 744c914..ac4af40 100644 --- a/test/parser/parser-test.h +++ b/test/parser/parser-test.h @@ -55,5 +55,12 @@ extern const size_t __embedded_config_size; __check_boot_option_count(ctx, count, __FILE__, __LINE__) void __check_boot_option_count(struct discover_context *ctx, int count, const char *file, int line); +/* + * Check that a boot option @opt has args @args + */ +void __check_args(struct discover_boot_option *opt, const char *args, + const char *file, int line); +#define check_args(opt, args) \ + __check_args(opt, args, __FILE__, __LINE__) #endif /* PARSER_TEST_H */ diff --git a/test/parser/utils.c b/test/parser/utils.c index 019ba63..0b4c89f 100644 --- a/test/parser/utils.c +++ b/test/parser/utils.c @@ -179,3 +179,24 @@ void __check_boot_option_count(struct discover_context *ctx, int count, exit(EXIT_FAILURE); } + +void __check_args(struct discover_boot_option *opt, const char *args, + const char *file, int line) +{ + int rc; + + if (!opt->option->boot_args) { + fprintf(stderr, "%s%d: arg check failed\n", file, line); + fprintf(stderr, " no arguments parsed\n"); + fprintf(stderr, " expected '%s'\n", args); + exit(EXIT_FAILURE); + } + + rc = strcmp(opt->option->boot_args, args); + if (rc) { + fprintf(stderr, "%s%d: arg check failed\n", file, line); + fprintf(stderr, " got '%s'\n", opt->option->boot_args); + fprintf(stderr, " expected '%s'\n", args); + exit(EXIT_FAILURE); + } +} |