test_libbpf.sh 851 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. export TESTNAME=test_libbpf
  4. # Determine selftest success via shell exit code
  5. exit_handler()
  6. {
  7. if [ $? -eq 0 ]; then
  8. echo "selftests: $TESTNAME [PASS]";
  9. else
  10. echo "$TESTNAME: failed at file $LAST_LOADED" 1>&2
  11. echo "selftests: $TESTNAME [FAILED]";
  12. fi
  13. }
  14. libbpf_open_file()
  15. {
  16. LAST_LOADED=$1
  17. if [ -n "$VERBOSE" ]; then
  18. ./test_libbpf_open $1
  19. else
  20. ./test_libbpf_open --quiet $1
  21. fi
  22. }
  23. # Exit script immediately (well catched by trap handler) if any
  24. # program/thing exits with a non-zero status.
  25. set -e
  26. # (Use 'trap -l' to list meaning of numbers)
  27. trap exit_handler 0 2 3 6 9
  28. libbpf_open_file test_l4lb.o
  29. # Load a program with BPF-to-BPF calls
  30. libbpf_open_file test_l4lb_noinline.o
  31. # Load a program compiled without the "-target bpf" flag
  32. libbpf_open_file test_xdp.o
  33. # Success
  34. exit 0