Fixed failing test_simple_library() in test_uprobes.py
authorMichael Przybylski <mike.przybylski@appdynamics.com>
Fri, 20 Jan 2017 07:21:07 +0000 (23:21 -0800)
committerMichael Przybylski <mike.przybylski@appdynamics.com>
Thu, 9 Feb 2017 14:57:57 +0000 (06:57 -0800)
tests/python/test_uprobes.py

index c22efbb..e5b10ec 100755 (executable)
@@ -24,18 +24,18 @@ int count(struct pt_regs *ctx) {
         incr(0);
     return 0;
 }"""
-        text = text.replace("PID", "%d" % os.getpid())
-        print text
+        test_pid = os.getpid()
+        text = text.replace("PID", "%d" % test_pid)
         b = bcc.BPF(text=text)
-        b.attach_uprobe(name="c", sym="malloc_stats", fn_name="count")
-        b.attach_uretprobe(name="c", sym="malloc_stats", fn_name="count")
+        b.attach_uprobe(name="c", sym="malloc_stats", fn_name="count", pid=test_pid)
+        b.attach_uretprobe(name="c", sym="malloc_stats", fn_name="count", pid=test_pid)
         libc = ctypes.CDLL("libc.so.6")
         libc.malloc_stats.restype = None
         libc.malloc_stats.argtypes = []
         libc.malloc_stats()
         self.assertEqual(b["stats"][ctypes.c_int(0)].value, 2)
-        b.detach_uretprobe(name="c", sym="malloc_stats")
-        b.detach_uprobe(name="c", sym="malloc_stats")
+        b.detach_uretprobe(name="c", sym="malloc_stats", pid=test_pid)
+        b.detach_uprobe(name="c", sym="malloc_stats", pid=test_pid)
 
     def test_simple_binary(self):
         text = """