File: run_test.sh

package info (click to toggle)
qtcontacts-sqlite 0.3.20-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,952 kB
  • sloc: cpp: 32,880; ansic: 1,269; xml: 62; makefile: 32; sh: 18
file content (39 lines) | stat: -rwxr-xr-x 1,018 bytes parent folder | download
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
#! /bin/sh

# Usage:
#   run_test.sh <TOP_BUILD_DIR> <TEST_PROGRAM>
#
# Run TEST_PROGRAM within a proper environment; this includes a D-Bus session
# and any environment variable needed for the succesful completion of the test.
#
# If the TEST_WRAPPER environment variable is set, then it will be executed and
# the test program will be passed as an argument to it; this can be useful, for
# example, to run the tests in valgrind or strace.

set -e

TOP_BUILD_DIR="$1"
TEST_PROGRAM="$2"

export LC_ALL=C
export QT_PLUGIN_PATH="${TOP_BUILD_DIR}/src/engine/"

OUTPUT=$(dbus-daemon --session --print-address '' --print-pid '' --fork)
export DBUS_SESSION_BUS_ADDRESS=$(echo "$OUTPUT" | head -1)
DBUS_DAEMON_PID=$(echo "$OUTPUT" | tail -1)

# Setup a temporary directory for the database file
export XDG_DATA_HOME="$(mktemp -d)"

cleanUp() {
    echo "Killing the temporary D-Bus daemon"
    kill "$DBUS_DAEMON_PID"
    rm -r "$XDG_DATA_HOME"
}

trap cleanUp EXIT INT TERM

$TEST_WRAPPER $TEST_PROGRAM

trap - EXIT
cleanUp