File: test-wrapper

package info (click to toggle)
pkcs11-provider 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,084 kB
  • sloc: ansic: 30,447; sh: 3,354; python: 104; makefile: 58
file content (45 lines) | stat: -rwxr-xr-x 1,206 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash -e
# Copyright (C) 2022 Simo sorce <simo@redhat.com>
# SPDX-License-Identifier: Apache-2.0

DNAME=$(dirname "${1}")
BNAME=$(basename "${1}")

: "${TEST_PATH=$DNAME}"
: "${TESTBLDDIR=.}"

# the test name is {TEST_NAME}-{TOKEN_DRIVER}.t
# split extension
NAME=${BNAME%.*}
TEST_NAME=${NAME%-*}
export TOKEN_DRIVER=${NAME#*-}

if [ -f "${TESTBLDDIR}/${TOKEN_DRIVER}/testvars" ]; then
    # shellcheck source=/dev/null # we do not care about linting this source
    source "${TESTBLDDIR}/${TOKEN_DRIVER}/testvars"
else
    exit 77 # token not configured, skip
fi

# some tests are compiled, others are just distributed scripts
# so we need to check both the current tests build dir and the
# source tests dir in the out-of-source build case (used by
# make distcheck for example)
if [ -f "${TEST_PATH}/t${TEST_NAME}" ]; then
    COMMAND="${TEST_PATH}/t${TEST_NAME}"
else
    COMMAND="${TESTBLDDIR}/t${TEST_NAME}"
fi

# for compiled tests, we need to add valgrind/checker
if [ -f "${TEST_PATH}/t${TEST_NAME}.c" ]; then
    COMMAND="$CHECKER $COMMAND"
fi

LOGFILE="${TESTBLDDIR}/${TEST_NAME}.${TOKEN_DRIVER}.log"

echo "Executing ${COMMAND}"
(
  set -o pipefail
  ${COMMAND} 2>&1 | tee "${LOGFILE}"
)