Fixes for writing 3D CPLs.
[libdcp.git] / run-tests.sh
1 #!/bin/bash -e
2
3 #
4 # Runs our test suite, which (amongst other things)
5 # builds a couple of DCPs.
6 # The outputs are compared against the ones
7 # in test/ref/DCP, and an error is given
8 # if anything is different.
9 #
10
11 if [ ! -e "../libdcp-test" ]; then
12   echo "Test corpus not found"
13   exit 1
14 fi
15
16 if [ "$1" == "--debug" ]; then
17   shift
18   LD_LIBRARY_PATH=build/src:build/asdcplib/src gdb --args build/test/tests
19 elif [ "$1" == "--valgrind" ]; then
20   shift
21   LD_LIBRARY_PATH=build/src:build/asdcplib/src valgrind --tool="memcheck" build/test/tests
22 else
23   LD_LIBRARY_PATH=build/src:build/asdcplib/src build/test/tests
24 fi
25
26 diff -ur test/ref/DCP/foo build/test/foo
27 if [ "$?" != "0" ]; then
28   echo "FAIL: files differ"
29   exit 1
30 fi
31
32 diff -ur test/ref/DCP/bar build/test/bar
33 if [ "$?" != "0" ]; then
34   echo "FAIL: files differ"
35   exit 1
36 fi
37
38 rm -f build/test/info.log
39
40 for d in `find ../libdcp-test -mindepth 1 -maxdepth 1 -type d | sort`; do
41   if [ `basename $d` != ".git" ]; then
42     LD_LIBRARY_PATH=build/src:build/asdcplib/src build/tools/dcpinfo -s $d >> build/test/info.log
43     if [ "$?" != "0" ]; then
44       echo "FAIL: dcpinfo failed for $d"
45       exit 1
46     fi
47   fi
48 done
49
50 diff -q build/test/info.log ../libdcp-test/info.log
51 if [ "$?" != "0" ]; then
52   echo "FAIL: dcpinfo output incorrect"
53   exit 1
54 fi
55
56 rm -f build/test/info2.log
57 rm -rf build/test/libdcp-test
58
59 cp -r ../libdcp-test build/test
60 for d in `find build/test/libdcp-test -mindepth 1 -maxdepth 1 -type d | sort`; do
61   if [ `basename $d` != ".git" ]; then
62     LD_LIBRARY_PATH=build/src:build/asdcplib/src build/test/rewrite_subs $d
63     LD_LIBRARY_PATH=build/src:build/asdcplib/src build/tools/dcpinfo -s $d >> build/test/info2.log
64   fi
65 done
66
67 sed -i "s/DCP: build\/test/DCP: \.\./g" build/test/info2.log
68
69 diff -q build/test/info2.log ../libdcp-test/info.log
70 if [ "$?" != "0" ]; then
71   echo "FAIL: dcpinfo output from rewrite incorrect"
72   exit 1
73 fi
74
75 diff build/test/baz/video1.mxf build/test/baz/video2.mxf
76 if [ "$?" != "0" ]; then
77   echo "FAIL: MXFs from recovery incorrect"
78   exit 1
79 fi
80     
81 echo "PASS"