summaryrefslogtreecommitdiffstats
path: root/test/parser
diff options
context:
space:
mode:
Diffstat (limited to 'test/parser')
-rw-r--r--test/parser/Makefile.am12
-rw-r--r--test/parser/extract-config.awk21
-rw-r--r--test/parser/parser-test.h6
3 files changed, 38 insertions, 1 deletions
diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am
index aa4591f..2e97fbe 100644
--- a/test/parser/Makefile.am
+++ b/test/parser/Makefile.am
@@ -47,5 +47,15 @@ LDADD = $(common_libs) $(test_libs)
libtest_o_SOURCES = utils.c parser-test.h handler.c main.c $(parser_test_objs)
+$(check_PROGRAMS): %: %.embedded-config.o
+$(check_PROGRAMS): LDADD += $@.embedded-config.o
-EXTRA_DIST = $(check_DATA)
+extract_config = $(srcdir)/extract-config.awk
+
+%.embedded-config.c: %.c $(extract_config)
+ gawk --file=$(extract_config) $^ > $@
+
+EXTRA_DIST = $(check_DATA) $(extract_config)
+
+CLEANFILES = $(foreach f, $(check_PROGRAMS), \
+ $(f).embedded-config.c $(f).embedded-config.o)
diff --git a/test/parser/extract-config.awk b/test/parser/extract-config.awk
new file mode 100644
index 0000000..e7a5b33
--- /dev/null
+++ b/test/parser/extract-config.awk
@@ -0,0 +1,21 @@
+BEGIN {
+ config=0
+}
+
+/^#if\s*0\s*\/\*\s*PARSER_EMBEDDED_CONFIG/ {
+ config=1
+ print "#include <stdlib.h>"
+ print "const char __embedded_config[] = "
+ next
+}
+!config {
+ next
+}
+/^#endif/ {
+ print ";"
+ print "const size_t __embedded_config_size = sizeof(__embedded_config);"
+ exit
+}
+{
+ print "\t\"" $0 "\\n\""
+}
diff --git a/test/parser/parser-test.h b/test/parser/parser-test.h
index 5baa458..76132d5 100644
--- a/test/parser/parser-test.h
+++ b/test/parser/parser-test.h
@@ -31,4 +31,10 @@ void test_read_conf_file(struct parser_test *test, const char *filename);
int test_run_parser(struct parser_test *test, const char *parser_name);
+/* 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)
+
#endif /* PARSER_TEST_H */
OpenPOWER on IntegriCloud