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