locitest: generate tests from the test_data files

The "c" section of the test data file should allocate and populate a LOCI
object. The resulting wire buffer is compared to the "binary" section.

This only tests serialization, but given that we have autogenerated tests that
round-trip each object I think this is sufficient.

I added C sections to the OF 1.0 test data files. OF 1.3 tests will come in a
future pull request.
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index 54d18b7..ff111f8 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -66,6 +66,8 @@
 import loxi_front_end.type_maps as type_maps
 import loxi_utils.loxi_utils as loxi_utils
 import loxi_front_end.identifiers as identifiers
+import util
+import test_data
 
 def var_name_map(m_type):
     """
@@ -340,6 +342,7 @@
 extern int run_list_limits_tests(void);
 
 extern int test_ext_objs(void);
+extern int test_datafiles(void);
 
 """)
 
@@ -1966,3 +1969,16 @@
 }
 """)
 
+def gen_datafiles_tests(out, name):
+    tests = []
+    for filename in test_data.list_files():
+        data = test_data.read(filename)
+        if not 'c' in data:
+            continue
+        name = filename[:-5].replace("/", "_")
+        tests.append(dict(name=name,
+                          filename=filename,
+                          c=data['c'],
+                          binary=data['binary']))
+
+    util.render_template(out, "test_data.c", tests=tests)