]> git.ozlabs.org Git - petitboot/commitdiff
test/parser: Update test cases as per new parser requesting conf files
authorNeelesh Gupta <neelegup@linux.vnet.ibm.com>
Mon, 28 Oct 2013 07:15:59 +0000 (12:45 +0530)
committerJeremy Kerr <jk@ozlabs.org>
Wed, 6 Nov 2013 08:34:26 +0000 (16:34 +0800)
Update the parser test code/cases as per new prototyping of parse()
function which doesn't require buf and len to be passed from the caller,
instead reading the configuration data either embedded or from file to
a parser's known conffile.

Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
28 files changed:
test/parser/Makefile.am
test/parser/parser-test.h
test/parser/test-grub2-default-index.c
test/parser/test-grub2-default-multiword.c
test/parser/test-grub2-default.c
test/parser/test-grub2-f18-ppc64.c
test/parser/test-grub2-lexer-error.c
test/parser/test-grub2-load-env.c
test/parser/test-grub2-multiple-resolve.c
test/parser/test-grub2-parser-error.c
test/parser/test-grub2-save-env.c
test/parser/test-grub2-single-line-if.c
test/parser/test-grub2-single.c
test/parser/test-grub2-ubuntu-13_04-x86.c
test/parser/test-kboot-single.c
test/parser/test-pxe-empty.c
test/parser/test-pxe-initrd-in-append.c
test/parser/test-pxe-single.c
test/parser/test-yaboot-default.c
test/parser/test-yaboot-device-override.c
test/parser/test-yaboot-external.c
test/parser/test-yaboot-partition-override.c
test/parser/test-yaboot-partition.c
test/parser/test-yaboot-rh8-ppc64.c
test/parser/test-yaboot-root-global.c
test/parser/test-yaboot-root-override.c
test/parser/test-yaboot-single.c
test/parser/utils.c

index 65dd7fcf491d13688e174229686f1efc67c073ec..32f204d31fa7337f775ca3e8ead1f69c8e7b049c 100644 (file)
@@ -51,8 +51,7 @@ TESTS = \
        test-yaboot-rh8-ppc64 \
        test-pxe-empty \
        test-pxe-single \
        test-yaboot-rh8-ppc64 \
        test-pxe-empty \
        test-pxe-single \
-       test-pxe-initrd-in-append \
-       test-pxe-default
+       test-pxe-initrd-in-append
 
 $(TESTS): %: %.embedded-config.o
 $(TESTS): LDADD += $@.embedded-config.o
 
 $(TESTS): %: %.embedded-config.o
 $(TESTS): LDADD += $@.embedded-config.o
@@ -70,7 +69,9 @@ parser_objs = \
        $(top_srcdir)/discover/resource.c \
        $(top_srcdir)/discover/paths.c \
        $(top_srcdir)/discover/device-handler.c \
        $(top_srcdir)/discover/resource.c \
        $(top_srcdir)/discover/paths.c \
        $(top_srcdir)/discover/device-handler.c \
-       $(top_srcdir)/discover/parser-conf.c
+       $(top_srcdir)/discover/parser-conf.c \
+       $(top_srcdir)/discover/user-event.c \
+       $(top_srcdir)/discover/event.c
 
 libtest_ro_SOURCES = \
        main.c \
 
 libtest_ro_SOURCES = \
        main.c \
index ab3424c7e676c371f9f5f6cf23831c605965399b..7e4ffa255ce002f77a62febbe689bf6ec4e910ba 100644 (file)
@@ -11,10 +11,6 @@ struct parser_test {
        struct discover_context *ctx;
        struct list files;
        struct config *config;
        struct discover_context *ctx;
        struct list files;
        struct config *config;
-       struct {
-               void    *buf;
-               size_t  size;
-       } conf;
 };
 
 /* interface required for parsers */
 };
 
 /* interface required for parsers */
@@ -24,13 +20,13 @@ void __register_parser(struct parser *parser);
 struct discover_device *test_create_device(struct parser_test *test,
                const char *name);
 
 struct discover_device *test_create_device(struct parser_test *test,
                const char *name);
 
-#define test_read_conf_data(t, d) \
-       __test_read_conf_data(t, d, sizeof(d))
+#define test_read_conf_data(t, f, d) \
+       __test_read_conf_data(t, f, d, sizeof(d))
 
 
-void __test_read_conf_data(struct parser_test *test,
+void __test_read_conf_data(struct parser_test *test, const char *conf_file,
                const char *buf, size_t len);
                const char *buf, size_t len);
