From c14b12980885edd035322cd3bc87efff444c39b1 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Wed, 29 Jan 2014 13:28:06 +0800 Subject: pb-config: Move config storage modules to "platform" modules in discover code There's no need to include the config storage code in lib/ as only the discover server should be using it. This change moves the config-storage code to discover/, with the platform-specific parts moved to a 'struct platform'. Each platform has a probe function, which is called during init. The first probe function to return a platform is used. At present we only have the one platform, but it's now non-intrusive to add others. We keep an array of platform pointers in a separate ("platforms") section, to allow the test module to drop-in its own test "platform". Signed-off-by: Jeremy Kerr --- test/parser/Makefile.am | 1 + test/parser/parser-test.h | 1 - test/parser/utils.c | 18 ++++++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am index 9393b2a..aeb16d8 100644 --- a/test/parser/Makefile.am +++ b/test/parser/Makefile.am @@ -82,6 +82,7 @@ parser_objs = \ $(top_srcdir)/discover/yaboot-parser.c \ $(top_srcdir)/discover/kboot-parser.c \ $(top_srcdir)/discover/pxe-parser.c \ + $(top_srcdir)/discover/platform.c \ $(top_srcdir)/discover/resource.c \ $(top_srcdir)/discover/paths.c \ $(top_srcdir)/discover/device-handler.c \ diff --git a/test/parser/parser-test.h b/test/parser/parser-test.h index 631f1e5..c0339b8 100644 --- a/test/parser/parser-test.h +++ b/test/parser/parser-test.h @@ -10,7 +10,6 @@ struct parser_test { struct device_handler *handler; struct discover_context *ctx; struct list files; - struct config *config; }; /* interface required for parsers */ diff --git a/test/parser/utils.c b/test/parser/utils.c index 838250b..8a6314b 100644 --- a/test/parser/utils.c +++ b/test/parser/utils.c @@ -16,6 +16,7 @@ #include "parser.h" #include "resource.h" #include "event.h" +#include "platform.h" #include "parser-test.h" @@ -95,14 +96,26 @@ static struct discover_context *test_create_context(struct parser_test *test) return ctx; } -extern struct config *test_config_init(struct parser_test *test); +/* define our own test platform */ +static bool test_platform_probe(struct platform *p __attribute__((unused)), + void *ctx __attribute__((unused))) +{ + return true; +} + +struct platform test_platform = { + .name = "test", + .probe = test_platform_probe, +}; + +register_platform(test_platform); struct parser_test *test_init(void) { struct parser_test *test; test = talloc_zero(NULL, struct parser_test); - test->config = test_config_init(test); + platform_init(NULL); test->handler = device_handler_init(NULL, NULL, 0); test->ctx = test_create_context(test); list_init(&test->files); @@ -114,6 +127,7 @@ void test_fini(struct parser_test *test) { device_handler_destroy(test->handler); talloc_free(test); + platform_fini(); } void __test_read_conf_data(struct parser_test *test, -- cgit v1.1