ksft_runner.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. source "$(dirname $(realpath $0))/../../kselftest/ktap_helpers.sh"
  4. readonly ipv4_args=('--ip_version=ipv4 '
  5. '--local_ip=192.168.0.1 '
  6. '--gateway_ip=192.168.0.1 '
  7. '--netmask_ip=255.255.0.0 '
  8. '--remote_ip=192.0.2.1 '
  9. '-D CMSG_LEVEL_IP=SOL_IP '
  10. '-D CMSG_TYPE_RECVERR=IP_RECVERR ')
  11. readonly ipv6_args=('--ip_version=ipv6 '
  12. '--mtu=1520 '
  13. '--local_ip=fd3d:0a0b:17d6::1 '
  14. '--gateway_ip=fd3d:0a0b:17d6:8888::1 '
  15. '--remote_ip=fd3d:fa7b:d17d::1 '
  16. '-D CMSG_LEVEL_IP=SOL_IPV6 '
  17. '-D CMSG_TYPE_RECVERR=IPV6_RECVERR ')
  18. if [ $# -ne 1 ]; then
  19. ktap_exit_fail_msg "usage: $0 <script>"
  20. exit "$KSFT_FAIL"
  21. fi
  22. script="$1"
  23. if [ -z "$(which packetdrill)" ]; then
  24. ktap_skip_all "packetdrill not found in PATH"
  25. exit "$KSFT_SKIP"
  26. fi
  27. declare -a optargs
  28. if [[ -n "${KSFT_MACHINE_SLOW}" ]]; then
  29. optargs+=('--tolerance_usecs=14000')
  30. fi
  31. ktap_print_header
  32. ktap_set_plan 2
  33. unshare -n packetdrill ${ipv4_args[@]} ${optargs[@]} $(basename $script) > /dev/null \
  34. && ktap_test_pass "ipv4" || ktap_test_fail "ipv4"
  35. unshare -n packetdrill ${ipv6_args[@]} ${optargs[@]} $(basename $script) > /dev/null \
  36. && ktap_test_pass "ipv6" || ktap_test_fail "ipv6"
  37. ktap_finished