282d923bbe21dc069cf205229a1fca166f5840c4
[dcpomatic.git] / run / tests
1 #!/bin/bash
2 #
3 # e.g. --run_tests=foo
4 set -e
5
6 PRIVATE_GIT="0af96c8d8f28e71b8b1a19e3ea5637fcba5e913e"
7
8 if [ "$1" == "--check" ]; then
9         shift 1
10         check=1
11 else
12         check=0
13 fi
14
15 if [ "$(uname)" == "Linux" ]; then 
16   export LD_LIBRARY_PATH=build/src/lib:/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH
17   rm -f build/test/dcpomatic2_openssl
18   # This must be our patched openssl or tests will fail
19   if [ ! -f build/test/dcpomatic2_openssl ]; then 
20     ln -s ../../../openssl/apps/openssl build/test/dcpomatic2_openssl
21   fi
22 fi
23
24 if [ "$(uname)" == "Darwin" ]; then
25   resources=build/Resources
26   rm -rf $resources
27   mkdir -p $resources
28   cp fonts/*.ttf $resources
29   cp -r ../libdcp/tags $resources
30   cp -r ../libdcp/xsd $resources
31   cp ../libdcp/ratings $resources
32   rm -f build/test/openssl
33   ln -s ../../../openssl/apps/openssl build/test/openssl
34   # SIP stops this being passed in from the caller's environment
35   export DYLD_LIBRARY_PATH=/Users/ci/osx-environment/x86_64/10.10/lib:/Users/ci/workspace/lib
36   # We need to find ffcmp in here
37   export PATH=$PATH:/Users/ci/workspace/bin
38 fi
39
40 if [ "$check" == "1" ]; then
41         if [ "$DCPOMATIC_TEST_PRIVATE" == "" ]; then
42                 pushd ../dcpomatic-test-private
43         else
44                 pushd $DCPOMATIC_TEST_PRIVATE
45         fi
46         current=$(git rev-parse HEAD)
47         if [ "$current" != "$PRIVATE_GIT" ]; then
48                 echo "Unexpected dcpomatic-test-private version"
49                 exit 1
50         fi
51         ./check_sums || (echo "dcpomatic-test-private checksums are incorrect"; exit 1)
52         popd
53 fi
54
55 if [ "$1" == "--debug" ]; then
56     shift;
57     gdb --args build/test/unit-tests --catch_system_errors=no --log_level=test_suite $*
58 elif [ "$1" == "--backtrace" ]; then
59     shift;
60     gdb -batch -ex "run" -ex "thread apply all bt" -return-child-result --args build/test/unit-tests --catch_system_errors=yes $*
61 elif [ "$1" == "--valgrind" ]; then
62     shift;
63 #    valgrind --tool="memcheck" --vgdb=yes --vgdb-error=0 build/test/unit-tests $*
64     valgrind --tool="memcheck" --suppressions=suppressions build/test/unit-tests $*
65 elif [ "$1" == "--callgrind" ]; then
66     shift;
67     valgrind --tool="callgrind" build/test/unit-tests $*
68 elif [ "$1" == "--quiet" ]; then
69     shift;
70     build/test/unit-tests --catch_system_errors=no $*
71 elif [ "$1" == "--drd" ]; then
72     shift;
73     valgrind --tool="drd" build/test/unit-tests $*
74 elif [ "$1" == "--helgrind" ]; then
75     shift;
76     valgrind --tool="helgrind" build/test/unit-tests $*
77 else
78     ulimit -c unlimited
79     build/test/unit-tests --catch_system_errors=no $*
80 fi