Remove submodule of test/private as submodules don't seem to work too well with git...
[libdcp.git] / run / tests
1 #!/bin/bash -e
2 #
3 # Run our test suite, which (amongst other things)
4 # builds a couple of DCPs.
5 # The outputs are compared against the ones
6 # in test/ref/DCP, and an error is given
7 # if anything is different.
8
9 private=test/private
10 work=build/test
11
12 export LD_LIBRARY_PATH=build/src:build/asdcplib/src
13
14 # Run the unit tests in test/
15 if [ "$1" == "--debug" ]; then
16     shift
17     gdb --args $work/tests
18 elif [ "$1" == "--valgrind" ]; then
19     shift
20     valgrind --tool="memcheck" $work/tests
21 else
22     $work/tests $*
23 fi
24
25 # Check a MXF written by the unit tests
26 diff $work/baz/video1.mxf $work/baz/video2.mxf
27 if [ "$?" != "0" ]; then
28     echo "FAIL: MXFs from recovery incorrect"
29     exit 1
30 fi
31
32 # Check the first DCP written by the unit tests
33 diff -ur test/ref/DCP/foo $work/DCP/foo
34 if [ "$?" != "0" ]; then
35     echo "FAIL: files differ"
36     exit 1
37 fi
38
39 # Check the second DCP written by the unit tests
40 diff -ur test/ref/DCP/bar $work/DCP/bar
41 if [ "$?" != "0" ]; then
42     echo "FAIL: files differ"
43     exit 1
44 fi
45     
46 # Everything beyond this point needs $private to exist
47 if [ ! -e "$private/info.log" ]; then
48     echo ""
49     echo "Private data not found: some tests will not run."
50     exit 1
51 fi
52
53 # Run dcpinfo on all the DCPs in private/metadata, writing $work/info.log
54 rm -f $work/info.log
55 for d in `find $private/metadata -mindepth 1 -maxdepth 1 -type d | sort`; do
56     if [ `basename $d` != ".git" ]; then
57         build/tools/dcpinfo -s $d >> $work/info.log
58         if [ "$?" != "0" ]; then
59             echo "FAIL: dcpinfo failed for $d"
60             exit 1
61         fi
62     fi
63 done
64
65 # Check info.log is what it should be
66 diff -q $work/info.log $private/info.log
67 if [ "$?" != "0" ]; then
68     echo "FAIL: dcpinfo output incorrect"
69     exit 1
70 fi
71
72 # Copy test/private into build/ then re-write the subtitles of every DCP using 
73 # $work/rewrite_subs.  This tests round-trip of subtitle reading/writing.
74 rm -f $work/info2.log
75 rm -rf $work/private
76 cp -r $private $work
77 for d in `find $work/private/metadata -mindepth 1 -maxdepth 1 -type d | sort`; do
78     if [ `basename $d` != ".git" ]; then
79         $work/rewrite_subs $d
80         build/tools/dcpinfo -s $d >> $work/info2.log
81     fi
82 done
83
84 # Fudge the output
85 sed -i "s/DCP: build\/test/DCP: test/g" $work/info2.log
86
87 # And check it
88 diff -q $work/info2.log $private/info.log
89 if [ "$?" != "0" ]; then
90     echo "FAIL: dcpinfo output from rewrite incorrect"
91     exit 1
92 fi
93
94 # Dump the subs of JourneyToJah... (which has MXF-wrapped subtitles)
95 # and check that they are right
96 build/tools/dcpinfo -s $private/JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV >> $work/jah.log
97
98 echo "PASS"