Skip to content

Commit f02c87c

Browse files
authored
fix some test cases failed (iovisor#3235)
* tests/test_uprobes.py: set larger sleep time to pass test on aarch64 * test/test_clang.py: attach to vfs_read after failed to attach __vfs_read * tests/test_clang_complex.c: set BPF_TABLE array key type to int array_map_check_btf in kernel/bpf/arraymap.c check key type must be BTF_KIND_INT Signed-off-by: Chunmei Xu <[email protected]>
1 parent 0d86893 commit f02c87c

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

tests/python/test_clang.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,11 @@ def test_unary_operator(self):
852852
}
853853
"""
854854
b = BPF(text=text)
855-
b.attach_kprobe(event="__vfs_read", fn_name="trace_read_entry")
855+
try:
856+
b.attach_kprobe(event="__vfs_read", fn_name="trace_read_entry")
857+
except Exception:
858+
print('Current kernel does not have __vfs_read, try vfs_read instead')
859+
b.attach_kprobe(event="vfs_read", fn_name="trace_read_entry")
856860

857861
def test_printk_f(self):
858862
text = """

tests/python/test_clang_complex.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@ struct FwdLeaf {
1313
BPF_HASH(fwd_map, struct FwdKey, struct FwdLeaf, 1);
1414

1515
// array
16-
struct ConfigKey {
17-
u32 index;
18-
};
1916
struct ConfigLeaf {
2017
u32 bpfdev_ip;
2118
u32 slave_ip;
2219
};
23-
BPF_TABLE("array", struct ConfigKey, struct ConfigLeaf, config_map, 1);
20+
BPF_TABLE("array", u32, struct ConfigLeaf, config_map, 1);
2421

2522
// hash
2623
struct MacaddrKey {
@@ -49,7 +46,7 @@ int handle_packet(struct __sk_buff *skb) {
4946
// make sure configured
5047
u32 slave_ip;
5148

52-
struct ConfigKey cfg_key = {.index = 0};
49+
u32 cfg_key = 0;
5350
struct ConfigLeaf *cfg_leaf = config_map.lookup(&cfg_key);
5451
if (cfg_leaf) {
5552
slave_ip = cfg_leaf->slave_ip;
@@ -132,7 +129,7 @@ int handle_packet(struct __sk_buff *skb) {
132129
u64 src_mac;
133130
u64 dst_mac;
134131

135-
struct ConfigKey cfg_key = {.index = 0};
132+
u32 cfg_key = 0;
136133
struct ConfigLeaf *cfg_leaf = config_map.lookup(&cfg_key);
137134
if (cfg_leaf) {
138135
struct MacaddrKey mac_key = {.ip = cfg_leaf->bpfdev_ip};

tests/python/test_uprobes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def test_mount_namespace(self):
119119
shutil.copy(libz_path, b"/tmp")
120120

121121
libz = ctypes.CDLL("/tmp/libz.so.1")
122-
time.sleep(1)
122+
time.sleep(3)
123123
libz.zlibVersion()
124124
time.sleep(5)
125125
os._exit(0)
@@ -130,7 +130,7 @@ def test_mount_namespace(self):
130130
b = bcc.BPF(text=text)
131131
b.attach_uprobe(name=libname, sym=symname, fn_name="count", pid=child_pid)
132132
b.attach_uretprobe(name=libname, sym=symname, fn_name="count", pid=child_pid)
133-
time.sleep(1)
133+
time.sleep(5)
134134
self.assertEqual(b["stats"][ctypes.c_int(0)].value, 2)
135135
b.detach_uretprobe(name=libname, sym=symname, pid=child_pid)
136136
b.detach_uprobe(name=libname, sym=symname, pid=child_pid)

0 commit comments

Comments
 (0)