-void test_read_conf_file(struct parser_test *test, const char *filename);
-void test_set_conf_source(struct parser_test *test, const char *url);
+void test_read_conf_file(struct parser_test *test, const char *filename,
+               const char *conf_file);
 
 int test_run_parser(struct parser_test *test, const char *parser_name);
 
 
 int test_run_parser(struct parser_test *test, const char *parser_name);
 
@@ -38,6 +34,9 @@ void test_hotplug_device(struct parser_test *test, struct discover_device *dev);
 
 void test_add_file_data(struct parser_test *test, struct discover_device *dev,
                const char *filename, const void *data, int size);
 
 void test_add_file_data(struct parser_test *test, struct discover_device *dev,
                const char *filename, const void *data, int size);
+void test_set_event_source(struct parser_test *test);
+void test_set_event_param(struct event *event, const char *name,
+               const char *value);
 
 #define test_add_file_string(test, dev, filename, str) \
        test_add_file_data(test, dev, filename, str, sizeof(str) - 1)
 
 #define test_add_file_string(test, dev, filename, str) \
        test_add_file_data(test, dev, filename, str, sizeof(str) - 1)
@@ -48,8 +47,8 @@ struct discover_boot_option *get_boot_option(struct discover_context *ctx,
 /* embedded config */
 extern const char __embedded_config[];
 extern const size_t __embedded_config_size;
 /* embedded config */
 extern const char __embedded_config[];
 extern const size_t __embedded_config_size;
-#define test_read_conf_embedded(t) \
-       __test_read_conf_data(t, __embedded_config, __embedded_config_size)
+#define test_read_conf_embedded(t, f) \
+       __test_read_conf_data(t, f, __embedded_config, __embedded_config_size)
 
 /**
  * Checks for parser results.
 
 /**
  * Checks for parser results.
index 78835cd9eb8b82104b29d5d70efaa51677e63403..cef8ef579bbfdfdac4b7a21a85a04944e2538ba9 100644 (file)
@@ -19,7 +19,7 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/boot/grub2/grub.cfg");
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
index f7993fece510c0b83d4823495b51d1ede338c9a0..25d1cf1e5f0b3398a7d7a6ae9fe772c6c21cc84f 100644 (file)
@@ -16,7 +16,7 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/grub2/grub.cfg");
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
index b3359d099df54a341b9e7baa28a503f3b4249a28..b083510eddb927760f2be204415ea03b9704275d 100644 (file)
@@ -13,7 +13,7 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/grub2/grub.cfg");
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
index 0baac052f3b5c140b8fbf414d1fe8cdb451573ca..bf59540437610742c6d9058f645c2da43c125591 100644 (file)
@@ -8,7 +8,9 @@ void run_test(struct parser_test *test)
        struct discover_device *dev;
        int i;
 
        struct discover_device *dev;
        int i;
 
-       test_read_conf_file(test, "grub2-f18-ppc64.conf");
+       test_read_conf_file(test, "grub2-f18-ppc64.conf",
+                       "/boot/grub2/grub.cfg");
+
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
index 503ec9996687c2afa51f15d9756ffad2b2bbe4e4..b08760ead8f7573167572e473ed83411cde2fffb 100644 (file)
@@ -7,7 +7,8 @@
 
 void run_test(struct parser_test *test)
 {
 
 void run_test(struct parser_test *test)
 {
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/grub.cfg");
+
        test_run_parser(test, "grub2");
        check_boot_option_count(test->ctx, 0);
 }
        test_run_parser(test, "grub2");
        check_boot_option_count(test->ctx, 0);
 }
index 2f4e96ec74f6f0d9765d5f8dbe8fa907f2f113cd..36fb3c5ff680434214280a99308b49ca7d81a02a 100644 (file)
@@ -18,7 +18,8 @@ void run_test(struct parser_test *test)
                                "# GRUB Environment Block\n"
                                "kernel=vmlinux-from-env\n");
 
                                "# GRUB Environment Block\n"
                                "kernel=vmlinux-from-env\n");
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/boot/grub2/grub.cfg");
+
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
index 4c4a7e9679accd0757016477272b5f755dba03a9..f24c07fabf27f48b444f353f5497e0cf16fed8bc 100644 (file)
@@ -19,7 +19,8 @@ void run_test(struct parser_test *test)
        struct discover_context *ctx;
        struct discover_device *dev;
 
        struct discover_context *ctx;
        struct discover_device *dev;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/grub.cfg");
+
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
index a7a00a43474b2078ce80521d95728463b4b8dd95..92fa75cb6f441585d109038aaf93927aa0871f49 100644 (file)
@@ -7,7 +7,8 @@
 
 void run_test(struct parser_test *test)
 {
 
 void run_test(struct parser_test *test)
 {
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/grub/grub.cfg");
+
        test_run_parser(test, "grub2");
        check_boot_option_count(test->ctx, 0);
 }
        test_run_parser(test, "grub2");
        check_boot_option_count(test->ctx, 0);
 }
index 7a2938f2d4323bee140223d9e246665fc79015c0..826963ee22a677be7c2c6befbc10dacb9bb1abb9 100644 (file)
@@ -86,7 +86,9 @@ static void run_env_test(struct parser_test *test, struct env_test *envtest)
        test_add_file_data(test, test->ctx->device, "/boot/grub/grubenv",
                        env_before, strlen(env_before));
 
        test_add_file_data(test, test->ctx->device, "/boot/grub/grubenv",
                        env_before, strlen(env_before));
 
-       __test_read_conf_data(test, envtest->script, strlen(envtest->script));
+       __test_read_conf_data(test, "/boot/grub2/grub.cfg", envtest->script,
+                       strlen(envtest->script));
+
        test_run_parser(test, "grub2");
 
        check_file_contents(test, test->ctx->device, "/boot/grub/grubenv",
        test_run_parser(test, "grub2");
 
        check_file_contents(test, test->ctx->device, "/boot/grub/grubenv",
index 487d2f38f80e22a3c4f877e29ff2a7af9672a6a8..3a750ba6d0e5310113b74b94ddbf852d09f4b600 100644 (file)
@@ -16,7 +16,8 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/grub.cfg");
+
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
index 7db8eb957896ab7bad2ca4f4a42b5744a719ef01..f12fe535ff645afb0be84c032abfceb75a30f141 100644 (file)
@@ -13,7 +13,8 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/grub2/grub.cfg");
+
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
index 8f9785862d3826d27da4f51ced71dd717d2b9dbb..2f9aefd47333aa02afa12b289d78a538765017d6 100644 (file)
@@ -7,7 +7,8 @@ void run_test(struct parser_test *test)
        struct discover_context *ctx;
        struct discover_device *dev;
 
        struct discover_context *ctx;
        struct discover_device *dev;
 
-       test_read_conf_file(test, "grub2-ubuntu-13_04-x86.conf");
+       test_read_conf_file(test, "grub2-ubuntu-13_04-x86.conf", "/grub.cfg");
+
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
        test_run_parser(test, "grub2");
 
        ctx = test->ctx;
index af7bdabdaf59bc98d5573d00fa6fc3d33d1ba887..228b06dde35fec5688754d6919aed6f0edc8df09 100644 (file)
@@ -9,7 +9,8 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_data(test, config);
+       test_read_conf_data(test, "/kboot.conf", config);
+
        test_run_parser(test, "kboot");
 
        ctx = test->ctx;
        test_run_parser(test, "kboot");
 
        ctx = test->ctx;
index eb3b75877e6bfff0b851d821fd2db7d35e2f1a72..fbc1d8a7d0ef2f8fc7dc3ac9b47cfdb7fbdb571e 100644 (file)
@@ -9,8 +9,12 @@ void run_test(struct parser_test *test)
 {
        struct discover_context *ctx;
 
 {
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
-       test_set_conf_source(test, "tftp://host/dir/conf.txt");
+       test_read_conf_embedded(test, "conf.txt");
+
+       test_set_event_source(test);
+       test_set_event_param(test->ctx->event, "conffile",
+                       "tftp://host/dir/conf.txt");
+
        test_run_parser(test, "pxe");
 
        ctx = test->ctx;
        test_run_parser(test, "pxe");
 
        ctx = test->ctx;
index 3c1c217f4899d6335fb5fc453dc855a359b90fdd..6cd2ef49311ca031b804598aa1cde03acd667fc6 100644 (file)
@@ -14,8 +14,12 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
-       test_set_conf_source(test, "tftp://host/dir/conf.txt");
+       test_read_conf_embedded(test, "conf.txt");
+
+       test_set_event_source(test);
+       test_set_event_param(test->ctx->event, "conffile",
+                       "tftp://host/dir/conf.txt");
+
        test_run_parser(test, "pxe");
 
        ctx = test->ctx;
        test_run_parser(test, "pxe");
 
        ctx = test->ctx;
index 65e30516f4f01b494796d629462cea288348b820..ccb4d5c6462efc721156ecd4725f4adbd14e23ff 100644 (file)
@@ -15,8 +15,12 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
-       test_set_conf_source(test, "tftp://host/dir/conf.txt");
+       test_read_conf_embedded(test, "conf.txt");
+
+       test_set_event_source(test);
+       test_set_event_param(test->ctx->event, "conffile",
+                       "tftp://host/dir/conf.txt");
+
        test_run_parser(test, "pxe");
 
        ctx = test->ctx;
        test_run_parser(test, "pxe");
 
        ctx = test->ctx;
index 66ba3a20051ed1ea5d725af2b9b85ea72233d507..4143defc3d5498805d7f544214c37efd777245ff 100644 (file)
@@ -15,7 +15,8 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/etc/yaboot.conf");
+
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
index ddbe4f40405291674dd35d98d4dec19e154becf3..be9332ff0a7829c262c63211419aaaccbcc1bc00 100644 (file)
@@ -34,7 +34,8 @@ void run_test(struct parser_test *test)
        char *devname;
        int i;
 
        char *devname;
        int i;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/etc/yaboot.conf");
+
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
index bd09b44e8a7999e4c3245293efd5926023f02110..713145f31e007d94c76f08feb01fe70e90988d23 100644 (file)
@@ -15,7 +15,8 @@ void run_test(struct parser_test *test)
        struct discover_context *ctx;
        struct discover_device *dev;
 
        struct discover_context *ctx;
        struct discover_device *dev;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/yaboot.conf");
+
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
index fc23ba0c65731843d89ede8b5135db4bb116e9d3..0231e1a969ca99a987df155cae8f163e09a65c92 100644 (file)
@@ -14,7 +14,8 @@ void run_test(struct parser_test *test)
        struct discover_context *ctx;
        struct discover_device *dev;
 
        struct discover_context *ctx;
        struct discover_device *dev;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/yaboot.conf");
+
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
index 25aa98f0c8c6642df007340d07ae34f5f1e95cc8..462aee927438afb8913479fb08f5e90dbdd17cdf 100644 (file)
@@ -1,4 +1,5 @@
 #include "parser-test.h"
 #include "parser-test.h"
+#include <stdio.h>
 
 #if 0 /* PARSER_EMBEDDED_CONFIG */
 device=sda
 
 #if 0 /* PARSER_EMBEDDED_CONFIG */
 device=sda
@@ -14,7 +15,8 @@ void run_test(struct parser_test *test)
        struct discover_context *ctx;
        struct discover_device *dev;
 
        struct discover_context *ctx;
        struct discover_device *dev;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/yaboot.conf");
+
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
index 8966cfd40c2a2942dec1cb5740fbd7017b140182..3f6571ed2a4a6b51d7ddec4f8bfbb229f9b713c7 100644 (file)
@@ -6,7 +6,8 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_file(test, "yaboot-rh8-ppc64.conf");
+       test_read_conf_file(test, "yaboot-rh8-ppc64.conf", "/yaboot.conf");
+
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
index 6d8da85104b070cd986473dd23bd5e6546677511..c5e7698ecf82c7c0e2f1a9929c736f0756e7f949 100644 (file)
@@ -16,7 +16,8 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/etc/yaboot.conf");
+
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
index 0eea3d4450023a3828616820e4f34dc0db6c68da..74518cf3ee24217747a486e4d117b724b15493a3 100644 (file)
@@ -18,7 +18,8 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/etc/yaboot.conf");
+
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
index 17866e85571143d78822033d71c224ba8fecc52e..f5e1393d48e83c925aa13e41b2bbac27f315c506 100644 (file)
@@ -14,7 +14,8 @@ void run_test(struct parser_test *test)
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
        struct discover_boot_option *opt;
        struct discover_context *ctx;
 
-       test_read_conf_embedded(test);
+       test_read_conf_embedded(test, "/etc/yaboot.conf");
+
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
        test_run_parser(test, "yaboot");
 
        ctx = test->ctx;
index 083d916b082fd4cda6ba3af8a59b370ffa9d5b0c..b80e0e102025430f4ebaece59540481d44fb5814 100644 (file)
@@ -15,6 +15,7 @@
 #include "device-handler.h"
 #include "parser.h"
 #include "resource.h"
 #include "device-handler.h"
 #include "parser.h"
 #include "resource.h"
+#include "event.h"
 
 #include "parser-test.h"
 
 
 #include "parser-test.h"
 
@@ -111,18 +112,20 @@ void test_fini(struct parser_test *test)
        talloc_free(test);
 }
 
        talloc_free(test);
 }
 
