File: timeout

package info (click to toggle)
auto-apt-proxy 13.3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 156 kB
  • sloc: sh: 189; makefile: 13
file content (23 lines) | stat: -rwxr-xr-x 539 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
22
23
#!/bin/sh

set -eu

cd ${AUTOPKGTEST_TMP:-${TMPDIR:-/tmp}}

# Run a fake proxy on localhost:9999 that takes 1h to respond to simulate an
# approx proxy that is behind some port filtering and takes forever to respond.
cat > config.ru <<PROXY
class TimeoutProxy
  def call(env)
    sleep(60*60)
  end
end
run TimeoutProxy.new
PROXY
rackup --daemonize --pid proxy.pid --port 9999
trap 'kill -9 $(cat proxy.pid)' INT TERM EXIT

set -x

# auto-apt-proxy should timeout and exit 0 in less than 10 seconds
timeout --signal=KILL 10 auto-apt-proxy