Test case for incomplete types
authorPaul Chaignon <paul.chaignon@gmail.com>
Tue, 22 Aug 2017 21:00:08 +0000 (23:00 +0200)
committerBrenden Blanco <bblanco@gmail.com>
Wed, 23 Aug 2017 17:18:38 +0000 (10:18 -0700)
The bcc rewriter segfaults when it encounters an incomplete type
(missing declaration or declaration after use) in a map declaration.

tests/python/test_clang.py

index 376a5dc..70ff1b8 100755 (executable)
@@ -591,6 +591,16 @@ int foo(struct pt_regs *ctx) {
         with self.assertRaises(Exception):
             b = BPF(text=text)
 
+    def test_incomplete_type(self):
+        text = """
+BPF_HASH(drops, struct key_t);
+struct key_t {
+    u64 location;
+};
+"""
+        with self.assertRaises(Exception):
+            b = BPF(text=text)
+
 
 if __name__ == "__main__":
     main()