Debian Codegraph @

test/impass-test

raw
1 #!/usr/bin/env bash
2
3 # Run tests
4 #
5 # Copyright (c) 2005 Junio C Hamano
6 #
7 # Adapted from a Makefile to a shell script by Carl Worth (2010)
8
9 if [ ${BASH_VERSINFO[0]} -lt 4 ]; then
10 echo "Error: The impass test suite requires a bash version >= 4.0"
11 echo "due to use of associative arrays within the test suite."
12 echo "Please try again with a newer bash (or help us fix the"
13 echo "test suite to be more portable). Thanks."
14 exit 1
15 fi
16
17 cd $(dirname "$0")
18
19 TESTS="
20 basic
21 library
22 cli
23 "
24
25 # setup
26 TESTS=${IMPASS_TESTS:=$TESTS}
27
28 # test for timeout utility
29 if command -v timeout >/dev/null; then
30 TEST_TIMEOUT_CMD="timeout 1m "
31 echo "INFO: using 1 minute timeout for tests"
32 else
33 TEST_TIMEOUT_CMD=""
34 fi
35
36 # Prep
37 rm -rf test-results
38 mkdir -m 0700 -p ./gnupg
39 GNUPGHOME=./gnupg gpg --import < openpgp-data/secring.gpg
40 GNUPGHOME=./gnupg gpg --import-ownertrust < openpgp-data/ownertrust.txt
41
42 trap 'e=$?; kill $!; exit $e' HUP INT TERM
43 # Run the tests
44 for test in $TESTS; do
45 $TEST_TIMEOUT_CMD ./$test "$@" &
46 wait $!
47 done
48 trap - HUP INT TERM
49
50 # Report results
51 echo
52 ./lib/test-aggregate-results test-results/*
53 ev=$?
54
55 # Clean up
56 rm -rf test-results
57 rm -rf ./gnupg
58
59 exit $ev