CI: Install and use OpenSSL 1.1 on CentOS 7.
[tinc] / .github / workflows / test / run.sh
1 #!/bin/sh
2
3 set -eu
4
5 bail() {
6   echo >&2 "@"
7   exit 1
8 }
9
10 header() {
11   echo '################################################################################'
12   echo "# $*"
13   echo '################################################################################'
14 }
15
16 run_tests() {
17   flavor="$1"
18   shift
19
20   header "Cleaning up leftovers from previous runs"
21
22   for name in tinc tincd; do
23     pkill -TERM -x "$name" || true
24     pkill -KILL -x "$name" || true
25   done
26
27   git clean -dfx
28
29   header "Running test flavor $flavor"
30
31   # CentOS 7 has OpenSSL 1.1 installed in a non-default location.
32   if test -d /usr/include/openssl11; then
33     set -- "$@" --with-openssl-include=/usr/include/openssl11
34   fi
35
36   if test -d /usr/lib64/openssl11; then
37     set -- "$@" --with-openssl-lib=/usr/lib64/openssl11
38   fi
39
40   autoreconf -fsi
41   ./configure "$@"
42   make -j"$(nproc)"
43
44   code=0
45   make check -j2 VERBOSE=1 || code=$?
46
47   tar -c -z -f "/tmp/tests.$flavor.tar.gz" test/
48
49   return $code
50 }
51
52 # GitHub Checkout action supports git 2.18+.
53 # If we're running in a container with an older version,
54 # create our own local repository to make `git clean` work.
55 if ! [ -e .git ]; then
56   git init
57   git add .
58 fi
59
60 case "$1" in
61 default)
62   run_tests default ''
63   ;;
64 nolegacy)
65   run_tests nolegacy --disable-legacy-protocol
66   ;;
67 *)
68   bail "unknown test flavor $1"
69   ;;
70 esac