File: tap-test

package info (click to toggle)
git-evtag 2022.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 380 kB
  • sloc: ansic: 841; sh: 389; python: 86; makefile: 48; xml: 48
file content (41 lines) | stat: -rwxr-xr-x 948 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /bin/bash
#
# Run a test in tap mode, ensuring we have a temporary directory.  We
# always use /var/tmp becuase we might want to use user xattrs, which
# aren't available on tmpfs.
#
# The test binary is passed as $1

set -eu

srcd="$(cd "$(dirname "$1")" && pwd)"
bn="$(basename "$1")"
TEST_TMPDIR="${TEST_TMPDIR:-/var/tmp}"
tempdir="$(mktemp -d "$TEST_TMPDIR/tap-test.XXXXXX")"
touch "${tempdir}/.testtmp"
function cleanup () {
    if test -f "${tempdir}/.testtmp"; then
        rm "${tempdir}" -rf
    fi
}
function skip_cleanup() {
    echo "Skipping cleanup of ${tempdir}"
}
cd "${tempdir}"
rc=0
timeout \
    --kill-after=60 \
    --signal=ABRT \
    $(( 600 * ${TEST_TIMEOUT_FACTOR:-1} )) \
    "${srcd}/${bn}" -k --tap || rc=$?
case "${TEST_SKIP_CLEANUP:-}" in
    no|"") cleanup ;;
    err)
        if test "$rc" != 0; then
            skip_cleanup
        else
            cleanup
        fi ;;
    *) skip_cleanup  ;;
esac
exit "$rc"