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 376a5dc59e565704646fed64552d1d7ea8f04df6..70ff1b8a7366ad947a80b59e0e4cb03ae4195005 100755 (executable)
@@ -587,6 +587,16 @@ int bar(void) {
 int foo(struct pt_regs *ctx) {
     return bar();
 }
+"""
+        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)