-void __test_read_conf_data(struct parser_test *test,
+void __test_read_conf_data(struct parser_test *test, const char *conf_file,
                const char *buf, size_t len)
 {
                const char *buf, size_t len)
 {
-       test->conf.size = len;
-       test->conf.buf = talloc_memdup(test, buf, len);
+       test_add_file_data(test, test->ctx->device, conf_file, buf, len);
 }
 
 }
 
-void test_read_conf_file(struct parser_test *test, const char *filename)
+void test_read_conf_file(struct parser_test *test, const char *filename,
+               const char *conf_file)
 {
        struct stat stat;
 {
        struct stat stat;
+       size_t size;
        char *path;
        int fd, rc;
        char *path;
        int fd, rc;
+       char *buf;
 
        path = talloc_asprintf(test, "%s/%s", TEST_CONF_BASE, filename);
 
 
        path = talloc_asprintf(test, "%s/%s", TEST_CONF_BASE, filename);
 
@@ -134,22 +137,18 @@ void test_read_conf_file(struct parser_test *test, const char *filename)
        assert(!rc);
        (void)rc;
 
        assert(!rc);
        (void)rc;
 
-       test->conf.size = stat.st_size;
-       test->conf.buf = talloc_array(test, char, test->conf.size + 1);
+       size = stat.st_size;
+       buf = talloc_array(test, char, size + 1);
 
 
-       rc = read(fd, test->conf.buf, test->conf.size);
-       assert(rc == (ssize_t)test->conf.size);
+       rc = read(fd, buf, size);
+       assert(rc == (ssize_t)size);
 
 
-       *(char *)(test->conf.buf + test->conf.size) = '\0';
+       *(buf + size) = '\0';
 
        close(fd);
        talloc_free(path);
 
        close(fd);
        talloc_free(path);
-}
 
 
-void test_set_conf_source(struct parser_test *test, const char *url)
-{
-       test->ctx->conf_url = pb_url_parse(test, url);
-       assert(test->ctx->conf_url);
+       test_add_file_data(test, test->ctx->device, conf_file, buf, size);
 }
 
 void test_add_file_data(struct parser_test *test, struct discover_device *dev,
 }
 
 void test_add_file_data(struct parser_test *test, struct discover_device *dev,
@@ -165,6 +164,16 @@ void test_add_file_data(struct parser_test *test, struct discover_device *dev,
        list_add(&test->files, &file->list);
 }
 
        list_add(&test->files, &file->list);
 }
 
+void test_set_event_source(struct parser_test *test)
+{
+        test->ctx->event = talloc_zero(test->ctx, struct event);
+}
+
+void test_set_event_param(struct event *event, const char *name,
+                const char *value)
+{
+        event_set_param(event, name, value);
+}
 
 int parser_request_file(struct discover_context *ctx,
                struct discover_device *dev, const char *filename,
 
 int parser_request_file(struct discover_context *ctx,
                struct discover_device *dev, const char *filename,
@@ -221,6 +230,31 @@ int parser_replace_file(struct discover_context *ctx,
        file->size = len;
        return 0;
 }
        file->size = len;
        return 0;
 }
+
+int parser_request_url(struct discover_context *ctx, struct pb_url *url,
+               char **buf, int *len)
+{
+       struct parser_test *test = ctx->test_data;
+       struct test_file *file;
+       char *tmp;
+
+       list_for_each_entry(&test->files, file, list) {
+               if (strcmp(file->name, url->file))
+                       continue;
+
+               /* the read_file() interface always adds a trailing null
+                * for string-safety; do the same here */
+               tmp = talloc_array(test, char, file->size + 1);
+               memcpy(tmp, file->data, file->size);
+               tmp[file->size] = '\0';
+               *buf = tmp;
+               *len = file->size;
+               return 0;
+       }
+
+       return -1;
+}
+
 int test_run_parser(struct parser_test *test, const char *parser_name)
 {
        struct p_item* i;
 int test_run_parser(struct parser_test *test, const char *parser_name)
 {
        struct p_item* i;
@@ -229,7 +263,7 @@ int test_run_parser(struct parser_test *test, const char *parser_name)
                if (strcmp(i->parser->name, parser_name))
                        continue;
                test->ctx->parser = i->parser;
                if (strcmp(i->parser->name, parser_name))
                        continue;
                test->ctx->parser = i->parser;
-               return i->parser->parse(test->ctx, test->conf.buf, test->conf.size);
+               return i->parser->parse(test->ctx);
        }
 
        errx(EXIT_FAILURE, "%s: parser '%s' not found", __func__, parser_name);
        }
 
        errx(EXIT_FAILURE, "%s: parser '%s' not found", __func__, parser_name);