Remove use of xmldiff in tests.
[libdcp.git] / run / tests
1 #!/bin/bash
2 #
3 # Run our test suite.
4
5 # Private test data; this is stuff that is non-distributable
6 private=../libdcp-test-private
7 # Work directory
8 work=build/test
9 # Path to tools
10 dcpinfo=build/tools/dcpinfo
11 dcpverify=build/tools/dcpverify
12
13 export LD_LIBRARY_PATH=build/src:$LD_LIBRARY_PATH
14 # SIP stops this being passed in from the caller's environment
15 export DYLD_LIBRARY_PATH=/Users/ci/osx-environment/64/lib
16 export LIBDCP_SHARE_PREFIX=.
17
18 # Make sure we have the required tools
19 for c in xmlsec1 xmllint; do
20   hash $c 2>/dev/null || { echo >&2 "$c required but not found; aborting"; exit 1; }
21 done
22
23 echo "--- Unit tests"
24
25 # Run the unit tests in test/
26 if [ "$1" == "--debug" ]; then
27     shift
28     gdb --args $work/tests $private $*
29 elif [ "$1" == "--valgrind" ]; then
30     shift
31     valgrind --tool="memcheck" $work/tests $private $*
32 elif [ "$1" == "--callgrind" ]; then
33     shift
34     valgrind --tool="callgrind" $work/tests $private $*
35 else
36     $work/tests $* -- $private
37     if [ "$?" != "0" ]; then
38         echo "FAIL: unit tests"
39         exit 1
40     fi
41 fi
42
43 if [ "$*" != "" ]; then
44     echo "Skipping post-test checks as not all unit tests were run."
45     exit 0
46 fi
47
48 echo "--- Other tests"
49
50 # Check a MXF written by the unit tests
51 diff $work/baz/video1.mxf $work/baz/video2.mxf
52 if [ "$?" != "0" ]; then
53     echo "FAIL: MXFs from recovery incorrect"
54     exit 1
55 fi
56
57 # Check the DCP written by dcp_test1
58 diff -ur test/ref/DCP/dcp_test1 $work/DCP/dcp_test1
59 if [ "$?" != "0" ]; then
60     echo "FAIL: files differ"
61     exit 1
62 fi
63
64 # Check the DCP written by dcp_test2
65 diff -ur test/ref/DCP/dcp_test2 $work/DCP/dcp_test2
66 if [ "$?" != "0" ]; then
67     echo "FAIL: files differ"
68     exit 1
69 fi
70
71 # Check the DCP written by dcp_test5
72 diff -ur test/ref/DCP/dcp_test5 $work/DCP/dcp_test5
73 if [ "$?" != "0" ]; then
74     echo "FAIL: files differ"
75     exit 1
76 fi
77
78 # Check the DCP written by dcp_test7
79 diff -ur test/ref/DCP/dcp_test7 $work/DCP/dcp_test7
80 if [ "$?" != "0" ]; then
81     echo "FAIL: files differ"
82     exit 1
83 fi
84
85 # Check the DCP written by encryption_test
86 diff -ur test/ref/DCP/encryption_test $work/DCP/encryption_test
87 if [ "$?" != "0" ]; then
88     echo "FAIL: files differ"
89     exit 1
90 fi
91
92 # Everything beyond this point needs $private to exist
93 if [ ! -e "$private/info.log" ]; then
94     echo ""
95     echo "Private data not found: some tests will not run."
96     exit 1
97 fi
98
99 # Run dcpinfo on all the DCPs in private/metadata, writing $work/info.log
100 # This writes details of the CPLs and all subtitle details, so it checks
101 # if the code is reading subtitle files correctly.
102 rm -f $work/info.log
103 for d in `find $private/metadata -mindepth 1 -maxdepth 1 -type d | sort -f -d`; do
104     if [ `basename $d` != ".git" ]; then
105         $dcpinfo --ignore-missing-assets -s $d >> $work/info.log
106         if [ "$?" != "0" ]; then
107             echo "FAIL: dcpinfo failed for $d"
108             exit 1
109         fi
110     fi
111 done
112
113 # Run dcpverify on all the DCPs in private/metadata
114 for d in `find $private/metadata -mindepth 1 -maxdepth 1 -type d | sort -f -d`; do
115     if [ `basename $d` != ".git" ]; then
116         $dcpverify --ignore-missing-assets -q $d
117         if [ "$?" != "0" ]; then
118             echo "FAIL: dcpverify failed for $d"
119             exit 1
120         fi
121     fi
122 done
123
124 # Check info.log is what it should be
125 diff -q $work/info.log $private/info.log
126 if [ "$?" != "0" ]; then
127     echo "FAIL: dcpinfo output incorrect"
128     exit 1
129 fi
130
131 # Copy $private/metadata into build/metadata then re-write the subtitles
132 # of every DCP using $work/rewrite_subs.  This tests round-trip of
133 # subtitle reading/writing.
134 rm -f $work/info2.log
135 rm -rf $work/private
136 mkdir $work/private
137 cp -r $private/metadata $work/private/
138 for d in `find $work/private/metadata -mindepth 1 -maxdepth 1 -type d | sort -f -d`; do
139     if [ `basename $d` != ".git" ]; then
140         $work/rewrite_subs $d
141         $dcpinfo --ignore-missing-assets -s $d >> $work/info2.log
142     fi
143 done
144
145 # Fudge the output
146 sed -i "s/DCP: build\/test/DCP: test/g" $work/info2.log
147
148 # And check it
149 diff -q $work/info2.log $private/info2.log
150 if [ "$?" != "0" ]; then
151     echo "FAIL: dcpinfo output from rewrite incorrect"
152     exit 1
153 fi
154
155 # Dump the subs of JourneyToJah... (which has MXF-wrapped SMPTE subtitles)
156 # and check that they are right
157 $dcpinfo -s $private/data/JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV >> $work/jah.log
158
159 # Parse some problematic subs and check that we get it right
160 run/test/subs_in_out $private/TunaBoat_Icelandic_Reel1_V1_8sec.xml > $work/tuna.xml
161 diff -q $private/TunaBoat_Icelandic_Reel1_V1_8sec.parsed.xml $work/tuna.xml
162 if [ "$?" != "0" ]; then
163     echo "FAIL: output of parse check 1 invalid"
164     exit 1
165 fi
166
167 echo "PASS"