From d14bf38b9881c385478a460e3058d7cadee107fb Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Fri, 17 Jan 2014 16:36:41 +0800 Subject: test/parser: Check for full URLs in parser tests At present, we only match the 'file' portion of a URL in the parser tests, so we "serve" a file if just the filename (but not the scheme, hostname or path) matches the file we set with test_read_conf_embedded. This change introduces test_read_conf_embedded_url, which we can use to specify a full URL. In this case, the fake parser_request_file matches the entire URL before returning the file data. Signed-off-by: Jeremy Kerr --- test/parser/parser-test.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'test/parser/parser-test.h') diff --git a/test/parser/parser-test.h b/test/parser/parser-test.h index c23a7b0..7c40650 100644 --- a/test/parser/parser-test.h +++ b/test/parser/parser-test.h @@ -21,9 +21,10 @@ struct discover_device *test_create_device(struct parser_test *test, const char *name); #define test_read_conf_data(t, f, d) \ - __test_read_conf_data(t, f, d, sizeof(d)) + __test_read_conf_data(t, t->ctx->device, f, d, sizeof(d)) -void __test_read_conf_data(struct parser_test *test, const char *conf_file, +void __test_read_conf_data(struct parser_test *test, + struct discover_device *dev, const char *conf_file, const char *buf, size_t len); void test_read_conf_file(struct parser_test *test, const char *filename, const char *conf_file); @@ -49,7 +50,12 @@ struct discover_boot_option *get_boot_option(struct discover_context *ctx, extern const char __embedded_config[]; extern const size_t __embedded_config_size; #define test_read_conf_embedded(t, f) \ - __test_read_conf_data(t, f, __embedded_config, __embedded_config_size) + __test_read_conf_data(t, t->ctx->device, f, \ + __embedded_config, __embedded_config_size) + +#define test_read_conf_embedded_url(t, u) \ + __test_read_conf_data(t, NULL, u, \ + __embedded_config, __embedded_config_size) /** * Checks for parser results. -- cgit v1.2.1