From a5a787c5d170708be5d15ee9418520917653a104 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Wed, 15 May 2013 16:01:14 +0800 Subject: [PATCH] test/parser: Allow tests to provide pre-loaded config data Some tests may want to use an existing buffer as config data, so add test_read_config_data() to allow this. Signed-off-by: Jeremy Kerr --- test/parser/parser-test.h | 5 +++++ test/parser/utils.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/test/parser/parser-test.h b/test/parser/parser-test.h index e17cbbc..5baa458 100644 --- a/test/parser/parser-test.h +++ b/test/parser/parser-test.h @@ -22,6 +22,11 @@ void __register_parser(struct parser *parser); struct discover_device *test_create_device(struct discover_context *ctx, const char *name); +#define test_read_conf_data(t, d) \ + __test_read_conf_data(t, d, sizeof(d)) + +void __test_read_conf_data(struct parser_test *test, + const char *buf, size_t len); void test_read_conf_file(struct parser_test *test, const char *filename); int test_run_parser(struct parser_test *test, const char *parser_name); diff --git a/test/parser/utils.c b/test/parser/utils.c index 16c415a..a1d0ad2 100644 --- a/test/parser/utils.c +++ b/test/parser/utils.c @@ -85,6 +85,13 @@ void test_fini(struct parser_test *test) talloc_free(test); } +void __test_read_conf_data(struct parser_test *test, + const char *buf, size_t len) +{ + test->conf.size = len; + test->conf.buf = talloc_memdup(test, buf, len); +} + void test_read_conf_file(struct parser_test *test, const char *filename) { struct stat stat; -- 2.39.2