summaryrefslogtreecommitdiffstats
path: root/test/parser/extract-config.awk
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-05-15 13:11:43 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-05-16 11:53:34 +0800
commite0a7cb18a4237aa826e5e121ff17373814a1872d (patch)
tree110f5785d90478752e7a194c4f4ae4c76692f3b1 /test/parser/extract-config.awk
parenta5a787c5d170708be5d15ee9418520917653a104 (diff)
downloadtalos-petitboot-e0a7cb18a4237aa826e5e121ff17373814a1872d.tar.gz
talos-petitboot-e0a7cb18a4237aa826e5e121ff17373814a1872d.zip
test/parser: Allow raw config data in test .c files
Add a little post-processing script (extract-config.awk) to allow us to put the config data directly into the test .c files, without having to quote the C string. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'test/parser/extract-config.awk')
-rw-r--r--test/parser/extract-config.awk21
1 files changed, 21 insertions, 0 deletions
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\""
+}
OpenPOWER on IntegriCloud