summaryrefslogtreecommitdiff
path: root/run
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-02-26 15:43:53 +0000
committerCarl Hetherington <cth@carlh.net>2014-02-26 15:43:53 +0000
commitf3fba4af9566ae02f44dfa660c71dbaef6f4f92b (patch)
tree4b55c96e9101cee3c2b1f9dd854fad8c68a4383b /run
parent583999819d97ae98e97997ed7d6ccde9abc13e9b (diff)
Clean up unit testing.
Diffstat (limited to 'run')
-rwxr-xr-xrun/tests88
1 files changed, 88 insertions, 0 deletions
diff --git a/run/tests b/run/tests
new file mode 100755
index 00000000..97512b59
--- /dev/null
+++ b/run/tests
@@ -0,0 +1,88 @@
+#!/bin/bash -e
+#
+# Run our test suite, which (amongst other things)
+# builds a couple of DCPs.
+# The outputs are compared against the ones
+# in test/ref/DCP, and an error is given
+# if anything is different.
+
+private=test/private
+
+# Run the unit tests in test/
+if [ "$1" == "--debug" ]; then
+ shift
+ LD_LIBRARY_PATH=build/src:build/asdcplib/src gdb --args build/test/tests
+elif [ "$1" == "--valgrind" ]; then
+ shift
+ LD_LIBRARY_PATH=build/src:build/asdcplib/src valgrind --tool="memcheck" build/test/tests
+else
+ LD_LIBRARY_PATH=build/src:build/asdcplib/src build/test/tests $*
+fi
+
+if [ ! -e "test/private/info.log" ]; then
+ echo "Private data not found: some tests will not run"
+fi
+
+# Check the first DCP written by the unit tests
+diff -ur test/ref/DCP/foo build/test/DCP/foo
+if [ "$?" != "0" ]; then
+ echo "FAIL: files differ"
+ exit 1
+fi
+
+# Check the second DCP written by the unit tests
+diff -ur test/ref/DCP/bar build/test/DCP/bar
+if [ "$?" != "0" ]; then
+ echo "FAIL: files differ"
+ exit 1
+fi
+
+# Run dcpinfo on all the DCPs in private/metadata, writing build/test/info.log
+rm -f build/test/info.log
+for d in `find $private/metadata -mindepth 1 -maxdepth 1 -type d | sort`; do
+ if [ `basename $d` != ".git" ]; then
+ LD_LIBRARY_PATH=build/src:build/asdcplib/src build/tools/dcpinfo -s $d >> build/test/info.log
+ if [ "$?" != "0" ]; then
+ echo "FAIL: dcpinfo failed for $d"
+ exit 1
+ fi
+ fi
+done
+
+# Check info.log is what it should be
+diff -q build/test/info.log $private/info.log
+if [ "$?" != "0" ]; then
+ echo "FAIL: dcpinfo output incorrect"
+ exit 1
+fi
+
+# Copy test/private into build/ then re-write the subtitles of every DCP using
+# build/test/rewrite_subs. This tests round-trip of subtitle reading/writing.
+rm -f build/test/info2.log
+rm -rf build/test/private
+cp -r $private build/test
+for d in `find build/test/private/metadata -mindepth 1 -maxdepth 1 -type d | sort`; do
+ if [ `basename $d` != ".git" ]; then
+ LD_LIBRARY_PATH=build/src:build/asdcplib/src build/test/rewrite_subs $d
+ LD_LIBRARY_PATH=build/src:build/asdcplib/src build/tools/dcpinfo -s $d >> build/test/info2.log
+ fi
+done
+
+# Fudge the output
+sed -i "s/DCP: build\/test/DCP: test/g" build/test/info2.log
+
+# And check it
+diff -q build/test/info2.log $private/info.log
+if [ "$?" != "0" ]; then
+ echo "FAIL: dcpinfo output from rewrite incorrect"
+ exit 1
+fi
+
+# Check a MXF written by the unit tests
+diff build/test/baz/video1.mxf build/test/baz/video2.mxf
+if [ "$?" != "0" ]; then
+ echo "FAIL: MXFs from recovery incorrect"
+ exit 1
+fi
+
+echo "PASS"