• Andrey Ignatov's avatar
    selftests/bpf: C based test for sysctl and strtoX · 7568f4cb
    Andrey Ignatov authored
    Add C based test for a few bpf_sysctl_* helpers and bpf_strtoul.
    
    Make sure that sysctl can be identified by name and that multiple
    integers can be parsed from sysctl value with bpf_strtoul.
    
    net/ipv4/tcp_mem is chosen as a testing sysctl, it contains 3 unsigned
    longs, they all are parsed and compared (val[0] < val[1] < val[2]).
    
    Example of output:
      # ./test_sysctl
      ...
      Test case: C prog: deny all writes .. [PASS]
      Test case: C prog: deny access by name .. [PASS]
      Test case: C prog: read tcp_mem .. [PASS]
      Summary: 39 PASSED, 0 FAILED
    Signed-off-by: default avatarAndrey Ignatov <rdna@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    7568f4cb
test_sysctl.c 38.4 KB