File: ping-localhost

package info (click to toggle)
iputils 3%3A20240905-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,700 kB
  • sloc: ansic: 6,002; xml: 1,797; sh: 538; makefile: 28
file content (21 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

# test basic ping functionality with deadline and count options specified

set -e
start=$EPOCHSECONDS
# Specify a net.ipv4.ping_group_range that permits non-root users to
# create non-raw ICMP sockets.  See
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1008281 for
# context
sudo sysctl -w net.ipv4.ping_group_range="0 65534"
ping -q -w120 -c10 localhost
elapsed=$((EPOCHSECONDS-start))

if [ $elapsed -le 5 ]; then
cat <<EOF >&2
ping exited sooner than expected based on the provided command line, resulting in a failed test
(elapsed time: ${elapsed}s)
EOF
exit 1
fi