@@ -171,33 +171,6 @@ static int write_test_packet(int tap_fd)
171171 return 0 ;
172172}
173173
174- static void assert_test_result (const struct bpf_map * result_map )
175- {
176- int err ;
177- __u32 map_key = 0 ;
178- __u8 map_value [TEST_PAYLOAD_LEN ];
179-
180- err = bpf_map__lookup_elem (result_map , & map_key , sizeof (map_key ),
181- & map_value , TEST_PAYLOAD_LEN , BPF_ANY );
182- if (!ASSERT_OK (err , "lookup test_result" ))
183- return ;
184-
185- ASSERT_MEMEQ (& map_value , & test_payload , TEST_PAYLOAD_LEN ,
186- "test_result map contains test payload" );
187- }
188-
189- static bool clear_test_result (struct bpf_map * result_map )
190- {
191- const __u8 v [sizeof (test_payload )] = {};
192- const __u32 k = 0 ;
193- int err ;
194-
195- err = bpf_map__update_elem (result_map , & k , sizeof (k ), v , sizeof (v ), BPF_ANY );
196- ASSERT_OK (err , "update test_result" );
197-
198- return err == 0 ;
199- }
200-
201174void test_xdp_context_veth (void )
202175{
203176 LIBBPF_OPTS (bpf_tc_hook , tc_hook , .attach_point = BPF_TC_INGRESS );
@@ -270,11 +243,13 @@ void test_xdp_context_veth(void)
270243 if (!ASSERT_GE (tx_ifindex , 0 , "if_nametoindex tx" ))
271244 goto close ;
272245
246+ skel -> bss -> test_pass = false;
247+
273248 ret = send_test_packet (tx_ifindex );
274249 if (!ASSERT_OK (ret , "send_test_packet" ))
275250 goto close ;
276251
277- assert_test_result (skel -> maps . test_result );
252+ ASSERT_TRUE (skel -> bss -> test_pass , "test_pass" );
278253
279254close :
280255 close_netns (nstoken );
@@ -286,7 +261,7 @@ void test_xdp_context_veth(void)
286261static void test_tuntap (struct bpf_program * xdp_prog ,
287262 struct bpf_program * tc_prio_1_prog ,
288263 struct bpf_program * tc_prio_2_prog ,
289- struct bpf_map * result_map )
264+ bool * test_pass )
290265{
291266 LIBBPF_OPTS (bpf_tc_hook , tc_hook , .attach_point = BPF_TC_INGRESS );
292267 LIBBPF_OPTS (bpf_tc_opts , tc_opts , .handle = 1 , .priority = 1 );
@@ -295,8 +270,7 @@ static void test_tuntap(struct bpf_program *xdp_prog,
295270 int tap_ifindex ;
296271 int ret ;
297272
298- if (!clear_test_result (result_map ))
299- return ;
273+ * test_pass = false;
300274
301275 ns = netns_new (TAP_NETNS , true);
302276 if (!ASSERT_OK_PTR (ns , "create and open ns" ))
@@ -340,7 +314,7 @@ static void test_tuntap(struct bpf_program *xdp_prog,
340314 if (!ASSERT_OK (ret , "write_test_packet" ))
341315 goto close ;
342316
343- assert_test_result ( result_map );
317+ ASSERT_TRUE ( * test_pass , "test_pass" );
344318
345319close :
346320 if (tap_fd >= 0 )
@@ -431,37 +405,37 @@ void test_xdp_context_tuntap(void)
431405 test_tuntap (skel -> progs .ing_xdp ,
432406 skel -> progs .ing_cls ,
433407 NULL , /* tc prio 2 */
434- skel -> maps . test_result );
408+ & skel -> bss -> test_pass );
435409 if (test__start_subtest ("dynptr_read" ))
436410 test_tuntap (skel -> progs .ing_xdp ,
437411 skel -> progs .ing_cls_dynptr_read ,
438412 NULL , /* tc prio 2 */
439- skel -> maps . test_result );
413+ & skel -> bss -> test_pass );
440414 if (test__start_subtest ("dynptr_slice" ))
441415 test_tuntap (skel -> progs .ing_xdp ,
442416 skel -> progs .ing_cls_dynptr_slice ,
443417 NULL , /* tc prio 2 */
444- skel -> maps . test_result );
418+ & skel -> bss -> test_pass );
445419 if (test__start_subtest ("dynptr_write" ))
446420 test_tuntap (skel -> progs .ing_xdp_zalloc_meta ,
447421 skel -> progs .ing_cls_dynptr_write ,
448422 skel -> progs .ing_cls_dynptr_read ,
449- skel -> maps . test_result );
423+ & skel -> bss -> test_pass );
450424 if (test__start_subtest ("dynptr_slice_rdwr" ))
451425 test_tuntap (skel -> progs .ing_xdp_zalloc_meta ,
452426 skel -> progs .ing_cls_dynptr_slice_rdwr ,
453427 skel -> progs .ing_cls_dynptr_slice ,
454- skel -> maps . test_result );
428+ & skel -> bss -> test_pass );
455429 if (test__start_subtest ("dynptr_offset" ))
456430 test_tuntap (skel -> progs .ing_xdp_zalloc_meta ,
457431 skel -> progs .ing_cls_dynptr_offset_wr ,
458432 skel -> progs .ing_cls_dynptr_offset_rd ,
459- skel -> maps . test_result );
433+ & skel -> bss -> test_pass );
460434 if (test__start_subtest ("dynptr_offset_oob" ))
461435 test_tuntap (skel -> progs .ing_xdp ,
462436 skel -> progs .ing_cls_dynptr_offset_oob ,
463437 skel -> progs .ing_cls ,
464- skel -> maps . test_result );
438+ & skel -> bss -> test_pass );
465439 if (test__start_subtest ("clone_data_meta_empty_on_data_write" ))
466440 test_tuntap_mirred (skel -> progs .ing_xdp ,
467441 skel -> progs .clone_data_meta_empty_on_data_write ,
0 commit comments