Basic writing of DCPs containing Atmos MXFs; untested.
[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=../libdcp1-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:build/asdcplib/src:$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     $work/tests $private $*
31 fi
32
33 # Check a MXF written by the unit tests
34 diff $work/baz/video1.mxf $work/baz/video2.mxf
35 if [ "$?" != "0" ]; then
36     echo "FAIL: MXFs from recovery incorrect"
37     exit 1
38 fi
39
40 # Check the DCP written by dcp_test1
41 diff -ur test/ref/DCP/dcp_test1 $work/DCP/dcp_test1
42 if [ "$?" != "0" ]; then
43     echo "FAIL: files differ"
44     exit 1
45 fi
46
47 # Check the DCP written by dcp_test2
48 diff -ur test/ref/DCP/dcp_test2 $work/DCP/dcp_test2
49 if [ "$?" != "0" ]; then
50     echo "FAIL: files differ"
51     exit 1
52 fi
53
54 # Check the DCP written by dcp_test5
55 diff -ur test/ref/DCP/dcp_test5 $work/DCP/dcp_test5
56 if [ "$?" != "0" ]; then
57     echo "FAIL: files differ"
58     exit 1
59 fi
60
61 # Check the DCP written by encryption_test
62 diff -ur test/ref/DCP/encryption_test $work/DCP/encryption_test
63 if [ "$?" != "0" ]; then
64     echo "FAIL: files differ"
65     exit 1
66 fi
67
68 # Everything beyond this point needs $private to exist
69 if [ ! -e "$private/info.log" ]; then
70     echo ""
71     echo "Private data not found: some tests will not run."
72     exit 1
73 fi
74
75 # Run dcpinfo on all the DCPs in private/metadata, writing $work/info.log
76 # This writes details of the CPLs and all subtitle details, so it checks
77 # if the code is reading subtitle files correctly.
78 rm -f $work/info.log
79 for d in `find $private/metadata -mindepth 1 -maxdepth 1 -type d | sort -f -d`; do
80     if [ `basename $d` != ".git" ]; then
81         $dcpinfo --ignore-missing-assets -k -s $d >> $work/info.log
82         if [ "$?" != "0" ]; then
83             echo "FAIL: dcpinfo failed for $d"
84             exit 1
85         fi
86     fi
87 done
88
89 # Check info.log is what it should be
90 diff -q $work/info.log $private/info.log
91 if [ "$?" != "0" ]; then
92     echo "FAIL: dcpinfo output incorrect"
93     exit 1
94 fi
95
96 # Copy $private into build/ then re-write the subtitles of every DCP using
97 # $work/rewrite_subs.  This tests round-trip of subtitle reading/writing.
98 # Note that all the subs in $private/metadata are Interop.
99 rm -f $work/info2.log
100 rm -rf $work/private
101 mkdir $work/private
102 cp -r $private/* $work/private
103 for d in `find $work/private/metadata -mindepth 1 -maxdepth 1 -type d | sort -f -d`; do
104     if [ `basename $d` != ".git" ]; then
105         $work/rewrite_subs $d
106         $dcpinfo --ignore-missing-assets -k -s $d >> $work/info2.log
107     fi
108 done
109
110 # Fudge the output
111 sed -i "s/DCP: build\/test/DCP: test/g" $work/info2.log
112
113 # And check it
114 diff -q $work/info2.log $private/info2.log
115 if [ "$?" != "0" ]; then
116     echo "FAIL: dcpinfo output from rewrite incorrect"
117     exit 1
118 fi
119
120 # Dump the subs of JourneyToJah... (which has MXF-wrapped SMPTE subtitles)
121 # and check that they are right
122 $dcpinfo -s $private/data/JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV >> $work/jah.log
123
124 # Parse some problematic subs and check that we get it right
125 run/test/subs_in_out $private/TunaBoat_Icelandic_Reel1_V1_8sec.xml > $work/tuna.xml
126 diff -q $private/TunaBoat_Icelandic_Reel1_V1_8sec.parsed.xml $work/tuna.xml
127 if [ "$?" != "0" ]; then
128     echo "FAIL: output of parse check 1 invalid"
129     exit 1
130 fi
131
132 echo "PASS"