summaryrefslogtreecommitdiff
path: root/run/tests
blob: 5f356add3dfd77f7d0bc267685924ffe68453240 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
#
# e.g. --run_tests=foo
set -e

PRIVATE_GIT="881c48805e352dfe150993814757ca974282be18"

type=""
check=0
while [[ $# -gt 0 ]]; do
    case $1 in
        -e)
        environment=$2
        shift
        shift
        ;;
        --debug)
        type="debug"
        shift
        ;;
        --backtrace)
        type="backtrace"
        shift
        ;;
        --valgrind)
        type="valgrind"
        shift
        ;;
        --callgrind)
        type="callgrind"
        shift
        ;;
        --quiet)
        type="quiet"
        shift
        ;;
        --drd)
        type="drd"
        shift
        ;;
        --helgrind)
        type="helgrind"
        shift
        ;;
        --check)
        check=1
        shift
        ;;
        *)
        break
        ;;
    esac
done

if [ "$(uname)" == "Linux" ]; then 
  export LD_LIBRARY_PATH=build/src/lib:../../lib:/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH
  rm -f build/test/dcpomatic2_openssl
  # This must be our patched openssl or tests will fail
  if [ ! -f build/test/dcpomatic2_openssl ]; then 
    ln -s ../../../openssl/apps/openssl build/test/dcpomatic2_openssl
  fi
  export DCPOMATIC_TEST_TOOLS_PATH=/opt/asdcplib/bin
  if [ -f /src/backports/dcp_inspect ]; then
    export DCPOMATIC_DCP_INSPECT=/src/backports/dcp_inspect
  fi
  set +e
  python3 -m clairmeta.cli --help > /dev/null 2>&1
  if [ "$?" == "0" ]; then
    export DCPOMATIC_CLAIRMETA=1
  fi
  set -e
fi

if [ "$(uname)" == "Darwin" ]; then
  resources=build/Resources
  rm -rf $resources
  mkdir -p $resources
  cp fonts/*.ttf $resources
  cp -r ../libdcp/tags $resources
  cp -r ../libdcp/xsd $resources
  cp ../libdcp/ratings $resources
  rm -f build/test/openssl
  ln -s ../../../openssl/apps/openssl build/test/openssl
  # SIP stops this being passed in from the caller's environment
  export DYLD_LIBRARY_PATH=$environment/x86_64/10.10/lib:$HOME/workspace/lib
  # We need to find ffcmp in here
  export PATH=$PATH:$HOME/workspace/bin
fi

if [ "$check" == "1" ]; then
	if [ "$DCPOMATIC_TEST_PRIVATE" == "" ]; then
		pushd ../dcpomatic-test-private
	else
		pushd $DCPOMATIC_TEST_PRIVATE
	fi
	current=$(git rev-parse HEAD)
	if [ "$current" != "$PRIVATE_GIT" ]; then
		echo "Unexpected dcpomatic-test-private version"
		exit 1
	fi
	popd
fi

if [ "$type" == "debug" ]; then
    gdb --args build/test/unit-tests --catch_system_errors=no --log_level=test_suite $*
elif [ "$type" == "backtrace" ]; then
    gdb -batch -ex "run" -ex "thread apply all bt" -return-child-result --args build/test/unit-tests --catch_system_errors=yes $*
elif [ "$type" == "valgrind" ]; then
#    valgrind --tool="memcheck" --vgdb=yes --vgdb-error=0 build/test/unit-tests $*
    valgrind --tool="memcheck" --suppressions=suppressions build/test/unit-tests $*
elif [ "$type" == "callgrind" ]; then
    valgrind --tool="callgrind" build/test/unit-tests $*
elif [ "$type" == "quiet" ]; then
    build/test/unit-tests --catch_system_errors=no $*
elif [ "$type" == "drd" ]; then
    valgrind --tool="drd" build/test/unit-tests $*
elif [ "$type" == "helgrind" ]; then
    valgrind --tool="helgrind" build/test/unit-tests $*
else
    ulimit -c unlimited
    build/test/unit-tests --catch_system_errors=no $*
fi