summaryrefslogtreecommitdiff
path: root/pmt/src/lib/generate_unv.py
diff options
context:
space:
mode:
authoreb2006-08-03 23:42:44 +0000
committereb2006-08-03 23:42:44 +0000
commite6ba43e3c978a9212b21da25819934098ae75fca (patch)
tree315da7592d4eb1aaf09e9e0c7e56f54bef6dd85c /pmt/src/lib/generate_unv.py
parent0f53423b1973cf31a44fafe6b2a28e37061527f7 (diff)
downloadgnuradio-e6ba43e3c978a9212b21da25819934098ae75fca.tar.gz
gnuradio-e6ba43e3c978a9212b21da25819934098ae75fca.tar.bz2
gnuradio-e6ba43e3c978a9212b21da25819934098ae75fca.zip
merged interim/pmt r2248:HEAD into trunk
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@3128 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'pmt/src/lib/generate_unv.py')
-rwxr-xr-xpmt/src/lib/generate_unv.py68
1 files changed, 60 insertions, 8 deletions
diff --git a/pmt/src/lib/generate_unv.py b/pmt/src/lib/generate_unv.py
index 46a168a1d..a9d63f038 100755
--- a/pmt/src/lib/generate_unv.py
+++ b/pmt/src/lib/generate_unv.py
@@ -66,11 +66,6 @@ header = """\
*/
"""
-guard_head = """
-#ifndef INCLUDED_PMT_UNV_INT_H
-#define INCLUDED_PMT_UNV_INT_H
-"""
-
guard_tail = """
#endif
"""
@@ -85,6 +80,14 @@ includes = """
"""
+qa_includes = """
+#include <qa_pmt_unv.h>
+#include <cppunit/TestAssert.h>
+#include <pmt.h>
+#include <stdio.h>
+
+"""
+
# set srcdir to the directory that contains Makefile.am
try:
@@ -99,6 +102,17 @@ def open_src (name, mode):
return open(os.path.join (srcdir, name), mode)
+def guard_name(filename):
+ return 'INCLUDED_' + re.sub('\.', '_', filename.upper())
+
+def guard_head(filename):
+ guard = guard_name(filename)
+ return """
+#ifndef %s
+#define %s
+""" % (guard, guard)
+
+
def do_substitution (d, input, out_file):
def repl (match_obj):
key = match_obj.group (1)
@@ -111,15 +125,15 @@ def do_substitution (d, input, out_file):
def generate_h():
template = open_src('unv_template.h.t', 'r').read()
- output = open('pmt_unv_int.h', 'w')
+ output_filename = 'pmt_unv_int.h'
+ output = open(output_filename, 'w')
output.write(header)
- output.write(guard_head)
+ output.write(guard_head(output_filename))
for tag, typ in unv_types:
d = { 'TAG' : tag, 'TYPE' : typ }
do_substitution(d, template, output)
output.write(guard_tail)
-
def generate_cc():
template = open_src('unv_template.cc.t', 'r').read()
output = open('pmt_unv.cc', 'w')
@@ -130,9 +144,47 @@ def generate_cc():
do_substitution(d, template, output)
+def generate_qa_h():
+ output_filename = 'qa_pmt_unv.h'
+ output = open(output_filename, 'w')
+ output.write(header)
+ output.write(guard_head(output_filename))
+
+ output.write('''
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_pmt_unv : public CppUnit::TestCase {
+
+ CPPUNIT_TEST_SUITE(qa_pmt_unv);
+''')
+ for tag, typ in unv_types:
+ output.write(' CPPUNIT_TEST(test_%svector);\n' % (tag,))
+ output.write('''\
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+''')
+ for tag, typ in unv_types:
+ output.write(' void test_%svector();\n' % (tag,))
+ output.write('};\n')
+ output.write(guard_tail)
+
+def generate_qa_cc():
+ template = open_src('unv_qa_template.cc.t', 'r').read()
+ output = open('qa_pmt_unv.cc', 'w')
+ output.write(header)
+ output.write(qa_includes)
+ for tag, typ in unv_types:
+ d = { 'TAG' : tag, 'TYPE' : typ }
+ do_substitution(d, template, output)
+
+
def main():
generate_h()
generate_cc()
+ generate_qa_h()
+ generate_qa_cc()
if __name__ == '__main__':
main()