blob: 7c4b5605599aa941e2934ae199e03a8c322ccd46 [file] [log] [blame]
Tom Finegan36c39d62014-04-03 13:16:58 -07001#!/bin/sh
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002## Copyright (c) 2016, Alliance for Open Media. All rights reserved
Tom Finegan36c39d62014-04-03 13:16:58 -07003##
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004## This source code is subject to the terms of the BSD 2 Clause License and
5## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6## was not distributed with this source code in the LICENSE file, you can
7## obtain it at www.aomedia.org/license/software. If the Alliance for Open
8## Media Patent License 1.0 was not distributed with this source code in the
9## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
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 Finegan9a74bb62018-02-15 14:59:40 -080020readonly AOM_ENCODE_TEST_FRAME_LIMIT=5
Tom Finegan36c39d62014-04-03 13:16:58 -070021
Tom Finegan12672c22014-06-16 10:57:00 -070022elog() {
23 echo "$@" 1>&2
24}
25
Tom Fineganc5d962d2014-04-28 20:56:37 -070026vlog() {
Yaowu Xuf883b422016-08-30 14:01:10 -070027 if [ "${AOM_TEST_VERBOSE_OUTPUT}" = "yes" ]; then
Tom Finegan7279d442014-05-08 12:06:08 -070028 echo "$@"
29 fi
Tom Fineganc5d962d2014-04-28 20:56:37 -070030}
31
Yaowu Xuf883b422016-08-30 14:01:10 -070032# Sets $AOM_TOOL_TEST to the name specified by positional parameter one.
Tom Finegan36c39d62014-04-03 13:16:58 -070033test_begin() {
Yaowu Xuf883b422016-08-30 14:01:10 -070034 AOM_TOOL_TEST="${1}"
Tom Finegan36c39d62014-04-03 13:16:58 -070035}
36
Yaowu Xuf883b422016-08-30 14:01:10 -070037# Clears the AOM_TOOL_TEST variable after confirming that $AOM_TOOL_TEST matches
Tom Finegan36c39d62014-04-03 13:16:58 -070038# positional parameter one.
39test_end() {
Yaowu Xuf883b422016-08-30 14:01:10 -070040 if [ "$1" != "${AOM_TOOL_TEST}" ]; then
Tom Finegan36c39d62014-04-03 13:16:58 -070041 echo "FAIL completed test mismatch!."
42 echo " completed test: ${1}"
Yaowu Xuf883b422016-08-30 14:01:10 -070043 echo " active test: ${AOM_TOOL_TEST}."
Tom Finegan36c39d62014-04-03 13:16:58 -070044 return 1
45 fi
Yaowu Xuf883b422016-08-30 14:01:10 -070046 AOM_TOOL_TEST='<unset>'
Tom Finegan36c39d62014-04-03 13:16:58 -070047}
48
49# Echoes the target configuration being tested.
50test_configuration_target() {
Yaowu Xuf883b422016-08-30 14:01:10 -070051 aom_config_mk="${LIBAOM_CONFIG_PATH}/config.mk"
Tom Finegan747cf982017-06-08 08:53:01 -070052 # TODO(tomfinegan): Remove the parts requiring config.mk when the configure
53 # script is removed from the repository.
54 if [ ! -f "${aom_config_mk}" ]; then
55 aom_config_c="${LIBAOM_CONFIG_PATH}/aom_config.c"
56 # Clean up the cfg pointer line from aom_config.c for easier re-use by
57 # someone examining a failure in the example tests.
58 # 1. Run grep on aom_config.c for cfg and limit the results to 1.
59 # 2. Split the line using ' = ' as separator.
60 # 3. Abuse sed to consume the leading " and trailing "; from the assignment
61 # to the cfg pointer.
62 cmake_config=$(awk -F ' = ' '/cfg/ { print $NF; exit }' "${aom_config_c}" \
63 | sed -e s/\"// -e s/\"\;//)
64 echo cmake generated via command: cmake path/to/aom ${cmake_config}
65 return
66 fi
Tom Finegan36c39d62014-04-03 13:16:58 -070067 # Find the TOOLCHAIN line, split it using ':=' as the field separator, and
68 # print the last field to get the value. Then pipe the value to tr to consume
69 # any leading/trailing spaces while allowing tr to echo the output to stdout.
Yaowu Xuf883b422016-08-30 14:01:10 -070070 awk -F ':=' '/TOOLCHAIN/ { print $NF }' "${aom_config_mk}" | tr -d ' '
Tom Finegan36c39d62014-04-03 13:16:58 -070071}
72
73# Trap function used for failure reports and tool output directory removal.
Yaowu Xuf883b422016-08-30 14:01:10 -070074# When the contents of $AOM_TOOL_TEST do not match the string '<unset>', reports
75# failure of test stored in $AOM_TOOL_TEST.
Tom Finegan36c39d62014-04-03 13:16:58 -070076cleanup() {
Yaowu Xuf883b422016-08-30 14:01:10 -070077 if [ -n "${AOM_TOOL_TEST}" ] && [ "${AOM_TOOL_TEST}" != '<unset>' ]; then
78 echo "FAIL: $AOM_TOOL_TEST"
Tom Finegan36c39d62014-04-03 13:16:58 -070079 fi
Yaowu Xuf883b422016-08-30 14:01:10 -070080 if [ -n "${AOM_TEST_OUTPUT_DIR}" ] && [ -d "${AOM_TEST_OUTPUT_DIR}" ]; then
81 rm -rf "${AOM_TEST_OUTPUT_DIR}"
Tom Finegan36c39d62014-04-03 13:16:58 -070082 fi
83}
84
Tom Finegan355e46d2018-03-06 18:47:58 -080085# Echoes the version string assigned to the VERSION_STRING_NOSP variable defined
86# in $LIBAOM_CONFIG_PATH/aom_version.h to stdout.
87cmake_version() {
88 aom_version_h="${LIBAOM_CONFIG_PATH}/aom_version.h"
Tom Finegan747cf982017-06-08 08:53:01 -070089
Tom Finegan355e46d2018-03-06 18:47:58 -080090 # Find VERSION_STRING_NOSP line, split it with '"' and print the next to last
91 # field to output the version string to stdout.
92 aom_version=$(awk -F \" '/VERSION_STRING_NOSP/ {print $(NF-1)}' \
93 "${aom_version_h}")
94 echo "v${aom_version}"
Tom Finegan36c39d62014-04-03 13:16:58 -070095}
96
Tom Finegan355e46d2018-03-06 18:47:58 -080097# Echoes current git version as reported by running 'git describe', or the
98# version used by the cmake build when git is unavailable.
99source_version() {
Tom Finegan36c39d62014-04-03 13:16:58 -0700100 if git --version > /dev/null 2>&1; then
101 (cd "$(dirname "${0}")"
Tom Finegan355e46d2018-03-06 18:47:58 -0800102 git describe)
Tom Finegan36c39d62014-04-03 13:16:58 -0700103 else
Tom Finegan355e46d2018-03-06 18:47:58 -0800104 cmake_version
Tom Finegan36c39d62014-04-03 13:16:58 -0700105 fi
106}
107
Tom Finegan355e46d2018-03-06 18:47:58 -0800108# Echoes warnings to stdout when source version and CMake build generated
109# version are out of sync.
110check_version_strings() {
111 cmake_version=$(cmake_version)
112 source_version=$(source_version)
Tom Finegan36c39d62014-04-03 13:16:58 -0700113
Tom Finegan355e46d2018-03-06 18:47:58 -0800114 if [ "${cmake_version}" != "${source_version}" ]; then
115 echo "Warning: version has changed since last cmake run."
116 vlog " cmake version: ${cmake_version} version now: ${source_version}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700117 fi
118}
119
James Zern2ebe0ae2015-02-26 12:57:30 -0800120# $1 is the name of an environment variable containing a directory name to
121# test.
122test_env_var_dir() {
123 local dir=$(eval echo "\${$1}")
124 if [ ! -d "${dir}" ]; then
125 elog "'${dir}': No such directory"
126 elog "The $1 environment variable must be set to a valid directory."
127 return 1
128 fi
129}
130
Yaowu Xuc27fc142016-08-22 16:08:15 -0700131# This script requires that the LIBAOM_BIN_PATH, LIBAOM_CONFIG_PATH, and
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700132# LIBAOM_TEST_DATA_PATH variables are in the environment: Confirm that
Tom Finegan36c39d62014-04-03 13:16:58 -0700133# the variables are set and that they all evaluate to directory paths.
Yaowu Xuf883b422016-08-30 14:01:10 -0700134verify_aom_test_environment() {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700135 test_env_var_dir "LIBAOM_BIN_PATH" \
136 && test_env_var_dir "LIBAOM_CONFIG_PATH" \
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700137 && test_env_var_dir "LIBAOM_TEST_DATA_PATH"
Tom Finegan36c39d62014-04-03 13:16:58 -0700138}
139
Yaowu Xuf883b422016-08-30 14:01:10 -0700140# Greps aom_config.h in LIBAOM_CONFIG_PATH for positional parameter one, which
Yaowu Xuc27fc142016-08-22 16:08:15 -0700141# should be a LIBAOM preprocessor flag. Echoes yes to stdout when the feature
Tom Finegan36c39d62014-04-03 13:16:58 -0700142# is available.
Yaowu Xuf883b422016-08-30 14:01:10 -0700143aom_config_option_enabled() {
144 aom_config_option="${1}"
145 aom_config_file="${LIBAOM_CONFIG_PATH}/aom_config.h"
146 config_line=$(grep "${aom_config_option}" "${aom_config_file}")
Tom Finegan36c39d62014-04-03 13:16:58 -0700147 if echo "${config_line}" | egrep -q '1$'; then
148 echo yes
149 fi
150}
151
152# Echoes yes when output of test_configuration_target() contains win32 or win64.
153is_windows_target() {
154 if test_configuration_target \
155 | grep -q -e win32 -e win64 > /dev/null 2>&1; then
156 echo yes
157 fi
158}
159
Tom Finegancd41a512018-02-16 15:58:48 -0800160# Echoes path to $1 when it's executable and exists in one of the directories
161# included in $tool_paths, or an empty string. Caller is responsible for testing
162# the string once the function returns.
Yaowu Xuf883b422016-08-30 14:01:10 -0700163aom_tool_path() {
Tom Finegan4d91e162014-08-15 11:31:30 -0700164 local readonly tool_name="$1"
Tom Finegancd41a512018-02-16 15:58:48 -0800165 local readonly root_path="${LIBAOM_BIN_PATH}"
166 local readonly suffix="${AOM_TEST_EXE_SUFFIX}"
167 local readonly tool_paths="\
168 ${root_path}/${tool_name}${suffix} \
169 ${root_path}/../${tool_name}${suffix} \
170 ${root_path}/tools/${tool_name}${suffix} \
171 ${root_path}/../tools/${tool_name}${suffix}"
Tom Finegan4d91e162014-08-15 11:31:30 -0700172
Tom Finegancd41a512018-02-16 15:58:48 -0800173 local toolpath=""
174
175 for tool_path in ${tool_paths}; do
176 if [ -x "${tool_path}" ] && [ -f "${tool_path}" ]; then
177 echo "${tool_path}"
178 return 0
179 fi
180 done
181
182 return 1
Tom Finegan4d91e162014-08-15 11:31:30 -0700183}
184
Tom Finegan36c39d62014-04-03 13:16:58 -0700185# Echoes yes to stdout when the file named by positional parameter one exists
Yaowu Xuc27fc142016-08-22 16:08:15 -0700186# in LIBAOM_BIN_PATH, and is executable.
Yaowu Xuf883b422016-08-30 14:01:10 -0700187aom_tool_available() {
Tom Finegan39c5a4b2014-04-22 19:36:40 -0700188 local tool_name="$1"
Yaowu Xuf883b422016-08-30 14:01:10 -0700189 local tool="${LIBAOM_BIN_PATH}/${tool_name}${AOM_TEST_EXE_SUFFIX}"
Tom Finegan39c5a4b2014-04-22 19:36:40 -0700190 [ -x "${tool}" ] && echo yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700191}
192
Yaowu Xuf883b422016-08-30 14:01:10 -0700193# Echoes yes to stdout when aom_config_option_enabled() reports yes for
194# CONFIG_AV1_DECODER.
195av1_decode_available() {
196 [ "$(aom_config_option_enabled CONFIG_AV1_DECODER)" = "yes" ] && echo yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700197}
198
Yaowu Xuf883b422016-08-30 14:01:10 -0700199# Echoes yes to stdout when aom_config_option_enabled() reports yes for
200# CONFIG_AV1_ENCODER.
201av1_encode_available() {
202 [ "$(aom_config_option_enabled CONFIG_AV1_ENCODER)" = "yes" ] && echo yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700203}
204
Tom Finegan9a74bb62018-02-15 14:59:40 -0800205# Echoes "fast" encode params for use with aomenc.
206aomenc_encode_test_fast_params() {
207 echo "--cpu-used=1
208 --limit=${AOM_ENCODE_TEST_FRAME_LIMIT}
209 --lag-in-frames=0
210 --test-decode=fatal"
211}
212
Yaowu Xuf883b422016-08-30 14:01:10 -0700213# Echoes yes to stdout when aom_config_option_enabled() reports yes for
Tom Finegan36c39d62014-04-03 13:16:58 -0700214# CONFIG_WEBM_IO.
215webm_io_available() {
Yaowu Xuf883b422016-08-30 14:01:10 -0700216 [ "$(aom_config_option_enabled CONFIG_WEBM_IO)" = "yes" ] && echo yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700217}
218
Tom Fineganf34d7282014-09-19 11:09:39 -0700219# Filters strings from $1 using the filter specified by $2. Filter behavior
220# depends on the presence of $3. When $3 is present, strings that match the
221# filter are excluded. When $3 is omitted, strings matching the filter are
222# included.
223# The filtered result is echoed to stdout.
Tom Finegan36c39d62014-04-03 13:16:58 -0700224filter_strings() {
225 strings=${1}
226 filter=${2}
227 exclude=${3}
228
229 if [ -n "${exclude}" ]; then
230 # When positional parameter three exists the caller wants to remove strings.
231 # Tell grep to invert matches using the -v argument.
232 exclude='-v'
233 else
234 unset exclude
235 fi
236
237 if [ -n "${filter}" ]; then
238 for s in ${strings}; do
239 if echo "${s}" | egrep -q ${exclude} "${filter}" > /dev/null 2>&1; then
240 filtered_strings="${filtered_strings} ${s}"
241 fi
242 done
243 else
244 filtered_strings="${strings}"
245 fi
246 echo "${filtered_strings}"
247}
248
249# Runs user test functions passed via positional parameters one and two.
250# Functions in positional parameter one are treated as environment verification
251# functions and are run unconditionally. Functions in positional parameter two
Yaowu Xuf883b422016-08-30 14:01:10 -0700252# are run according to the rules specified in aom_test_usage().
Tom Finegan36c39d62014-04-03 13:16:58 -0700253run_tests() {
Yaowu Xuf883b422016-08-30 14:01:10 -0700254 local env_tests="verify_aom_test_environment $1"
Tom Finegan3d38cf92014-05-15 15:31:02 -0700255 local tests_to_filter="$2"
Yaowu Xuf883b422016-08-30 14:01:10 -0700256 local test_name="${AOM_TEST_NAME}"
Tom Finegan3d38cf92014-05-15 15:31:02 -0700257
258 if [ -z "${test_name}" ]; then
James Zern81880962014-05-21 19:54:48 -0700259 test_name="$(basename "${0%.*}")"
Tom Finegan3d38cf92014-05-15 15:31:02 -0700260 fi
Tom Finegan36c39d62014-04-03 13:16:58 -0700261
Yaowu Xuf883b422016-08-30 14:01:10 -0700262 if [ "${AOM_TEST_RUN_DISABLED_TESTS}" != "yes" ]; then
Tom Finegan36c39d62014-04-03 13:16:58 -0700263 # Filter out DISABLED tests.
264 tests_to_filter=$(filter_strings "${tests_to_filter}" ^DISABLED exclude)
265 fi
266
Yaowu Xuf883b422016-08-30 14:01:10 -0700267 if [ -n "${AOM_TEST_FILTER}" ]; then
Tom Finegan36c39d62014-04-03 13:16:58 -0700268 # Remove tests not matching the user's filter.
Yaowu Xuf883b422016-08-30 14:01:10 -0700269 tests_to_filter=$(filter_strings "${tests_to_filter}" ${AOM_TEST_FILTER})
Tom Finegan36c39d62014-04-03 13:16:58 -0700270 fi
271
Tom Fineganf34d7282014-09-19 11:09:39 -0700272 # User requested test listing: Dump test names and return.
Yaowu Xuf883b422016-08-30 14:01:10 -0700273 if [ "${AOM_TEST_LIST_TESTS}" = "yes" ]; then
Tom Fineganf34d7282014-09-19 11:09:39 -0700274 for test_name in $tests_to_filter; do
275 echo ${test_name}
276 done
277 return
278 fi
279
James Zern84eca072014-12-17 19:02:00 -0800280 # Don't bother with the environment tests if everything else was disabled.
281 [ -z "${tests_to_filter}" ] && return
282
Tom Fineganf34d7282014-09-19 11:09:39 -0700283 # Combine environment and actual tests.
Tom Finegan3d38cf92014-05-15 15:31:02 -0700284 local tests_to_run="${env_tests} ${tests_to_filter}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700285
Tom Finegan355e46d2018-03-06 18:47:58 -0800286 check_version_strings
Tom Finegan36c39d62014-04-03 13:16:58 -0700287
288 # Run tests.
289 for test in ${tests_to_run}; do
290 test_begin "${test}"
Tom Fineganc5d962d2014-04-28 20:56:37 -0700291 vlog " RUN ${test}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700292 "${test}"
Tom Fineganc5d962d2014-04-28 20:56:37 -0700293 vlog " PASS ${test}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700294 test_end "${test}"
295 done
296
Tom Finegan355e46d2018-03-06 18:47:58 -0800297 local tested_config="$(test_configuration_target) @ $(source_version)"
Tom Finegan3d38cf92014-05-15 15:31:02 -0700298 echo "${test_name}: Done, all tests pass for ${tested_config}."
Tom Finegan36c39d62014-04-03 13:16:58 -0700299}
300
Yaowu Xuf883b422016-08-30 14:01:10 -0700301aom_test_usage() {
Tom Finegan36c39d62014-04-03 13:16:58 -0700302cat << EOF
303 Usage: ${0##*/} [arguments]
Yaowu Xuc27fc142016-08-22 16:08:15 -0700304 --bin-path <path to libaom binaries directory>
305 --config-path <path to libaom config directory>
Tom Finegan36c39d62014-04-03 13:16:58 -0700306 --filter <filter>: User test filter. Only tests matching filter are run.
307 --run-disabled-tests: Run disabled tests.
308 --help: Display this message and exit.
Yaowu Xuc27fc142016-08-22 16:08:15 -0700309 --test-data-path <path to libaom test data directory>
Tom Finegan1d29ce52014-04-30 11:03:15 -0700310 --show-program-output: Shows output from all programs being tested.
Tom Finegan926a6f62014-07-10 15:17:05 -0700311 --prefix: Allows for a user specified prefix to be inserted before all test
312 programs. Grants the ability, for example, to run test programs
313 within valgrind.
Tom Fineganf34d7282014-09-19 11:09:39 -0700314 --list-tests: List all test names and exit without actually running tests.
Tom Finegan36c39d62014-04-03 13:16:58 -0700315 --verbose: Verbose output.
316
317 When the --bin-path option is not specified the script attempts to use
Yaowu Xuc27fc142016-08-22 16:08:15 -0700318 \$LIBAOM_BIN_PATH and then the current directory.
Tom Finegan36c39d62014-04-03 13:16:58 -0700319
320 When the --config-path option is not specified the script attempts to use
Yaowu Xuc27fc142016-08-22 16:08:15 -0700321 \$LIBAOM_CONFIG_PATH and then the current directory.
Tom Finegan36c39d62014-04-03 13:16:58 -0700322
323 When the -test-data-path option is not specified the script attempts to use
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700324 \$LIBAOM_TEST_DATA_PATH and then the current directory.
Tom Finegan36c39d62014-04-03 13:16:58 -0700325EOF
326}
327
328# Returns non-zero (failure) when required environment variables are empty
329# strings.
Yaowu Xuf883b422016-08-30 14:01:10 -0700330aom_test_check_environment() {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700331 if [ -z "${LIBAOM_BIN_PATH}" ] || \
332 [ -z "${LIBAOM_CONFIG_PATH}" ] || \
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700333 [ -z "${LIBAOM_TEST_DATA_PATH}" ]; then
Tom Finegan36c39d62014-04-03 13:16:58 -0700334 return 1
335 fi
336}
337
Jim Bankoskie78a9642016-05-25 07:02:19 -0700338# Echo aomenc command line parameters allowing use of a raw yuv file as
339# input to aomenc.
340yuv_raw_input() {
341 echo ""${YUV_RAW_INPUT}"
342 --width="${YUV_RAW_INPUT_WIDTH}"
343 --height="${YUV_RAW_INPUT_HEIGHT}""
344}
345
346# Do a small encode for testing decoders.
347encode_yuv_raw_input_av1() {
348 if [ "$(av1_encode_available)" = "yes" ]; then
349 local readonly output="$1"
350 local readonly encoder="$(aom_tool_path aomenc)"
Jim Bankoskif7f04372016-05-27 14:31:29 -0700351 shift
Jim Bankoskie78a9642016-05-25 07:02:19 -0700352 eval "${encoder}" $(yuv_raw_input) \
353 --codec=av1 \
Jim Bankoskif7f04372016-05-27 14:31:29 -0700354 $@ \
Jim Bankoskie78a9642016-05-25 07:02:19 -0700355 --limit=5 \
356 --output="${output}" \
357 ${devnull}
358
359 if [ ! -e "${output}" ]; then
360 elog "Output file does not exist."
361 return 1
362 fi
363 fi
364}
365
Tom Finegan36c39d62014-04-03 13:16:58 -0700366# Parse the command line.
367while [ -n "$1" ]; do
368 case "$1" in
369 --bin-path)
Yaowu Xuc27fc142016-08-22 16:08:15 -0700370 LIBAOM_BIN_PATH="$2"
Tom Finegan36c39d62014-04-03 13:16:58 -0700371 shift
372 ;;
373 --config-path)
Yaowu Xuc27fc142016-08-22 16:08:15 -0700374 LIBAOM_CONFIG_PATH="$2"
Tom Finegan36c39d62014-04-03 13:16:58 -0700375 shift
376 ;;
377 --filter)
Yaowu Xuf883b422016-08-30 14:01:10 -0700378 AOM_TEST_FILTER="$2"
Tom Finegan36c39d62014-04-03 13:16:58 -0700379 shift
380 ;;
381 --run-disabled-tests)
Yaowu Xuf883b422016-08-30 14:01:10 -0700382 AOM_TEST_RUN_DISABLED_TESTS=yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700383 ;;
384 --help)
Yaowu Xuf883b422016-08-30 14:01:10 -0700385 aom_test_usage
Tom Finegan36c39d62014-04-03 13:16:58 -0700386 exit
387 ;;
388 --test-data-path)
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700389 LIBAOM_TEST_DATA_PATH="$2"
Tom Finegan36c39d62014-04-03 13:16:58 -0700390 shift
391 ;;
Tom Finegan926a6f62014-07-10 15:17:05 -0700392 --prefix)
Yaowu Xuf883b422016-08-30 14:01:10 -0700393 AOM_TEST_PREFIX="$2"
Tom Finegan926a6f62014-07-10 15:17:05 -0700394 shift
395 ;;
Tom Finegan36c39d62014-04-03 13:16:58 -0700396 --verbose)
Yaowu Xuf883b422016-08-30 14:01:10 -0700397 AOM_TEST_VERBOSE_OUTPUT=yes
Tom Finegan36c39d62014-04-03 13:16:58 -0700398 ;;
Tom Finegan1d29ce52014-04-30 11:03:15 -0700399 --show-program-output)
400 devnull=
401 ;;
Tom Fineganf34d7282014-09-19 11:09:39 -0700402 --list-tests)
Yaowu Xuf883b422016-08-30 14:01:10 -0700403 AOM_TEST_LIST_TESTS=yes
Tom Fineganf34d7282014-09-19 11:09:39 -0700404 ;;
Tom Finegan36c39d62014-04-03 13:16:58 -0700405 *)
Yaowu Xuf883b422016-08-30 14:01:10 -0700406 aom_test_usage
Tom Finegan36c39d62014-04-03 13:16:58 -0700407 exit 1
408 ;;
409 esac
410 shift
411done
412
413# Handle running the tests from a build directory without arguments when running
414# the tests on *nix/macosx.
Yaowu Xuc27fc142016-08-22 16:08:15 -0700415LIBAOM_BIN_PATH="${LIBAOM_BIN_PATH:-.}"
416LIBAOM_CONFIG_PATH="${LIBAOM_CONFIG_PATH:-.}"
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700417LIBAOM_TEST_DATA_PATH="${LIBAOM_TEST_DATA_PATH:-.}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700418
419# Create a temporary directory for output files, and a trap to clean it up.
420if [ -n "${TMPDIR}" ]; then
Yaowu Xuf883b422016-08-30 14:01:10 -0700421 AOM_TEST_TEMP_ROOT="${TMPDIR}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700422elif [ -n "${TEMPDIR}" ]; then
Yaowu Xuf883b422016-08-30 14:01:10 -0700423 AOM_TEST_TEMP_ROOT="${TEMPDIR}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700424else
Yaowu Xuf883b422016-08-30 14:01:10 -0700425 AOM_TEST_TEMP_ROOT=/tmp
Tom Finegan36c39d62014-04-03 13:16:58 -0700426fi
427
Yaowu Xuf883b422016-08-30 14:01:10 -0700428AOM_TEST_OUTPUT_DIR="${AOM_TEST_TEMP_ROOT}/aom_test_$$"
Tom Finegan36c39d62014-04-03 13:16:58 -0700429
Yaowu Xuf883b422016-08-30 14:01:10 -0700430if ! mkdir -p "${AOM_TEST_OUTPUT_DIR}" || \
431 [ ! -d "${AOM_TEST_OUTPUT_DIR}" ]; then
Tom Finegan36c39d62014-04-03 13:16:58 -0700432 echo "${0##*/}: Cannot create output directory, giving up."
Yaowu Xuf883b422016-08-30 14:01:10 -0700433 echo "${0##*/}: AOM_TEST_OUTPUT_DIR=${AOM_TEST_OUTPUT_DIR}"
Tom Finegan36c39d62014-04-03 13:16:58 -0700434 exit 1
435fi
436
Tom Finegan39c5a4b2014-04-22 19:36:40 -0700437if [ "$(is_windows_target)" = "yes" ]; then
Yaowu Xuf883b422016-08-30 14:01:10 -0700438 AOM_TEST_EXE_SUFFIX=".exe"
Tom Finegan39c5a4b2014-04-22 19:36:40 -0700439fi
440
Tom Finegan7da552c2014-04-23 17:18:56 -0700441# Variables shared by tests.
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700442VP8_IVF_FILE="${LIBAOM_TEST_DATA_PATH}/vp80-00-comprehensive-001.ivf"
Johann472cd032017-10-19 10:06:26 -0700443AV1_IVF_FILE=""
Tom Finegan7da552c2014-04-23 17:18:56 -0700444
Johann472cd032017-10-19 10:06:26 -0700445AV1_WEBM_FILE=""
446AV1_FPM_WEBM_FILE=""
447AV1_LT_50_FRAMES_WEBM_FILE=""
Tom Finegan7da552c2014-04-23 17:18:56 -0700448
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700449YUV_RAW_INPUT="${LIBAOM_TEST_DATA_PATH}/hantro_collage_w352h288.yuv"
Tom Finegan7da552c2014-04-23 17:18:56 -0700450YUV_RAW_INPUT_WIDTH=352
451YUV_RAW_INPUT_HEIGHT=288
452
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700453Y4M_NOSQ_PAR_INPUT="${LIBAOM_TEST_DATA_PATH}/park_joy_90p_8_420_a10-1.y4m"
454Y4M_720P_INPUT="${LIBAOM_TEST_DATA_PATH}/niklas_1280_720_30.y4m"
Frank Galligan09acd262015-06-01 10:20:58 -0700455
Tom Finegan7da552c2014-04-23 17:18:56 -0700456# Setup a trap function to clean up after tests complete.
Tom Finegan36c39d62014-04-03 13:16:58 -0700457trap cleanup EXIT
458
Tom Fineganc5d962d2014-04-28 20:56:37 -0700459vlog "$(basename "${0%.*}") test configuration:
Yaowu Xuc27fc142016-08-22 16:08:15 -0700460 LIBAOM_BIN_PATH=${LIBAOM_BIN_PATH}
461 LIBAOM_CONFIG_PATH=${LIBAOM_CONFIG_PATH}
Yaowu Xu97aa09f2016-10-12 08:25:39 -0700462 LIBAOM_TEST_DATA_PATH=${LIBAOM_TEST_DATA_PATH}
Yaowu Xuf883b422016-08-30 14:01:10 -0700463 AOM_IVF_FILE=${AOM_IVF_FILE}
464 AV1_IVF_FILE=${AV1_IVF_FILE}
465 AV1_WEBM_FILE=${AV1_WEBM_FILE}
466 AOM_TEST_EXE_SUFFIX=${AOM_TEST_EXE_SUFFIX}
467 AOM_TEST_FILTER=${AOM_TEST_FILTER}
468 AOM_TEST_LIST_TESTS=${AOM_TEST_LIST_TESTS}
469 AOM_TEST_OUTPUT_DIR=${AOM_TEST_OUTPUT_DIR}
470 AOM_TEST_PREFIX=${AOM_TEST_PREFIX}
471 AOM_TEST_RUN_DISABLED_TESTS=${AOM_TEST_RUN_DISABLED_TESTS}
472 AOM_TEST_SHOW_PROGRAM_OUTPUT=${AOM_TEST_SHOW_PROGRAM_OUTPUT}
473 AOM_TEST_TEMP_ROOT=${AOM_TEST_TEMP_ROOT}
474 AOM_TEST_VERBOSE_OUTPUT=${AOM_TEST_VERBOSE_OUTPUT}
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.