2019-03-01 19:42:19 -08:00
// SPDX-License-Identifier: GPL-2.0
# include <test_progs.h>
void test_reference_tracking ( void )
{
2019-10-04 15:40:37 -07:00
const char * file = " test_sk_lookup_kern.o " ;
const char * obj_name = " ref_track " ;
2019-10-22 10:21:00 -07:00
DECLARE_LIBBPF_OPTS ( bpf_object_open_opts , open_opts ,
2019-10-04 15:40:37 -07:00
. object_name = obj_name ,
. relaxed_maps = true ,
) ;
2019-03-01 19:42:19 -08:00
struct bpf_object * obj ;
struct bpf_program * prog ;
__u32 duration = 0 ;
int err = 0 ;
2019-10-04 15:40:37 -07:00
obj = bpf_object__open_file ( file , & open_opts ) ;
2019-08-21 16:44:25 -07:00
if ( CHECK_FAIL ( IS_ERR ( obj ) ) )
2019-03-01 19:42:19 -08:00
return ;
2019-10-04 15:40:37 -07:00
if ( CHECK ( strcmp ( bpf_object__name ( obj ) , obj_name ) , " obj_name " ,
" wrong obj name '%s', expected '%s' \n " ,
bpf_object__name ( obj ) , obj_name ) )
goto cleanup ;
2019-03-01 19:42:19 -08:00
bpf_object__for_each_program ( prog , obj ) {
const char * title ;
/* Ignore .text sections */
2020-09-03 13:35:37 -07:00
title = bpf_program__section_name ( prog ) ;
2019-03-01 19:42:19 -08:00
if ( strstr ( title , " .text " ) ! = NULL )
continue ;
2019-10-20 20:39:01 -07:00
if ( ! test__start_subtest ( title ) )
continue ;
2019-03-01 19:42:19 -08:00
/* Expect verifier failure if test name has 'fail' */
if ( strstr ( title , " fail " ) ! = NULL ) {
2019-07-27 20:25:27 -07:00
libbpf_print_fn_t old_print_fn ;
old_print_fn = libbpf_set_print ( NULL ) ;
2019-03-01 19:42:19 -08:00
err = ! bpf_program__load ( prog , " GPL " , 0 ) ;
2019-07-27 20:25:27 -07:00
libbpf_set_print ( old_print_fn ) ;
2019-03-01 19:42:19 -08:00
} else {
err = bpf_program__load ( prog , " GPL " , 0 ) ;
}
CHECK ( err , title , " \n " ) ;
}
2019-10-04 15:40:37 -07:00
cleanup :
2019-03-01 19:42:19 -08:00
bpf_object__close ( obj ) ;
}