diff --git a/Project/GNU/CLI/Makefile.am b/Project/GNU/CLI/Makefile.am index 18eeec38..87d26fec 100644 --- a/Project/GNU/CLI/Makefile.am +++ b/Project/GNU/CLI/Makefile.am @@ -60,7 +60,8 @@ TESTS = \ test/simple.sh \ test/filename.sh \ test/test_mk.sh \ - test/test_ffv1.sh + test/test_ffv1.sh \ + test/test_policy.sh SAMPLES_DIR = test/SampleFiles diff --git a/Project/GNU/CLI/test/test_policy.sh b/Project/GNU/CLI/test/test_policy.sh new file mode 100755 index 00000000..8f921ef4 --- /dev/null +++ b/Project/GNU/CLI/test/test_policy.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +PATH_SCRIPT=$(dirname "${0}") +. "${PATH_SCRIPT}/utils.sh" + +FILES_DIRECTORY="${PATH_SCRIPT}/SampleFiles/PolicyTestFiles" + +MC="${PWD}/mediaconch" + +RCODE=0 + +while read LINE ; do + POLICY="$(echo "${LINE}" | cut -d':' -f1)" + FILE="$(echo "${LINE}" | cut -d':' -f2)" + OUTCOME="$(echo "${LINE}" | cut -d':' -f3)" + TEST="${POLICY}:$(basename "${FILE}"):${OUTCOME}" + + if [ ! -e "${FILES_DIRECTORY}/Policy/${POLICY}" ] ; then + echo "NOK: ${TEST}/${POLICY}, file not found" >&9 + RCODE=1 + continue + fi + + if [ ! -e "${FILES_DIRECTORY}/${FILE}" ] ; then + echo "NOK: ${TEST}/${FILE}, file not found" >&9 + RCODE=1 + continue + fi + + pushd "${FILES_DIRECTORY}" >/dev/null 2>&1 + DATA="$(${MC} -p Policy/${POLICY} -fx ${FILE})" + + T1=`echo "${DATA}" | xmllint --xpath \ + "string(/*[local-name()='MediaConch']/*[local-name()='media']/*[local-name()='policy']/@outcome)" -` + + if [ "${T1}" == "${OUTCOME}" ] ; then + echo "OK: ${TEST}" >&9 + else + echo "NOK: ${TEST}, failed" >&9 + RCODE=1 + fi + popd >/dev/null 2>&1 +done < "${PATH_SCRIPT}/test_policy.txt" + +exit ${RCODE} diff --git a/Project/GNU/CLI/test/test_policy.txt b/Project/GNU/CLI/test/test_policy.txt new file mode 100644 index 00000000..28f557bd --- /dev/null +++ b/Project/GNU/CLI/test/test_policy.txt @@ -0,0 +1,7 @@ +value.xml:Matroska/videofirst.mkv:pass +value.xml:Matroska/audiofirst.mkv:fail +info.xml:Matroska/audiofirst.mkv:info +warn.xml:Matroska/audiofirst.mkv:warn +levelcap.xml:Matroska/audiofirst.mkv:info +operators.xml:Matroska/videofirst.mkv:pass +mmt.xml:Matroska/videofirst.mkv:pass