Improve save-template dialog and always use a default template.
[dcpomatic.git] / run / tests
1 #!/bin/bash
2 #
3 # e.g. --run_tests=foo
4 set -e
5
6 PRIVATE_GIT="881c48805e352dfe150993814757ca974282be18"
7
8 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
9 source $DIR/environment
10
11 type=""
12 check=0
13 while [[ $# -gt 0 ]]; do
14     case $1 in
15         -e)
16         environment=$2
17         shift
18         shift
19         ;;
20         --debug)
21         type="debug"
22         shift
23         ;;
24         --backtrace)
25         type="backtrace"
26         shift
27         ;;
28         --valgrind)
29         type="valgrind"
30         shift
31         ;;
32         --callgrind)
33         type="callgrind"
34         shift
35         ;;
36         --quiet)
37         type="quiet"
38         shift
39         ;;
40         --drd)
41         type="drd"
42         shift
43         ;;
44         --helgrind)
45         type="helgrind"
46         shift
47         ;;
48         --check)
49         check=1
50         shift
51         ;;
52         *)
53         break
54         ;;
55     esac
56 done
57
58 if [ "$(uname)" == "Linux" ]; then 
59     rm -f build/test/dcpomatic2_openssl
60     mkdir -p build/test
61     # This must be our patched openssl or tests will fail
62     if [ ! -f build/test/dcpomatic2_openssl ]; then
63         ln -s ../../../openssl/apps/openssl build/test/dcpomatic2_openssl
64     fi
65     export DCPOMATIC_TEST_TOOLS_PATH=/opt/asdcplib/bin
66     if [ -f /src/backports/dcp_inspect ]; then
67         export DCPOMATIC_DCP_INSPECT=/src/backports/dcp_inspect
68     fi
69     set +e
70     python3 -m clairmeta.cli --help > /dev/null 2>&1
71     if [ "$?" == "0" ]; then
72         export DCPOMATIC_CLAIRMETA=1
73     fi
74     set -e
75 fi
76
77 if [ "$(uname)" == "Darwin" ]; then
78     resources=build/Resources
79     rm -rf $resources
80     mkdir -p $resources
81     cp fonts/*.ttf $resources
82     cp -r ../libdcp/tags $resources
83     cp -r ../libdcp/xsd $resources
84     cp ../libdcp/ratings $resources
85     rm -f build/test/openssl
86     ln -s ../../../openssl/apps/openssl build/test/openssl
87     # We need to find ffcmp in here
88     export PATH=$PATH:/Users/ci/workspace/bin
89     export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$environment/x86_64/10.10/lib
90 fi
91
92 if [ "$check" == "1" ]; then
93     if [ "$DCPOMATIC_TEST_PRIVATE" == "" ]; then
94         pushd ../dcpomatic-test-private
95     else
96         pushd $DCPOMATIC_TEST_PRIVATE
97     fi
98     current=$(git rev-parse HEAD)
99     if [ "$current" != "$PRIVATE_GIT" ]; then
100         echo "Unexpected dcpomatic-test-private version"
101         exit 1
102     fi
103     popd
104 fi
105
106 if [ "$type" == "debug" ]; then
107     gdb --args build/test/unit-tests --catch_system_errors=no --log_level=test_suite $*
108 elif [ "$type" == "backtrace" ]; then
109     gdb -batch -ex "run" -ex "thread apply all bt" -return-child-result --args build/test/unit-tests --catch_system_errors=yes $*
110 elif [ "$type" == "valgrind" ]; then
111 #    valgrind --tool="memcheck" --vgdb=yes --vgdb-error=0 build/test/unit-tests $*
112     valgrind --tool="memcheck" --suppressions=suppressions build/test/unit-tests $*
113 elif [ "$type" == "callgrind" ]; then
114     valgrind --tool="callgrind" build/test/unit-tests $*
115 elif [ "$type" == "quiet" ]; then
116     build/test/unit-tests --catch_system_errors=no $*
117 elif [ "$type" == "drd" ]; then
118     valgrind --tool="drd" build/test/unit-tests $*
119 elif [ "$type" == "helgrind" ]; then
120     valgrind --tool="helgrind" build/test/unit-tests $*
121 else
122     ulimit -c unlimited
123     build/test/unit-tests --catch_system_errors=no $*
124 fi