Files
rk35xx-android14/external/bcc/tests/python/test_shared_table.py
T
hmz007 36ed224bac Rockchip Anroid14_SDK 20240628-rkr5 (2556df1a)
Signed-off-by: hmz007 <hmz007@gmail.com>
Change-Id: Ib87fdbe7a0be7dc961af3500fe9ea4589a127f9f
2024-10-29 18:12:02 +08:00

24 lines
695 B
Python

#!/usr/bin/env python3
# Copyright (c) 2016 Facebook, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
import ctypes as ct
import unittest
from bcc import BPF
class TestSharedTable(unittest.TestCase):
def test_close_extern(self):
b1 = BPF(text="""BPF_TABLE_PUBLIC("array", int, int, table1, 10);""")
with BPF(text="""BPF_TABLE("extern", int, int, table1, 10);""") as b2:
t2 = b2["table1"]
t2[ct.c_int(1)] = ct.c_int(10)
self.assertEqual(len(t2), 10)
t1 = b1["table1"]
self.assertEqual(t1[ct.c_int(1)].value, 10)
self.assertEqual(len(t1), 10)
if __name__ == "__main__":
unittest.main()