]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: C based test for sysctl and strtoX
authorAndrey Ignatov <rdna@fb.com>
Sat, 23 Mar 2019 22:51:00 +0000 (15:51 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 12 Apr 2019 20:54:59 +0000 (13:54 -0700)
commit00f8a3e9ebf0f1bb41c5e92ce4a76c29fdf33392
tree6fd06f468a87e79e8c203969d90318b862159649
parenta95440d571c552d8f8b4730bc93d5c2a71f212cb
selftests/bpf: C based test for sysctl and strtoX

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: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/test_sysctl_prog.c [new file with mode: 0644]
tools/testing/selftests/bpf/test_sysctl.c