Various probably quite untidy progress on KDMs.
[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 [ "$1" == "--debug" ]; then
12   shift
13   LD_LIBRARY_PATH=build/src:build/asdcplib/src gdb --args build/test/tests
14 else
15   LD_LIBRARY_PATH=build/src:build/asdcplib/src build/test/tests
16 fi
17
18 diff -ur test/ref/DCP/foo build/test/foo
19 if [ "$?" != "0" ]; then
20   echo "FAIL: files differ"
21   exit 1
22 fi
23
24 diff -ur test/ref/DCP/bar build/test/bar
25 if [ "$?" != "0" ]; then
26   echo "FAIL: files differ"
27   exit 1
28 fi
29
30 rm -f build/test/info.log
31
32 if [ ! -e "../libdcp-test" ]; then
33   echo "Test corpus not found"
34   exit 1
35 fi
36
37 for d in `find ../libdcp-test -mindepth 1 -maxdepth 1 -type d`; do
38   if [ `basename $d` != ".git" ]; then
39     LD_LIBRARY_PATH=build/src:build/asdcplib/src build/tools/dcpinfo -s $d >> build/test/info.log
40     if [ "$?" != "0" ]; then
41       echo "FAIL: dcpinfo failed for $d"
42       exit 1
43     fi
44   fi
45 done
46
47 diff -q build/test/info.log ../libdcp-test/info.log
48 if [ "$?" != "0" ]; then
49   echo "FAIL: dcpinfo output incorrect"
50   exit 1
51 fi
52
53 rm -f build/test/info2.log
54 rm -rf build/test/libdcp-test
55
56 cp -r ../libdcp-test build/test
57 for d in `find build/test/libdcp-test -mindepth 1 -maxdepth 1 -type d`; do
58   if [ `basename $d` != ".git" ]; then
59     LD_LIBRARY_PATH=build/src:build/asdcplib/src build/test/rewrite_subs $d
60     LD_LIBRARY_PATH=build/src:build/asdcplib/src build/tools/dcpinfo -s $d >> build/test/info2.log
61   fi
62 done
63
64 sed -i "s/DCP: build\/test/DCP: \.\./g" build/test/info2.log
65
66 diff -q build/test/info2.log ../libdcp-test/info.log
67 if [ "$?" != "0" ]; then
68   echo "FAIL: dcpinfo output from rewrite incorrect"
69   exit 1
70 fi
71     
72 echo "PASS"