@cryptotaxi247 / kubo / commits / f59751d1a

test: remove time-out script, use go-timeout instead

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Aug 31, 2016 at 19:52 UTC f59751d1a2bec79240a630c0bf13be5d5a4431c2
3 files changed +5 -89
test/bin/.gitignore
-1
@@ -8,4 +8,3 @@
8 !checkflags
9 !continueyn
10 !verify-go-fmt.sh
11 -!time-out
test/bin/time-out deleted
-83
@@ -1,83 +0,0 @@
1 -#!/bin/bash
2 -#
3 -# The Bash shell script executes a command with a time-out.
4 -# Upon time-out expiration SIGTERM (15) is sent to the process. If the signal
5 -# is blocked, then the subsequent SIGKILL (9) terminates it.
6 -#
7 -# Based on the Bash documentation example.
8 -
9 -scriptName="${0##*/}"
10 -
11 -declare -i DEFAULT_TIMEOUT=9
12 -declare -i DEFAULT_INTERVAL=1
13 -declare -i DEFAULT_DELAY=1
14 -
15 -# Timeout.
16 -declare -i timeout=DEFAULT_TIMEOUT
17 -# Interval between checks if the process is still alive.
18 -declare -i interval=DEFAULT_INTERVAL
19 -# Delay between posting the SIGTERM signal and destroying the process by SIGKILL.
20 -declare -i delay=DEFAULT_DELAY
21 -
22 -function printUsage() {
23 - cat <<EOF
24 -
25 -Synopsis
26 - $scriptName [-t timeout] [-i interval] [-d delay] command
27 - Execute a command with a time-out.
28 - Upon time-out expiration SIGTERM (15) is sent to the process. If SIGTERM
29 - signal is blocked, then the subsequent SIGKILL (9) terminates it.
30 -
31 - -t timeout
32 - Number of seconds to wait for command completion.
33 - Default value: $DEFAULT_TIMEOUT seconds.
34 -
35 - -i interval
36 - Interval between checks if the process is still alive.
37 - Positive integer, default value: $DEFAULT_INTERVAL seconds.
38 -
39 - -d delay
40 - Delay between posting the SIGTERM signal and destroying the
41 - process by SIGKILL. Default value: $DEFAULT_DELAY seconds.
42 -
43 -As of today, Bash does not support floating point arithmetic (sleep does),
44 -therefore all delay/time values must be integers.
45 -EOF
46 -}
47 -
48 -# Options.
49 -while getopts ":t:i:d:" option; do
50 - case "$option" in
51 - t) timeout=$OPTARG ;;
52 - i) interval=$OPTARG ;;
53 - d) delay=$OPTARG ;;
54 - *) printUsage; exit 1 ;;
55 - esac
56 -done
57 -shift $((OPTIND - 1))
58 -
59 -# $# should be at least 1 (the command to execute), however it may be strictly
60 -# greater than 1 if the command itself has options.
61 -if (($# == 0 || interval <= 0)); then
62 - printUsage
63 - exit 1
64 -fi
65 -
66 -# kill -0 pid Exit code indicates if a signal may be sent to $pid process.
67 -(
68 - ((t = timeout))
69 -
70 - while ((t > 0)); do
71 - sleep $interval
72 - kill -0 $$ || exit 0
73 - ((t -= interval))
74 - done
75 -
76 - # Be nice, post SIGTERM first.
77 - # The 'exit 0' below will be executed if any preceeding command fails.
78 - kill -s SIGTERM $$ && kill -0 $$ || exit 0
79 - sleep $delay
80 - kill -s SIGKILL $$
81 -) 2> /dev/null &
82 -
83 -exec "$@"
test/sharness/t0500-issues-and-regressions-offline.sh
+5 -5
@@ -8,17 +8,17 @@ test_description="Tests for various fixed issues and regressions."
8
9 test_expect_success "ipfs init with occupied input works - #2748" '
10 export IPFS_PATH="ipfs_path"
11 - echo "" | time-out ipfs init &&
11 + echo "" | go-timeout 10 ipfs init &&
12 rm -rf ipfs_path
13 '
14 test_init_ipfs
15
16 -test_expect_success "ipfs cat --help succeeds with no input" '
17 - time-out ipfs cat --help
16 +test_expect_success "ipfs cat --help succeeds when input remains open" '
17 + yes | go-timeout 1 ipfs cat --help
18 '
19
20 -test_expect_success "ipfs pin ls --help succeeds with no input" '
21 - time-out ipfs pin ls --help
20 +test_expect_success "ipfs pin ls --help succeeds when input remains open" '
21 + yes | go-timeout 1 ipfs pin ls --help
22 '
23
24 test_expect_success "ipfs add on 1MB from stdin woks" '