7 type ping${1} >/dev/null 2>&1 && PING="ping${1}" || PING="ping -${1}"
8 $PING -q -c 1 -W 1 ${2%%/*} >/dev/null 2>&1
14 echo -n "Wait
for testing IPv
4/IPv6 to become available
"
15 for _i in $(seq ${MAX_PING_TRIES}); do
17 if ping_once 4 ${TEST_IPv4} && ping_once 6 ${TEST_IPv6}; then
22 echo 1>&2 "ERROR
: Timeout waiting
for test IP to become available.
"
28 # Create testing interfaces not to interfere with current environment.
29 ip link add dev ${TEST_IF} type veth peer name ${TEST_IF_PEER}
30 ip link set ${TEST_IF} up
31 ip link set ${TEST_IF_PEER} up
33 ip -4 addr add ${TEST_IPv4} dev ${TEST_IF}
34 ip -6 addr add ${TEST_IPv6} dev ${TEST_IF}
40 ip link del ${TEST_IF} 2>/dev/null || :
41 ip link del ${TEST_IF_PEER} 2>/dev/null || :
46 trap cleanup EXIT 2 3 6 15
48 ./test_sock_addr setup_done
51 BASENAME=$(basename $0 .sh)
52 TEST_IF="${BASENAME}1"
53 TEST_IF_PEER="${BASENAME}2"
54 TEST_IPv4="127.0.0.4/8"