blob: 09b3f24009f76a894523dbabea27a7f86e56b639 [file] [log] [blame]
Tom Finegan36c39d62014-04-03 13:16:58 -07001#!/bin/sh
Krishna Rapaka7319db52021-09-28 20:35:29 -07002## Copyright (c) 2021, Alliance for Open Media. All rights reserved
Tom Finegan36c39d62014-04-03 13:16:58 -07003##
Krishna Rapaka7319db52021-09-28 20:35:29 -07004## This source code is subject to the terms of the BSD 3-Clause Clear License and the
5## Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear License was
6## not distributed with this source code in the LICENSE file, you can obtain it
7## at aomedia.org/license/software-license/bsd-3-c-c/. If the Alliance for Open Media Patent
8## License 1.0 was not distributed with this source code in the PATENTS file, you
9## can obtain it at aomedia.org/license/patent-license/.
Tom Finegan36c39d62014-04-03 13:16:58 -070010##
Yaowu Xuc27fc142016-08-22 16:08:15 -070011## This file contains shell code shared by test scripts for libaom tools.
Tom Finegan4e7e1f12014-04-28 17:16:05 -070012
Yaowu Xuf883b422016-08-30 14:01:10 -070013# Use $AOM_TEST_TOOLS_COMMON_SH as a pseudo include guard.
14if [ -z "${AOM_TEST_TOOLS_COMMON_SH}" ]; then
15AOM_TEST_TOOLS_COMMON_SH=included
Tom Finegan4e7e1f12014-04-28 17:16:05 -070016
Tom Finegan36c39d62014-04-03 13:16:58 -070017set -e
Tom Finegan1d29ce52014-04-30 11:03:15 -070018devnull='> /dev/null 2>&1'
Yaowu Xuf883b422016-08-30 14:01:10 -070019AOM_TEST_PREFIX=""
Tom Finegan36c39d62014-04-03 13:16:58 -070020
Tom Finegan12672c22014-06-16 10:57:00 -070021elog() {
22 echo "$@" 1>&2
23}
24
Tom Fineganc5d962d2014-04-28 20:56:37 -070025vlog() {
Yaowu Xuf883b422016-08-30 14:01:10 -070026 if [ "${AOM_TEST_VERBOSE_OUTPUT}" = "yes" ]; then
Tom Finegan7279d442014-05-08 12:06:08 -070027 echo "$@"
28 fi
Tom Fineganc5d962d2014-04-28 20:56:37 -070029}
30
Yaowu Xuf883b422016-08-30 14:01:10 -070031# Sets $AOM_TOOL_TEST to the name specified by positional parameter one.
Tom Finegan36c39d62014-04-03 13:16:58 -070032test_begin() {
Yaowu Xuf883b422016-08-30 14:01:10 -070033 AOM_TOOL_TEST="${1}"
Tom Finegan36c39d62014-04-03 13:16:58 -070034}
35
Yaowu Xuf883b422016-08-30 14:01:10 -070036# Clears the AOM_TOOL_TEST variable after confirming that $AOM_TOOL_TEST matches
Tom Finegan36c39d62014-04-03 13:16:58 -070037# positional parameter one.
38test_end() {
Yaowu Xuf883b422016-08-30 14:01:10 -070039 if [ "$1" != "${AOM_TOOL_TEST}" ]; then
Tom Finegan36c39d62014-04-03 13:16:58 -070040 echo "FAIL completed test mismatch!."
41 echo " completed test: ${1}"
Yaowu Xuf883b422016-08-30 14:01:10 -070042 echo " active test: ${AOM_TOOL_TEST}."
Tom Finegan36c39d62014-04-03 13:16:58 -070043 return 1
44 fi
Yaowu Xuf883b422016-08-30 14:01:10 -070045 AOM_TOOL_TEST='<unset>'
Tom Finegan36c39d62014-04-03 13:16:58 -070046}
47
48# Echoes the target configuration being tested.
49test_configuration_target() {
Tom Finegane54b8232018-07-09 14:25:33 -070050 aom_config_c="${LIBAOM_CONFIG_PATH}/config/aom_config.c"
51 # Clean up the cfg pointer line from aom_config.c for easier re-use by
52 # someone examining a failure in the example tests.
53 # 1. Run grep on aom_config.c for cfg and limit the results to 1.
54 # 2. Split the line using ' = ' as separator.
55 # 3. Abuse sed to consume the leading " and trailing "; from the assignment
56 # to the cfg pointer.
57 cmake_config=$(awk -F ' = ' '/cfg/ { print $NF; exit }' "${aom_config_c}" \
58 | sed -e s/\"// -e s/\"\;//)
59 echo cmake generated via command: cmake path/to/aom ${cmake_config}
Tom Finegan36c39d62014-04-03 13:16:58 -070060}
61
62# Trap function used for failure reports and tool output directory removal.
Yaowu Xuf883b422016-08-30 14:01:10 -070063# When the contents of $AOM_TOOL_TEST do not match the string '<unset>', reports
64# failure of test stored in $AOM_TOOL_TEST.
Tom Finegan36c39d62014-04-03 13:16:58 -070065cleanup() {
Yaowu Xuf883b422016-08-30 14:01:10 -070066 if [ -n "${AOM_TOOL_TEST}" ] && [ "${AOM_TOOL_TEST}" != '<unset>' ]; then
67 echo "FAIL: $AOM_TOOL_TEST"
Tom Finegan36c39d62014-04-03 13:16:58 -070068 fi
Tom Finegan8ab44142018-04-27 14:57:52 -070069 if [ "${AOM_TEST_PRESERVE_OUTPUT}" = "yes" ]; then
70 return
71 fi
Yaowu Xuf883b422016-08-30 14:01:10 -070072 if [ -n "${AOM_TEST_OUTPUT_DIR}" ] && [ -d "${AOM_TEST_OUTPUT_DIR}" ]; then
73 rm -rf "${AOM_TEST_OUTPUT_DIR}"
Tom Finegan36c39d62014-04-03 13:16:58 -070074 fi
75}
76
Tom Finegan355e46d2018-03-06 18:47:58 -080077# Echoes the version string assigned to the VERSION_STRING_NOSP variable defined
Tom Finegan6791ad12018-05-24 14:30:59 -070078# in $LIBAOM_CONFIG_PATH/config/aom_version.h to stdout.
Tom Finegan355e46d2018-03-06 18:47:58 -080079cmake_version() {
Tom Finegan6791ad12018-05-24 14:30:59 -070080 aom_version_h="${LIBAOM_CONFIG_PATH}/config/aom_version.h"
Tom Finegan747cf982017-06-08 08:53:01 -070081
Tom Finegan355e46d2018-03-06 18:47:58 -080082 # Find VERSION_STRING_NOSP line, split it with '"' and print the next to last
83 # field to output the version string to stdout.
84 aom_version=$(awk -F \" '/VERSION_STRING_NOSP/ {print $(NF-1)}' \
85 "${aom_version_h}")
86 echo "v${aom_version}"
Tom Finegan36c39d62014-04-03 13:16:58 -070087}
88
Tom Finegan355e46d2018-03-06 18:47:58 -080089# Echoes current git version as reported by running 'git describe', or the
90# version used by the cmake build when git is unavailable.
Urvang Joshi0766c992021-03-05 15:53:01 -080091# Note: version.cmake strips optional prefix before the version. So,
92# source_version() function needs to do the same, so that the strings can be
93# compared in check_version_strings() later.
Tom Finegan355e46d2018-03-06 18:47:58 -080094source_version() {
Tom Finegan36c39d62014-04-03 13:16:58 -070095 if git --version > /dev/null 2>&1; then
96 (cd "$(dirname "${0}")"
Urvang Joshi0766c992021-03-05 15:53:01 -080097 git describe | sed 's/.*-v/v/')
Tom Finegan36c39d62014-04-03 13:16:58 -070098 else
Tom Finegan355e46d2018-03-06 18:47:58 -080099 cmake_version
Tom Finegan36c39d62014-04-03 13:16:58 -0700100 fi
101}
102
Tom Finegan355e46d2018-03-06 18:47:58 -0800103# Echoes warnings to stdout when source version and CMake build generated
104# version are out of sync.
105check_version_strings() {
106 cmake_version=$(cmake_version)
107 source_version=$(source_version)
Tom Finegan36c39d62014-04-03 13:16:58 -0700108
Tom Finegan355e46d2018-03-06 18:47:58 -0800109 if [ "${cmake_version}" != "${source_version}" ]; then
110 echo "Warning: version has changed since last cmake run."
111 vlog " cmake version: ${cmake_version} version now: ${source_version}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700112 fi
113}
114
James Zern2ebe0ae2015-02-26 12:57:30 -0800115# $1 is the name of an environment variable containing a directory name to
116# test.
117test_env_var_dir() {
118 local dir=$(eval echo "\${$1}")
119 if [ ! -d "${dir}" ]; then
120 elog "'${dir}': No such directory"
121 elog "The $1 environment variable must be set to a valid directory."
122 return 1
123 fi
124}
125
Yaowu Xuc27fc142016-08-22 16:08:15 -0700126# This script requires that the LIBAOM_BIN_PATH, LIBAOM_CONFIG_PATH, and
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700127# LIBAOM_TEST_DATA_PATH variables are in the environment: Confirm that
Tom Finegan36c39d62014-04-03 13:16:58 -0700128# the variables are set and that they all evaluate to directory paths.
Yaowu Xuf883b422016-08-30 14:01:10 -0700129verify_aom_test_environment() {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700130 test_env_var_dir "LIBAOM_BIN_PATH" \
131 && test_env_var_dir "LIBAOM_CONFIG_PATH" \
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700132 && test_env_var_dir "LIBAOM_TEST_DATA_PATH"
Tom Finegan36c39d62014-04-03 13:16:58 -0700133}
134
Yaowu Xuf883b422016-08-30 14:01:10 -0700135# Greps aom_config.h in LIBAOM_CONFIG_PATH for positional parameter one, which
Yaowu Xuc27fc142016-08-22 16:08:15 -0700136# should be a LIBAOM preprocessor flag. Echoes yes to stdout when the feature
Tom Finegan36c39d62014-04-03 13:16:58 -0700137# is available.
Yaowu Xuf883b422016-08-30 14:01:10 -0700138aom_config_option_enabled() {
139 aom_config_option="${1}"
Tom Finegan60e653d2018-05-22 11:34:58 -0700140 aom_config_file="${LIBAOM_CONFIG_PATH}/config/aom_config.h"
Yaowu Xuf883b422016-08-30 14:01:10 -0700141 config_line=$(grep "${aom_config_option}" "${aom_config_file}")
Tom Finegan36c39d62014-04-03 13:16:58 -0700142 if echo "${config_line}" | egrep -q '1$'; then
143 echo yes
144 fi
145}
146
147# Echoes yes when output of test_configuration_target() contains win32 or win64.
148is_windows_target() {
149 if test_configuration_target \
150 | grep -q -e win32 -e win64 > /dev/null 2>&1; then
151 echo yes
152 fi
153}
154
Tom Finegancd41a512018-02-16 15:58:48 -0800155# Echoes path to $1 when it's executable and exists in one of the directories
156# included in $tool_paths, or an empty string. Caller is responsible for testing
157# the string once the function returns.
Yaowu Xuf883b422016-08-30 14:01:10 -0700158aom_tool_path() {
Tom Fineganef64ee82018-07-10 11:35:40 -0700159 local tool_name="$1"
160 local root_path="${LIBAOM_BIN_PATH}"
161 local suffix="${AOM_TEST_EXE_SUFFIX}"
162 local tool_paths="\
Tom Finegancd41a512018-02-16 15:58:48 -0800163 ${root_path}/${tool_name}${suffix} \
164 ${root_path}/../${tool_name}${suffix} \
165 ${root_path}/tools/${tool_name}${suffix} \
166 ${root_path}/../tools/${tool_name}${suffix}"
Tom Finegan4d91e162014-08-15 11:31:30 -0700167
Tom Finegancd41a512018-02-16 15:58:48 -0800168 local toolpath=""
169
170 for tool_path in ${tool_paths}; do
171 if [ -x "${tool_path}" ] && [ -f "${tool_path}" ]; then
172 echo "${tool_path}"
173 return 0
174 fi
175 done
176
177 return 1
Tom Finegan4d91e162014-08-15 11:31:30 -0700178}
179
Tom Finegan36c39d62014-04-03 13:16:58 -0700180# Echoes yes to stdout when the file named by positional parameter one exists
Yaowu Xuc27fc142016-08-22 16:08:15 -0700181# in LIBAOM_BIN_PATH, and is executable.
Yaowu Xuf883b422016-08-30 14:01:10 -0700182aom_tool_available() {
Tom Finegan39c5a4b2014-04-22 19:36:40 -0700183 local tool_name="$1"
Yaowu Xuf883b422016-08-30 14:01:10 -0700184 local tool="${LIBAOM_BIN_PATH}/${tool_name}${AOM_TEST_EXE_SUFFIX}"
Tom Finegan39c5a4b2014-04-22 19:36:40 -0700185 [ -x "${tool}" ] && echo yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700186}
187
Yaowu Xuf883b422016-08-30 14:01:10 -0700188# Echoes yes to stdout when aom_config_option_enabled() reports yes for
189# CONFIG_AV1_DECODER.
190av1_decode_available() {
191 [ "$(aom_config_option_enabled CONFIG_AV1_DECODER)" = "yes" ] && echo yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700192}
193
Yaowu Xuf883b422016-08-30 14:01:10 -0700194# Echoes yes to stdout when aom_config_option_enabled() reports yes for
195# CONFIG_AV1_ENCODER.
196av1_encode_available() {
197 [ "$(aom_config_option_enabled CONFIG_AV1_ENCODER)" = "yes" ] && echo yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700198}
199
Tom Finegan9a74bb62018-02-15 14:59:40 -0800200# Echoes "fast" encode params for use with aomenc.
201aomenc_encode_test_fast_params() {
Yaowu Xu8d9fecb2020-04-27 15:21:02 -0700202 echo "--cpu-used=2
Tom Finegan8ab44142018-04-27 14:57:52 -0700203 --limit=${AV1_ENCODE_TEST_FRAME_LIMIT}
Tom Finegan9a74bb62018-02-15 14:59:40 -0800204 --lag-in-frames=0
205 --test-decode=fatal"
206}
207
Yaowu Xuf883b422016-08-30 14:01:10 -0700208# Echoes yes to stdout when aom_config_option_enabled() reports yes for
Tom Finegan36c39d62014-04-03 13:16:58 -0700209# CONFIG_WEBM_IO.
210webm_io_available() {
Yaowu Xuf883b422016-08-30 14:01:10 -0700211 [ "$(aom_config_option_enabled CONFIG_WEBM_IO)" = "yes" ] && echo yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700212}
213
Tom Fineganf34d7282014-09-19 11:09:39 -0700214# Filters strings from $1 using the filter specified by $2. Filter behavior
215# depends on the presence of $3. When $3 is present, strings that match the
216# filter are excluded. When $3 is omitted, strings matching the filter are
217# included.
218# The filtered result is echoed to stdout.
Tom Finegan36c39d62014-04-03 13:16:58 -0700219filter_strings() {
220 strings=${1}
221 filter=${2}
222 exclude=${3}
223
224 if [ -n "${exclude}" ]; then
225 # When positional parameter three exists the caller wants to remove strings.
226 # Tell grep to invert matches using the -v argument.
227 exclude='-v'
228 else
229 unset exclude
230 fi
231
232 if [ -n "${filter}" ]; then
233 for s in ${strings}; do
234 if echo "${s}" | egrep -q ${exclude} "${filter}" > /dev/null 2>&1; then
235 filtered_strings="${filtered_strings} ${s}"
236 fi
237 done
238 else
239 filtered_strings="${strings}"
240 fi
241 echo "${filtered_strings}"
242}
243
244# Runs user test functions passed via positional parameters one and two.
245# Functions in positional parameter one are treated as environment verification
246# functions and are run unconditionally. Functions in positional parameter two
Yaowu Xuf883b422016-08-30 14:01:10 -0700247# are run according to the rules specified in aom_test_usage().
Tom Finegan36c39d62014-04-03 13:16:58 -0700248run_tests() {
Yaowu Xuf883b422016-08-30 14:01:10 -0700249 local env_tests="verify_aom_test_environment $1"
Tom Finegan3d38cf92014-05-15 15:31:02 -0700250 local tests_to_filter="$2"
Yaowu Xuf883b422016-08-30 14:01:10 -0700251 local test_name="${AOM_TEST_NAME}"
Tom Finegan3d38cf92014-05-15 15:31:02 -0700252
253 if [ -z "${test_name}" ]; then
James Zern81880962014-05-21 19:54:48 -0700254 test_name="$(basename "${0%.*}")"
Tom Finegan3d38cf92014-05-15 15:31:02 -0700255 fi
Tom Finegan36c39d62014-04-03 13:16:58 -0700256
Yaowu Xuf883b422016-08-30 14:01:10 -0700257 if [ "${AOM_TEST_RUN_DISABLED_TESTS}" != "yes" ]; then
Tom Finegan36c39d62014-04-03 13:16:58 -0700258 # Filter out DISABLED tests.
259 tests_to_filter=$(filter_strings "${tests_to_filter}" ^DISABLED exclude)
260 fi
261
Yaowu Xuf883b422016-08-30 14:01:10 -0700262 if [ -n "${AOM_TEST_FILTER}" ]; then
Tom Finegan36c39d62014-04-03 13:16:58 -0700263 # Remove tests not matching the user's filter.
Yaowu Xuf883b422016-08-30 14:01:10 -0700264 tests_to_filter=$(filter_strings "${tests_to_filter}" ${AOM_TEST_FILTER})
Tom Finegan36c39d62014-04-03 13:16:58 -0700265 fi
266
Tom Fineganf34d7282014-09-19 11:09:39 -0700267 # User requested test listing: Dump test names and return.
Yaowu Xuf883b422016-08-30 14:01:10 -0700268 if [ "${AOM_TEST_LIST_TESTS}" = "yes" ]; then
Tom Fineganf34d7282014-09-19 11:09:39 -0700269 for test_name in $tests_to_filter; do
270 echo ${test_name}
271 done
272 return
273 fi
274
James Zern84eca072014-12-17 19:02:00 -0800275 # Don't bother with the environment tests if everything else was disabled.
276 [ -z "${tests_to_filter}" ] && return
277
Tom Fineganf34d7282014-09-19 11:09:39 -0700278 # Combine environment and actual tests.
Tom Finegan3d38cf92014-05-15 15:31:02 -0700279 local tests_to_run="${env_tests} ${tests_to_filter}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700280
Tom Finegan355e46d2018-03-06 18:47:58 -0800281 check_version_strings
Tom Finegan36c39d62014-04-03 13:16:58 -0700282
283 # Run tests.
284 for test in ${tests_to_run}; do
285 test_begin "${test}"
Tom Fineganc5d962d2014-04-28 20:56:37 -0700286 vlog " RUN ${test}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700287 "${test}"
Tom Fineganc5d962d2014-04-28 20:56:37 -0700288 vlog " PASS ${test}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700289 test_end "${test}"
290 done
291
Tom Finegan355e46d2018-03-06 18:47:58 -0800292 local tested_config="$(test_configuration_target) @ $(source_version)"
Tom Finegan3d38cf92014-05-15 15:31:02 -0700293 echo "${test_name}: Done, all tests pass for ${tested_config}."
Tom Finegan36c39d62014-04-03 13:16:58 -0700294}
295
Yaowu Xuf883b422016-08-30 14:01:10 -0700296aom_test_usage() {
Tom Finegan36c39d62014-04-03 13:16:58 -0700297cat << EOF
298 Usage: ${0##*/} [arguments]
Yaowu Xuc27fc142016-08-22 16:08:15 -0700299 --bin-path <path to libaom binaries directory>
300 --config-path <path to libaom config directory>
Tom Finegan36c39d62014-04-03 13:16:58 -0700301 --filter <filter>: User test filter. Only tests matching filter are run.
302 --run-disabled-tests: Run disabled tests.
303 --help: Display this message and exit.
Yaowu Xuc27fc142016-08-22 16:08:15 -0700304 --test-data-path <path to libaom test data directory>
Tom Finegan1d29ce52014-04-30 11:03:15 -0700305 --show-program-output: Shows output from all programs being tested.
Tom Finegan926a6f62014-07-10 15:17:05 -0700306 --prefix: Allows for a user specified prefix to be inserted before all test
307 programs. Grants the ability, for example, to run test programs
308 within valgrind.
Tom Fineganf34d7282014-09-19 11:09:39 -0700309 --list-tests: List all test names and exit without actually running tests.
Tom Finegan36c39d62014-04-03 13:16:58 -0700310 --verbose: Verbose output.
311
312 When the --bin-path option is not specified the script attempts to use
Yaowu Xuc27fc142016-08-22 16:08:15 -0700313 \$LIBAOM_BIN_PATH and then the current directory.
Tom Finegan36c39d62014-04-03 13:16:58 -0700314
315 When the --config-path option is not specified the script attempts to use
Yaowu Xuc27fc142016-08-22 16:08:15 -0700316 \$LIBAOM_CONFIG_PATH and then the current directory.
Tom Finegan36c39d62014-04-03 13:16:58 -0700317
318 When the -test-data-path option is not specified the script attempts to use
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700319 \$LIBAOM_TEST_DATA_PATH and then the current directory.
Tom Finegan36c39d62014-04-03 13:16:58 -0700320EOF
321}
322
323# Returns non-zero (failure) when required environment variables are empty
324# strings.
Yaowu Xuf883b422016-08-30 14:01:10 -0700325aom_test_check_environment() {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700326 if [ -z "${LIBAOM_BIN_PATH}" ] || \
327 [ -z "${LIBAOM_CONFIG_PATH}" ] || \
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700328 [ -z "${LIBAOM_TEST_DATA_PATH}" ]; then
Tom Finegan36c39d62014-04-03 13:16:58 -0700329 return 1
330 fi
331}
332
Jim Bankoskie78a9642016-05-25 07:02:19 -0700333# Echo aomenc command line parameters allowing use of a raw yuv file as
334# input to aomenc.
335yuv_raw_input() {
336 echo ""${YUV_RAW_INPUT}"
337 --width="${YUV_RAW_INPUT_WIDTH}"
338 --height="${YUV_RAW_INPUT_HEIGHT}""
339}
340
341# Do a small encode for testing decoders.
342encode_yuv_raw_input_av1() {
343 if [ "$(av1_encode_available)" = "yes" ]; then
Tom Fineganef64ee82018-07-10 11:35:40 -0700344 local output="$1"
345 local encoder="$(aom_tool_path aomenc)"
Jim Bankoskif7f04372016-05-27 14:31:29 -0700346 shift
Jim Bankoskie78a9642016-05-25 07:02:19 -0700347 eval "${encoder}" $(yuv_raw_input) \
Tom Finegan8ab44142018-04-27 14:57:52 -0700348 $(aomenc_encode_test_fast_params) \
Jim Bankoskie78a9642016-05-25 07:02:19 -0700349 --output="${output}" \
Tom Finegan8ab44142018-04-27 14:57:52 -0700350 $@ \
Jim Bankoskie78a9642016-05-25 07:02:19 -0700351 ${devnull}
352
353 if [ ! -e "${output}" ]; then
354 elog "Output file does not exist."
355 return 1
356 fi
357 fi
358}
359
Tom Finegan36c39d62014-04-03 13:16:58 -0700360# Parse the command line.
361while [ -n "$1" ]; do
362 case "$1" in
363 --bin-path)
Yaowu Xuc27fc142016-08-22 16:08:15 -0700364 LIBAOM_BIN_PATH="$2"
Tom Finegan36c39d62014-04-03 13:16:58 -0700365 shift
366 ;;
367 --config-path)
Yaowu Xuc27fc142016-08-22 16:08:15 -0700368 LIBAOM_CONFIG_PATH="$2"
Tom Finegan36c39d62014-04-03 13:16:58 -0700369 shift
370 ;;
371 --filter)
Yaowu Xuf883b422016-08-30 14:01:10 -0700372 AOM_TEST_FILTER="$2"
Tom Finegan36c39d62014-04-03 13:16:58 -0700373 shift
374 ;;
375 --run-disabled-tests)
Yaowu Xuf883b422016-08-30 14:01:10 -0700376 AOM_TEST_RUN_DISABLED_TESTS=yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700377 ;;
378 --help)
Yaowu Xuf883b422016-08-30 14:01:10 -0700379 aom_test_usage
Tom Finegan36c39d62014-04-03 13:16:58 -0700380 exit
381 ;;
382 --test-data-path)
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700383 LIBAOM_TEST_DATA_PATH="$2"
Tom Finegan36c39d62014-04-03 13:16:58 -0700384 shift
385 ;;
Tom Finegan926a6f62014-07-10 15:17:05 -0700386 --prefix)
Yaowu Xuf883b422016-08-30 14:01:10 -0700387 AOM_TEST_PREFIX="$2"
Tom Finegan926a6f62014-07-10 15:17:05 -0700388 shift
389 ;;
Tom Finegan36c39d62014-04-03 13:16:58 -0700390 --verbose)
Yaowu Xuf883b422016-08-30 14:01:10 -0700391 AOM_TEST_VERBOSE_OUTPUT=yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700392 ;;
Tom Finegan1d29ce52014-04-30 11:03:15 -0700393 --show-program-output)
394 devnull=
395 ;;
Tom Fineganf34d7282014-09-19 11:09:39 -0700396 --list-tests)
Yaowu Xuf883b422016-08-30 14:01:10 -0700397 AOM_TEST_LIST_TESTS=yes
Tom Fineganf34d7282014-09-19 11:09:39 -0700398 ;;
Tom Finegan36c39d62014-04-03 13:16:58 -0700399 *)
Yaowu Xuf883b422016-08-30 14:01:10 -0700400 aom_test_usage
Tom Finegan36c39d62014-04-03 13:16:58 -0700401 exit 1
402 ;;
403 esac
404 shift
405done
406
407# Handle running the tests from a build directory without arguments when running
408# the tests on *nix/macosx.
Yaowu Xuc27fc142016-08-22 16:08:15 -0700409LIBAOM_BIN_PATH="${LIBAOM_BIN_PATH:-.}"
410LIBAOM_CONFIG_PATH="${LIBAOM_CONFIG_PATH:-.}"
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700411LIBAOM_TEST_DATA_PATH="${LIBAOM_TEST_DATA_PATH:-.}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700412
413# Create a temporary directory for output files, and a trap to clean it up.
414if [ -n "${TMPDIR}" ]; then
Yaowu Xuf883b422016-08-30 14:01:10 -0700415 AOM_TEST_TEMP_ROOT="${TMPDIR}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700416elif [ -n "${TEMPDIR}" ]; then
Yaowu Xuf883b422016-08-30 14:01:10 -0700417 AOM_TEST_TEMP_ROOT="${TEMPDIR}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700418else
Yaowu Xuf883b422016-08-30 14:01:10 -0700419 AOM_TEST_TEMP_ROOT=/tmp
Tom Finegan36c39d62014-04-03 13:16:58 -0700420fi
421
Tom Finegan8ab44142018-04-27 14:57:52 -0700422AOM_TEST_OUTPUT_DIR="${AOM_TEST_OUTPUT_DIR:-${AOM_TEST_TEMP_ROOT}/aom_test_$$}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700423
Yaowu Xuf883b422016-08-30 14:01:10 -0700424if ! mkdir -p "${AOM_TEST_OUTPUT_DIR}" || \
425 [ ! -d "${AOM_TEST_OUTPUT_DIR}" ]; then
Tom Finegan36c39d62014-04-03 13:16:58 -0700426 echo "${0##*/}: Cannot create output directory, giving up."
Yaowu Xuf883b422016-08-30 14:01:10 -0700427 echo "${0##*/}: AOM_TEST_OUTPUT_DIR=${AOM_TEST_OUTPUT_DIR}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700428 exit 1
429fi
430
Tom Finegan8ab44142018-04-27 14:57:52 -0700431AOM_TEST_PRESERVE_OUTPUT=${AOM_TEST_PRESERVE_OUTPUT:-no}
432
Tom Finegan39c5a4b2014-04-22 19:36:40 -0700433if [ "$(is_windows_target)" = "yes" ]; then
Yaowu Xuf883b422016-08-30 14:01:10 -0700434 AOM_TEST_EXE_SUFFIX=".exe"
Tom Finegan39c5a4b2014-04-22 19:36:40 -0700435fi
436
Tom Finegan7da552c2014-04-23 17:18:56 -0700437# Variables shared by tests.
Tom Finegan8ab44142018-04-27 14:57:52 -0700438AV1_ENCODE_CPU_USED=${AV1_ENCODE_CPU_USED:-1}
439AV1_ENCODE_TEST_FRAME_LIMIT=${AV1_ENCODE_TEST_FRAME_LIMIT:-5}
440AV1_IVF_FILE="${AV1_IVF_FILE:-${AOM_TEST_OUTPUT_DIR}/av1.ivf}"
441AV1_OBU_ANNEXB_FILE="${AV1_OBU_ANNEXB_FILE:-${AOM_TEST_OUTPUT_DIR}/av1.annexb.obu}"
442AV1_OBU_SEC5_FILE="${AV1_OBU_SEC5_FILE:-${AOM_TEST_OUTPUT_DIR}/av1.section5.obu}"
443AV1_WEBM_FILE="${AV1_WEBM_FILE:-${AOM_TEST_OUTPUT_DIR}/av1.webm}"
Tom Finegan7da552c2014-04-23 17:18:56 -0700444
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700445YUV_RAW_INPUT="${LIBAOM_TEST_DATA_PATH}/hantro_collage_w352h288.yuv"
Tom Finegan7da552c2014-04-23 17:18:56 -0700446YUV_RAW_INPUT_WIDTH=352
447YUV_RAW_INPUT_HEIGHT=288
448
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700449Y4M_NOSQ_PAR_INPUT="${LIBAOM_TEST_DATA_PATH}/park_joy_90p_8_420_a10-1.y4m"
450Y4M_720P_INPUT="${LIBAOM_TEST_DATA_PATH}/niklas_1280_720_30.y4m"
Frank Galligan09acd262015-06-01 10:20:58 -0700451
Tom Finegan7da552c2014-04-23 17:18:56 -0700452# Setup a trap function to clean up after tests complete.
Tom Finegan36c39d62014-04-03 13:16:58 -0700453trap cleanup EXIT
454
Tom Fineganc5d962d2014-04-28 20:56:37 -0700455vlog "$(basename "${0%.*}") test configuration:
Yaowu Xuc27fc142016-08-22 16:08:15 -0700456 LIBAOM_BIN_PATH=${LIBAOM_BIN_PATH}
457 LIBAOM_CONFIG_PATH=${LIBAOM_CONFIG_PATH}
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700458 LIBAOM_TEST_DATA_PATH=${LIBAOM_TEST_DATA_PATH}
Yaowu Xuf883b422016-08-30 14:01:10 -0700459 AOM_TEST_EXE_SUFFIX=${AOM_TEST_EXE_SUFFIX}
460 AOM_TEST_FILTER=${AOM_TEST_FILTER}
461 AOM_TEST_LIST_TESTS=${AOM_TEST_LIST_TESTS}
462 AOM_TEST_OUTPUT_DIR=${AOM_TEST_OUTPUT_DIR}
463 AOM_TEST_PREFIX=${AOM_TEST_PREFIX}
Tom Finegan8ab44142018-04-27 14:57:52 -0700464 AOM_TEST_PRESERVE_OUTPUT=${AOM_TEST_PRESERVE_OUTPUT}
Yaowu Xuf883b422016-08-30 14:01:10 -0700465 AOM_TEST_RUN_DISABLED_TESTS=${AOM_TEST_RUN_DISABLED_TESTS}
466 AOM_TEST_SHOW_PROGRAM_OUTPUT=${AOM_TEST_SHOW_PROGRAM_OUTPUT}
467 AOM_TEST_TEMP_ROOT=${AOM_TEST_TEMP_ROOT}
468 AOM_TEST_VERBOSE_OUTPUT=${AOM_TEST_VERBOSE_OUTPUT}
Tom Finegan8ab44142018-04-27 14:57:52 -0700469 AV1_ENCODE_CPU_USED=${AV1_ENCODE_CPU_USED}
470 AV1_ENCODE_TEST_FRAME_LIMIT=${AV1_ENCODE_TEST_FRAME_LIMIT}
471 AV1_IVF_FILE=${AV1_IVF_FILE}
472 AV1_OBU_ANNEXB_FILE=${AV1_OBU_ANNEXB_FILE}
473 AV1_OBU_SEC5_FILE=${AV1_OBU_SEC5_FILE}
474 AV1_WEBM_FILE=${AV1_WEBM_FILE}
Tom Finegan1557d4b2014-06-13 11:18:43 -0700475 YUV_RAW_INPUT=${YUV_RAW_INPUT}
476 YUV_RAW_INPUT_WIDTH=${YUV_RAW_INPUT_WIDTH}
Frank Galligan09acd262015-06-01 10:20:58 -0700477 YUV_RAW_INPUT_HEIGHT=${YUV_RAW_INPUT_HEIGHT}
478 Y4M_NOSQ_PAR_INPUT=${Y4M_NOSQ_PAR_INPUT}"
Tom Finegan4e7e1f12014-04-28 17:16:05 -0700479
Yaowu Xuf883b422016-08-30 14:01:10 -0700480fi # End $AOM_TEST_TOOLS_COMMON_SH pseudo include guard.