Commit adb31b57 authored by Teng Qin's avatar Teng Qin

Fix incorrect lost_cb type in Python

parent 25be6bb4
...@@ -532,7 +532,7 @@ class PerfEventArray(ArrayBase): ...@@ -532,7 +532,7 @@ class PerfEventArray(ArrayBase):
exit() exit()
else: else:
raise e raise e
def lost_cb_(lost): def lost_cb_(_, lost):
try: try:
lost_cb(lost) lost_cb(lost)
except IOError as e: except IOError as e:
......
...@@ -49,6 +49,9 @@ class TestArray(TestCase): ...@@ -49,6 +49,9 @@ class TestArray(TestCase):
event = ct.cast(data, ct.POINTER(Data)).contents event = ct.cast(data, ct.POINTER(Data)).contents
self.counter += 1 self.counter += 1
def lost_cb(lost):
self.assertGreater(lost, 0)
text = """ text = """
BPF_PERF_OUTPUT(events); BPF_PERF_OUTPUT(events);
int kprobe__sys_nanosleep(void *ctx) { int kprobe__sys_nanosleep(void *ctx) {
...@@ -60,7 +63,7 @@ int kprobe__sys_nanosleep(void *ctx) { ...@@ -60,7 +63,7 @@ int kprobe__sys_nanosleep(void *ctx) {
} }
""" """
b = BPF(text=text) b = BPF(text=text)
b["events"].open_perf_buffer(cb) b["events"].open_perf_buffer(cb, lost_cb=lost_cb)
time.sleep(0.1) time.sleep(0.1)
b.kprobe_poll() b.kprobe_poll()
self.assertGreater(self.counter, 0) self.assertGreater(self.counter, 0)
...@@ -77,6 +80,9 @@ int kprobe__sys_nanosleep(void *ctx) { ...@@ -77,6 +80,9 @@ int kprobe__sys_nanosleep(void *ctx) {
event = ct.cast(data, ct.POINTER(Data)).contents event = ct.cast(data, ct.POINTER(Data)).contents
self.events.append(event) self.events.append(event)
def lost_cb(lost):
self.assertGreater(lost, 0)
text = """ text = """
BPF_PERF_OUTPUT(events); BPF_PERF_OUTPUT(events);
int kprobe__sys_nanosleep(void *ctx) { int kprobe__sys_nanosleep(void *ctx) {
...@@ -88,7 +94,7 @@ int kprobe__sys_nanosleep(void *ctx) { ...@@ -88,7 +94,7 @@ int kprobe__sys_nanosleep(void *ctx) {
} }
""" """
b = BPF(text=text) b = BPF(text=text)
b["events"].open_perf_buffer(cb) b["events"].open_perf_buffer(cb, lost_cb=lost_cb)
online_cpus = get_online_cpus() online_cpus = get_online_cpus()
for cpu in online_cpus: for cpu in online_cpus:
subprocess.call(['taskset', '-c', str(cpu), 'sleep', '0.1']) subprocess.call(['taskset', '-c', str(cpu), 'sleep', '0.1'])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment