Skip to content
Snippets Groups Projects
  1. Nov 18, 2021
  2. Aug 25, 2020
  3. Jul 08, 2020
  4. Jul 02, 2020
    • Martin KaFai Lau's avatar
      bpf: selftests: Restore netns after each test · 811d7e37
      Martin KaFai Lau authored
      
      It is common for networking tests creating its netns and making its own
      setting under this new netns (e.g. changing tcp sysctl).  If the test
      forgot to restore to the original netns, it would affect the
      result of other tests.
      
      This patch saves the original netns at the beginning and then restores it
      after every test.  Since the restore "setns()" is not expensive, it does it
      on all tests without tracking if a test has created a new netns or not.
      
      The new restore_netns() could also be done in test__end_subtest() such
      that each subtest will get an automatic netns reset.  However,
      the individual test would lose flexibility to have total control
      on netns for its own subtests.  In some cases, forcing a test to do
      unnecessary netns re-configure for each subtest is time consuming.
      e.g. In my vm, forcing netns re-configure on each subtest in sk_assign.c
      increased the runtime from 1s to 8s.  On top of that,  test_progs.c
      is also doing per-test (instead of per-subtest) cleanup for cgroup.
      Thus, this patch also does per-test restore_netns().  The only existing
      per-subtest cleanup is reset_affinity() and no test is depending on this.
      Thus, it is removed from test__end_subtest() to give a consistent
      expectation to the individual tests.  test_progs.c only ensures
      any affinity/netns/cgroup change made by an earlier test does not
      affect the following tests.
      
      Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Link: https://lore.kernel.org/bpf/20200702004858.2103728-1-kafai@fb.com
      811d7e37
  5. Jul 01, 2020
  6. May 13, 2020
  7. May 08, 2020
  8. Apr 29, 2020
  9. Mar 17, 2020
  10. Mar 13, 2020
  11. Feb 25, 2020
    • Andrii Nakryiko's avatar
      selftests/bpf: Print backtrace on SIGSEGV in test_progs · 9fb156bb
      Andrii Nakryiko authored
      
      Due to various bugs in tests clean up code (usually), if host system is
      misconfigured, it happens that test_progs will just crash in the middle of
      running a test with little to no indication of where and why the crash
      happened. For cases where coredump is not readily available (e.g., inside
      a CI), it's very helpful to have a stack trace, which lead to crash, to be
      printed out. This change adds a signal handler that will capture and print out
      symbolized backtrace:
      
        $ sudo ./test_progs -t mmap
        test_mmap:PASS:skel_open_and_load 0 nsec
        test_mmap:PASS:bss_mmap 0 nsec
        test_mmap:PASS:data_mmap 0 nsec
        Caught signal #11!
        Stack trace:
        ./test_progs(crash_handler+0x18)[0x42a888]
        /lib64/libpthread.so.0(+0xf5d0)[0x7f2aab5175d0]
        ./test_progs(test_mmap+0x3c0)[0x41f0a0]
        ./test_progs(main+0x160)[0x407d10]
        /lib64/libc.so.6(__libc_start_main+0xf5)[0x7f2aab15d3d5]
        ./test_progs[0x407ebc]
        [1]    1988412 segmentation fault (core dumped)  sudo ./test_progs -t mmap
      
      Unfortunately, glibc's symbolization support is unable to symbolize static
      functions, only global ones will be present in stack trace. But it's still a
      step forward without adding extra libraries to get a better symbolization.
      
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20200225000847.3965188-1-andriin@fb.com
      9fb156bb
  12. Jan 16, 2020
    • Andrii Nakryiko's avatar
      selftests/bpf: Add whitelist/blacklist of test names to test_progs · b65053cd
      Andrii Nakryiko authored
      
      Add ability to specify a list of test name substrings for selecting which
      tests to run. So now -t is accepting a comma-separated list of strings,
      similarly to how -n accepts a comma-separated list of test numbers.
      
      Additionally, add ability to blacklist tests by name. Blacklist takes
      precedence over whitelist. Blacklisting is important for cases where it's
      known that some tests can't pass (e.g., due to perf hardware events that are
      not available within VM). This is going to be used for libbpf testing in
      Travis CI in its Github repo.
      
      Example runs with just whitelist and whitelist + blacklist:
      
        $ sudo ./test_progs -tattach,core/existence
        #1 attach_probe:OK
        #6 cgroup_attach_autodetach:OK
        #7 cgroup_attach_multi:OK
        #8 cgroup_attach_override:OK
        #9 core_extern:OK
        #10/44 existence:OK
        #10/45 existence___minimal:OK
        #10/46 existence__err_int_sz:OK
        #10/47 existence__err_int_type:OK
        #10/48 existence__err_int_kind:OK
        #10/49 existence__err_arr_kind:OK
        #10/50 existence__err_arr_value_type:OK
        #10/51 existence__err_struct_type:OK
        #10 core_reloc:OK
        #19 flow_dissector_reattach:OK
        #60 tp_attach_query:OK
        Summary: 8/8 PASSED, 0 SKIPPED, 0 FAILED
      
        $ sudo ./test_progs -tattach,core/existence -bcgroup,flow/arr
        #1 attach_probe:OK
        #9 core_extern:OK
        #10/44 existence:OK
        #10/45 existence___minimal:OK
        #10/46 existence__err_int_sz:OK
        #10/47 existence__err_int_type:OK
        #10/48 existence__err_int_kind:OK
        #10/51 existence__err_struct_type:OK
        #10 core_reloc:OK
        #60 tp_attach_query:OK
        Summary: 4/6 PASSED, 0 SKIPPED, 0 FAILED
      
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Cc: Julia Kartseva <hex@fb.com>
      Link: https://lore.kernel.org/bpf/20200116005549.3644118-1-andriin@fb.com
      b65053cd
  13. Nov 25, 2019
  14. Oct 21, 2019
  15. Oct 17, 2019
    • Andrii Nakryiko's avatar
      selftests/bpf: Teach test_progs to cd into subdir · 0b6e71c3
      Andrii Nakryiko authored
      
      We are building a bunch of "flavors" of test_progs, e.g., w/ alu32 flag
      for Clang when building BPF object. test_progs setup is relying on
      having all the BPF object files and extra resources to be available in
      current working directory, though. But we actually build all these files
      into a separate sub-directory. Next set of patches establishes
      convention of naming "flavored" test_progs (and test runner binaries in
      general) as test_progs-flavor (e.g., test_progs-alu32), for each such
      extra flavor. This patch teaches test_progs binary to automatically
      detect its own extra flavor based on its argv[0], and if present, to
      change current directory to a flavor-specific subdirectory.
      
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20191016060051.2024182-2-andriin@fb.com
      0b6e71c3
  16. Sep 06, 2019
  17. Sep 03, 2019
    • Stanislav Fomichev's avatar
      selftests/bpf: test_progs: fix verbose mode garbage · d80507d1
      Stanislav Fomichev authored
      
      fseeko(.., 0, SEEK_SET) on a memstream just puts the buffer pointer
      to the beginning so when we call fflush on it we get some garbage
      log data from the previous test. Let's manually set terminating
      byte to zero at the reported buffer size.
      
      To show the issue consider the following snippet:
      
      	stream = open_memstream (&buf, &len);
      
      	fprintf(stream, "aaa");
      	fflush(stream);
      	printf("buf=%s, len=%zu\n", buf, len);
      	fseeko(stream, 0, SEEK_SET);
      
      	fprintf(stream, "b");
      	fflush(stream);
      	printf("buf=%s, len=%zu\n", buf, len);
      
      Output:
      
      	buf=aaa, len=3
      	buf=baa, len=1
      
      Fixes: 946152b3 ("selftests/bpf: test_progs: switch to open_memstream")
      Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      d80507d1
  18. Aug 27, 2019
  19. Aug 07, 2019
  20. Jul 31, 2019
  21. Jul 28, 2019
  22. May 30, 2019
  23. Apr 03, 2019
    • Alexei Starovoitov's avatar
      selftests/bpf: add few verifier scale tests · e5e7a8f2
      Alexei Starovoitov authored
      
      Add 3 basic tests that stress verifier scalability.
      
      test_verif_scale1.c calls non-inlined jhash() function 90 times on
      different position in the packet.
      This test simulates network packet parsing.
      jhash function is ~140 instructions and main program is ~1200 insns.
      
      test_verif_scale2.c force inlines jhash() function 90 times.
      This program is ~15k instructions long.
      
      test_verif_scale3.c calls non-inlined jhash() function 90 times on
      But this time jhash has to process 32-bytes from the packet
      instead of 14-bytes in tests 1 and 2.
      jhash function is ~230 insns and main program is ~1200 insns.
      
      $ test_progs -s
      can be used to see verifier stats.
      
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      e5e7a8f2
  24. Mar 02, 2019
Loading