test generated services.h

This commit is contained in:
Adeeb Shihadeh 2020-07-29 13:45:03 -07:00
parent 3020c2b925
commit 17c3ad78f2
1 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import tempfile
import unittest import unittest
from parameterized import parameterized from parameterized import parameterized
@ -21,10 +22,10 @@ class TestServices(unittest.TestCase):
self.assertFalse(service.port in ports.keys(), f"duplicate port {service.port}") self.assertFalse(service.port in ports.keys(), f"duplicate port {service.port}")
ports[service.port] = name ports[service.port] = name
# TODO: check that the header is valid C
def test_generated_header(self): def test_generated_header(self):
ret = os.system(f"python3 {services.__file__} > /dev/null") with tempfile.NamedTemporaryFile(suffix=".h") as f:
self.assertEqual(ret, 0) ret = os.system(f"python3 {services.__file__} > {f.name} && clang++ /tmp/services.h")
self.assertEqual(ret, 0, f"generated services header is not valid C")
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()