• Andrii Nakryiko's avatar
    selftests/bpf: add ability to filter programs in veristat · bde4a96c
    Andrii Nakryiko authored
    Add -f (--filter) argument which accepts glob-based filters for
    narrowing down what BPF object files and programs within them should be
    processed by veristat. This filtering applies both to comparison and
    main (verification) mode.
    
    Filter can be of two forms:
      - file (object) filter: 'strobemeta*'; in this case all the programs
        within matching files are implicitly allowed (or denied, depending
        if it's positive or negative rule, see below);
      - file and prog filter: 'strobemeta*/*unroll*' will further filter
        programs within matching files to only allow those program names that
        match '*unroll*' glob.
    
    As mentioned, filters can be positive (allowlisting) and negative
    (denylisting). Negative filters should start with '!': '!strobemeta*'
    will deny any filename which basename starts with "strobemeta".
    
    Further, one extra special syntax is supported to allow more convenient
    use in practice. Instead of specifying rule on the command line,
    veristat allows to specify file that contains rules, both positive and
    negative, one line per one filter. This is achieved with -f @<filepath>
    use, where <filepath> points to a text file containing rules (negative
    and positive rules can be mixed). For convenience empty lines and lines
    starting with '#' are ignored. This feature is useful to have some
    pre-canned list of object files and program names that are tested
    repeatedly, allowing to check in a list of rules and quickly specify
    them on the command line.
    
    As a demonstration (and a short cut for nearest future), create a small
    list of "interesting" BPF object files from selftests/bpf and commit it
    as veristat.cfg. It currently includes 73 programs, most of which are
    the most complex and largest BPF programs in selftests, as judged by
    total verified instruction count and verifier states total.
    
    If there is overlap between positive or negative filters, negative
    filter takes precedence (denylisting is stronger than allowlisting). If
    no allow filter is specified, veristat implicitly assumes '*/*' rule. If
    no deny rule is specified, veristat (logically) assumes no negative
    filters.
    
    Also note that -f (just like -e and -s) can be specified multiple times
    and their effect is cumulative.
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/r/20220921164254.3630690-5-andrii@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    bde4a96c
veristat.c 29.6 KB