Skip to content

Commit

Permalink
Policies tests
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Gervais <[email protected]>
  • Loading branch information
g-maxime committed May 19, 2024
1 parent 3587575 commit efbda10
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Project/GNU/CLI/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
45 changes: 45 additions & 0 deletions Project/GNU/CLI/test/test_policy.sh
Original file line number Diff line number Diff line change
@@ -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}
7 changes: 7 additions & 0 deletions Project/GNU/CLI/test/test_policy.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit efbda10

Please sign in to comment.