diff --git a/test/examples.sh b/test/examples.sh index 7ba9ccef9..39f7e392d 100755 --- a/test/examples.sh +++ b/test/examples.sh @@ -15,7 +15,7 @@ example_tests=$(ls $(dirname $0)/*.sh) # List of script names to exclude. -exclude_list="examples vpxdec vpxenc tools_common" +exclude_list="examples tools_common" # Filter out the scripts in $exclude_list. for word in ${exclude_list}; do diff --git a/test/tools_common.sh b/test/tools_common.sh index 0bfefba46..15c7bcebb 100755 --- a/test/tools_common.sh +++ b/test/tools_common.sh @@ -144,6 +144,24 @@ is_windows_target() { fi } +# Echoes path to $1 when it's executable and exists in ${LIBVPX_BIN_PATH}, or an +# empty string. Caller is responsible for testing the string once the function +# returns. +vpx_tool_path() { + local readonly tool_name="$1" + local tool_path="${LIBVPX_BIN_PATH}/${tool_name}${VPX_TEST_EXE_SUFFIX}" + if [ ! -x "${tool_path}" ]; then + # Try one directory up: when running via examples.sh the tool could be in + # the parent directory of $LIBVPX_BIN_PATH. + tool_path="${LIBVPX_BIN_PATH}/../${tool_name}${VPX_TEST_EXE_SUFFIX}" + fi + + if [ ! -x "${tool_path}" ]; then + tool_path="" + fi + echo "${tool_path}" +} + # Echoes yes to stdout when the file named by positional parameter one exists # in LIBVPX_BIN_PATH, and is executable. vpx_tool_available() { diff --git a/test/vpxdec.sh b/test/vpxdec.sh index 836b13cce..a7bee7c6a 100755 --- a/test/vpxdec.sh +++ b/test/vpxdec.sh @@ -17,14 +17,13 @@ # Environment check: Make sure input is available. vpxdec_verify_environment() { if [ ! -e "${VP8_IVF_FILE}" ] || [ ! -e "${VP9_WEBM_FILE}" ]; then - echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH." + elog "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH." + return 1 + fi + if [ -z "$(vpx_tool_path vpxdec)" ]; then + elog "vpxdec not found. It must exist in LIBVPX_BIN_PATH or its parent." return 1 fi -} - -# Echoes yes to stdout when vpxdec exists according to vpx_tool_available(). -vpxdec_available() { - [ -n "$(vpx_tool_available vpxdec)" ] && echo yes } # Wrapper function for running vpxdec with pipe input. Requires that @@ -32,7 +31,7 @@ vpxdec_available() { # input file path and shifted away. All remaining parameters are passed through # to vpxdec. vpxdec_pipe() { - local decoder="${LIBVPX_BIN_PATH}/vpxdec${VPX_TEST_EXE_SUFFIX}" + local decoder="$(vpx_tool_path vpxdec)" local input="$1" shift cat "${input}" | eval "${VPX_TEST_PREFIX}" "${decoder}" - "$@" ${devnull} @@ -42,22 +41,20 @@ vpxdec_pipe() { # the directory containing vpxdec. $1 one is used as the input file path and # shifted away. All remaining parameters are passed through to vpxdec. vpxdec() { - local decoder="${LIBVPX_BIN_PATH}/vpxdec${VPX_TEST_EXE_SUFFIX}" + local decoder="$(vpx_tool_path vpxdec)" local input="${1}" shift eval "${VPX_TEST_PREFIX}" "${decoder}" "$input" "$@" ${devnull} } vpxdec_can_decode_vp8() { - if [ "$(vpxdec_available)" = "yes" ] && \ - [ "$(vp8_decode_available)" = "yes" ]; then + if [ "$(vp8_decode_available)" = "yes" ]; then echo yes fi } vpxdec_can_decode_vp9() { - if [ "$(vpxdec_available)" = "yes" ] && \ - [ "$(vp9_decode_available)" = "yes" ]; then + if [ "$(vp9_decode_available)" = "yes" ]; then echo yes fi } diff --git a/test/vpxenc.sh b/test/vpxenc.sh index 3cf3f4d40..83818aa98 100755 --- a/test/vpxenc.sh +++ b/test/vpxenc.sh @@ -23,33 +23,30 @@ vpxenc_verify_environment() { echo "The file ${YUV_RAW_INPUT##*/} must exist in LIBVPX_TEST_DATA_PATH." return 1 fi + if [ -z "$(vpx_tool_path vpxenc)" ]; then + elog "vpxenc not found. It must exist in LIBVPX_BIN_PATH or its parent." + return 1 + fi } vpxenc_can_encode_vp8() { - if [ "$(vpxenc_available)" = "yes" ] && \ - [ "$(vp8_encode_available)" = "yes" ]; then + if [ "$(vp8_encode_available)" = "yes" ]; then echo yes fi } vpxenc_can_encode_vp9() { - if [ "$(vpxenc_available)" = "yes" ] && \ - [ "$(vp9_encode_available)" = "yes" ]; then + if [ "$(vp9_encode_available)" = "yes" ]; then echo yes fi } -# Echoes yes to stdout when vpxenc exists according to vpx_tool_available(). -vpxenc_available() { - [ -n "$(vpx_tool_available vpxenc)" ] && echo yes -} - # Wrapper function for running vpxenc with pipe input. Requires that # LIBVPX_BIN_PATH points to the directory containing vpxenc. $1 is used as the # input file path and shifted away. All remaining parameters are passed through # to vpxenc. vpxenc_pipe() { - local readonly encoder="${LIBVPX_BIN_PATH}/vpxenc${VPX_TEST_EXE_SUFFIX}" + local readonly encoder="$(vpx_tool_path vpxenc)" local readonly input="$1" shift cat "${input}" | eval "${VPX_TEST_PREFIX}" "${encoder}" - "$@" ${devnull} @@ -59,7 +56,7 @@ vpxenc_pipe() { # the directory containing vpxenc. $1 one is used as the input file path and # shifted away. All remaining parameters are passed through to vpxenc. vpxenc() { - local readonly encoder="${LIBVPX_BIN_PATH}/vpxenc${VPX_TEST_EXE_SUFFIX}" + local readonly encoder="$(vpx_tool_path vpxenc)" local readonly input="${1}" shift eval "${VPX_TEST_PREFIX}" "${encoder}" "$input" "$@" ${devnull}