Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 1 | #!/bin/sh |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | ## Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 3 | ## |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 4 | ## 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 Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 10 | ## |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 11 | ## This file contains shell code shared by test scripts for libaom tools. |
Tom Finegan | 4e7e1f1 | 2014-04-28 17:16:05 -0700 | [diff] [blame] | 12 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 13 | # Use $AOM_TEST_TOOLS_COMMON_SH as a pseudo include guard. |
| 14 | if [ -z "${AOM_TEST_TOOLS_COMMON_SH}" ]; then |
| 15 | AOM_TEST_TOOLS_COMMON_SH=included |
Tom Finegan | 4e7e1f1 | 2014-04-28 17:16:05 -0700 | [diff] [blame] | 16 | |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 17 | set -e |
Tom Finegan | 1d29ce5 | 2014-04-30 11:03:15 -0700 | [diff] [blame] | 18 | devnull='> /dev/null 2>&1' |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 19 | AOM_TEST_PREFIX="" |
Tom Finegan | 9a74bb6 | 2018-02-15 14:59:40 -0800 | [diff] [blame] | 20 | readonly AOM_ENCODE_TEST_FRAME_LIMIT=5 |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 21 | |
Tom Finegan | 12672c2 | 2014-06-16 10:57:00 -0700 | [diff] [blame] | 22 | elog() { |
| 23 | echo "$@" 1>&2 |
| 24 | } |
| 25 | |
Tom Finegan | c5d962d | 2014-04-28 20:56:37 -0700 | [diff] [blame] | 26 | vlog() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 27 | if [ "${AOM_TEST_VERBOSE_OUTPUT}" = "yes" ]; then |
Tom Finegan | 7279d44 | 2014-05-08 12:06:08 -0700 | [diff] [blame] | 28 | echo "$@" |
| 29 | fi |
Tom Finegan | c5d962d | 2014-04-28 20:56:37 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 32 | # Sets $AOM_TOOL_TEST to the name specified by positional parameter one. |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 33 | test_begin() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 34 | AOM_TOOL_TEST="${1}" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 35 | } |
| 36 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 37 | # Clears the AOM_TOOL_TEST variable after confirming that $AOM_TOOL_TEST matches |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 38 | # positional parameter one. |
| 39 | test_end() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 40 | if [ "$1" != "${AOM_TOOL_TEST}" ]; then |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 41 | echo "FAIL completed test mismatch!." |
| 42 | echo " completed test: ${1}" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 43 | echo " active test: ${AOM_TOOL_TEST}." |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 44 | return 1 |
| 45 | fi |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 46 | AOM_TOOL_TEST='<unset>' |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | # Echoes the target configuration being tested. |
| 50 | test_configuration_target() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 51 | aom_config_mk="${LIBAOM_CONFIG_PATH}/config.mk" |
Tom Finegan | 747cf98 | 2017-06-08 08:53:01 -0700 | [diff] [blame] | 52 | # 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 Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 67 | # 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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 70 | awk -F ':=' '/TOOLCHAIN/ { print $NF }' "${aom_config_mk}" | tr -d ' ' |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | # Trap function used for failure reports and tool output directory removal. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 74 | # When the contents of $AOM_TOOL_TEST do not match the string '<unset>', reports |
| 75 | # failure of test stored in $AOM_TOOL_TEST. |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 76 | cleanup() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 77 | if [ -n "${AOM_TOOL_TEST}" ] && [ "${AOM_TOOL_TEST}" != '<unset>' ]; then |
| 78 | echo "FAIL: $AOM_TOOL_TEST" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 79 | fi |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 80 | if [ -n "${AOM_TEST_OUTPUT_DIR}" ] && [ -d "${AOM_TEST_OUTPUT_DIR}" ]; then |
| 81 | rm -rf "${AOM_TEST_OUTPUT_DIR}" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 82 | fi |
| 83 | } |
| 84 | |
Tom Finegan | 355e46d | 2018-03-06 18:47:58 -0800 | [diff] [blame] | 85 | # Echoes the version string assigned to the VERSION_STRING_NOSP variable defined |
| 86 | # in $LIBAOM_CONFIG_PATH/aom_version.h to stdout. |
| 87 | cmake_version() { |
| 88 | aom_version_h="${LIBAOM_CONFIG_PATH}/aom_version.h" |
Tom Finegan | 747cf98 | 2017-06-08 08:53:01 -0700 | [diff] [blame] | 89 | |
Tom Finegan | 355e46d | 2018-03-06 18:47:58 -0800 | [diff] [blame] | 90 | # 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 Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Tom Finegan | 355e46d | 2018-03-06 18:47:58 -0800 | [diff] [blame] | 97 | # Echoes current git version as reported by running 'git describe', or the |
| 98 | # version used by the cmake build when git is unavailable. |
| 99 | source_version() { |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 100 | if git --version > /dev/null 2>&1; then |
| 101 | (cd "$(dirname "${0}")" |
Tom Finegan | 355e46d | 2018-03-06 18:47:58 -0800 | [diff] [blame] | 102 | git describe) |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 103 | else |
Tom Finegan | 355e46d | 2018-03-06 18:47:58 -0800 | [diff] [blame] | 104 | cmake_version |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 105 | fi |
| 106 | } |
| 107 | |
Tom Finegan | 355e46d | 2018-03-06 18:47:58 -0800 | [diff] [blame] | 108 | # Echoes warnings to stdout when source version and CMake build generated |
| 109 | # version are out of sync. |
| 110 | check_version_strings() { |
| 111 | cmake_version=$(cmake_version) |
| 112 | source_version=$(source_version) |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 113 | |
Tom Finegan | 355e46d | 2018-03-06 18:47:58 -0800 | [diff] [blame] | 114 | 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 Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 117 | fi |
| 118 | } |
| 119 | |
James Zern | 2ebe0ae | 2015-02-26 12:57:30 -0800 | [diff] [blame] | 120 | # $1 is the name of an environment variable containing a directory name to |
| 121 | # test. |
| 122 | test_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 Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 131 | # This script requires that the LIBAOM_BIN_PATH, LIBAOM_CONFIG_PATH, and |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 132 | # LIBAOM_TEST_DATA_PATH variables are in the environment: Confirm that |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 133 | # the variables are set and that they all evaluate to directory paths. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 134 | verify_aom_test_environment() { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 135 | test_env_var_dir "LIBAOM_BIN_PATH" \ |
| 136 | && test_env_var_dir "LIBAOM_CONFIG_PATH" \ |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 137 | && test_env_var_dir "LIBAOM_TEST_DATA_PATH" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 140 | # Greps aom_config.h in LIBAOM_CONFIG_PATH for positional parameter one, which |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 141 | # should be a LIBAOM preprocessor flag. Echoes yes to stdout when the feature |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 142 | # is available. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 143 | aom_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 Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 147 | 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. |
| 153 | is_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 Finegan | cd41a51 | 2018-02-16 15:58:48 -0800 | [diff] [blame] | 160 | # 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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 163 | aom_tool_path() { |
Tom Finegan | 4d91e16 | 2014-08-15 11:31:30 -0700 | [diff] [blame] | 164 | local readonly tool_name="$1" |
Tom Finegan | cd41a51 | 2018-02-16 15:58:48 -0800 | [diff] [blame] | 165 | 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 Finegan | 4d91e16 | 2014-08-15 11:31:30 -0700 | [diff] [blame] | 172 | |
Tom Finegan | cd41a51 | 2018-02-16 15:58:48 -0800 | [diff] [blame] | 173 | 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 Finegan | 4d91e16 | 2014-08-15 11:31:30 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 185 | # Echoes yes to stdout when the file named by positional parameter one exists |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 186 | # in LIBAOM_BIN_PATH, and is executable. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 187 | aom_tool_available() { |
Tom Finegan | 39c5a4b | 2014-04-22 19:36:40 -0700 | [diff] [blame] | 188 | local tool_name="$1" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 189 | local tool="${LIBAOM_BIN_PATH}/${tool_name}${AOM_TEST_EXE_SUFFIX}" |
Tom Finegan | 39c5a4b | 2014-04-22 19:36:40 -0700 | [diff] [blame] | 190 | [ -x "${tool}" ] && echo yes |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 193 | # Echoes yes to stdout when aom_config_option_enabled() reports yes for |
| 194 | # CONFIG_AV1_DECODER. |
| 195 | av1_decode_available() { |
| 196 | [ "$(aom_config_option_enabled CONFIG_AV1_DECODER)" = "yes" ] && echo yes |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 199 | # Echoes yes to stdout when aom_config_option_enabled() reports yes for |
| 200 | # CONFIG_AV1_ENCODER. |
| 201 | av1_encode_available() { |
| 202 | [ "$(aom_config_option_enabled CONFIG_AV1_ENCODER)" = "yes" ] && echo yes |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 203 | } |
| 204 | |
Tom Finegan | 9a74bb6 | 2018-02-15 14:59:40 -0800 | [diff] [blame] | 205 | # Echoes "fast" encode params for use with aomenc. |
| 206 | aomenc_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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 213 | # Echoes yes to stdout when aom_config_option_enabled() reports yes for |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 214 | # CONFIG_WEBM_IO. |
| 215 | webm_io_available() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 216 | [ "$(aom_config_option_enabled CONFIG_WEBM_IO)" = "yes" ] && echo yes |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 217 | } |
| 218 | |
Tom Finegan | f34d728 | 2014-09-19 11:09:39 -0700 | [diff] [blame] | 219 | # 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 Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 224 | filter_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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 252 | # are run according to the rules specified in aom_test_usage(). |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 253 | run_tests() { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 254 | local env_tests="verify_aom_test_environment $1" |
Tom Finegan | 3d38cf9 | 2014-05-15 15:31:02 -0700 | [diff] [blame] | 255 | local tests_to_filter="$2" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 256 | local test_name="${AOM_TEST_NAME}" |
Tom Finegan | 3d38cf9 | 2014-05-15 15:31:02 -0700 | [diff] [blame] | 257 | |
| 258 | if [ -z "${test_name}" ]; then |
James Zern | 8188096 | 2014-05-21 19:54:48 -0700 | [diff] [blame] | 259 | test_name="$(basename "${0%.*}")" |
Tom Finegan | 3d38cf9 | 2014-05-15 15:31:02 -0700 | [diff] [blame] | 260 | fi |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 261 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 262 | if [ "${AOM_TEST_RUN_DISABLED_TESTS}" != "yes" ]; then |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 263 | # Filter out DISABLED tests. |
| 264 | tests_to_filter=$(filter_strings "${tests_to_filter}" ^DISABLED exclude) |
| 265 | fi |
| 266 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 267 | if [ -n "${AOM_TEST_FILTER}" ]; then |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 268 | # Remove tests not matching the user's filter. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 269 | tests_to_filter=$(filter_strings "${tests_to_filter}" ${AOM_TEST_FILTER}) |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 270 | fi |
| 271 | |
Tom Finegan | f34d728 | 2014-09-19 11:09:39 -0700 | [diff] [blame] | 272 | # User requested test listing: Dump test names and return. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 273 | if [ "${AOM_TEST_LIST_TESTS}" = "yes" ]; then |
Tom Finegan | f34d728 | 2014-09-19 11:09:39 -0700 | [diff] [blame] | 274 | for test_name in $tests_to_filter; do |
| 275 | echo ${test_name} |
| 276 | done |
| 277 | return |
| 278 | fi |
| 279 | |
James Zern | 84eca07 | 2014-12-17 19:02:00 -0800 | [diff] [blame] | 280 | # Don't bother with the environment tests if everything else was disabled. |
| 281 | [ -z "${tests_to_filter}" ] && return |
| 282 | |
Tom Finegan | f34d728 | 2014-09-19 11:09:39 -0700 | [diff] [blame] | 283 | # Combine environment and actual tests. |
Tom Finegan | 3d38cf9 | 2014-05-15 15:31:02 -0700 | [diff] [blame] | 284 | local tests_to_run="${env_tests} ${tests_to_filter}" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 285 | |
Tom Finegan | 355e46d | 2018-03-06 18:47:58 -0800 | [diff] [blame] | 286 | check_version_strings |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 287 | |
| 288 | # Run tests. |
| 289 | for test in ${tests_to_run}; do |
| 290 | test_begin "${test}" |
Tom Finegan | c5d962d | 2014-04-28 20:56:37 -0700 | [diff] [blame] | 291 | vlog " RUN ${test}" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 292 | "${test}" |
Tom Finegan | c5d962d | 2014-04-28 20:56:37 -0700 | [diff] [blame] | 293 | vlog " PASS ${test}" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 294 | test_end "${test}" |
| 295 | done |
| 296 | |
Tom Finegan | 355e46d | 2018-03-06 18:47:58 -0800 | [diff] [blame] | 297 | local tested_config="$(test_configuration_target) @ $(source_version)" |
Tom Finegan | 3d38cf9 | 2014-05-15 15:31:02 -0700 | [diff] [blame] | 298 | echo "${test_name}: Done, all tests pass for ${tested_config}." |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 301 | aom_test_usage() { |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 302 | cat << EOF |
| 303 | Usage: ${0##*/} [arguments] |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 304 | --bin-path <path to libaom binaries directory> |
| 305 | --config-path <path to libaom config directory> |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 306 | --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 Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 309 | --test-data-path <path to libaom test data directory> |
Tom Finegan | 1d29ce5 | 2014-04-30 11:03:15 -0700 | [diff] [blame] | 310 | --show-program-output: Shows output from all programs being tested. |
Tom Finegan | 926a6f6 | 2014-07-10 15:17:05 -0700 | [diff] [blame] | 311 | --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 Finegan | f34d728 | 2014-09-19 11:09:39 -0700 | [diff] [blame] | 314 | --list-tests: List all test names and exit without actually running tests. |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 315 | --verbose: Verbose output. |
| 316 | |
| 317 | When the --bin-path option is not specified the script attempts to use |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 318 | \$LIBAOM_BIN_PATH and then the current directory. |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 319 | |
| 320 | When the --config-path option is not specified the script attempts to use |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 321 | \$LIBAOM_CONFIG_PATH and then the current directory. |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 322 | |
| 323 | When the -test-data-path option is not specified the script attempts to use |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 324 | \$LIBAOM_TEST_DATA_PATH and then the current directory. |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 325 | EOF |
| 326 | } |
| 327 | |
| 328 | # Returns non-zero (failure) when required environment variables are empty |
| 329 | # strings. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 330 | aom_test_check_environment() { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 331 | if [ -z "${LIBAOM_BIN_PATH}" ] || \ |
| 332 | [ -z "${LIBAOM_CONFIG_PATH}" ] || \ |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 333 | [ -z "${LIBAOM_TEST_DATA_PATH}" ]; then |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 334 | return 1 |
| 335 | fi |
| 336 | } |
| 337 | |
Jim Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 338 | # Echo aomenc command line parameters allowing use of a raw yuv file as |
| 339 | # input to aomenc. |
| 340 | yuv_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. |
| 347 | encode_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 Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 351 | shift |
Jim Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 352 | eval "${encoder}" $(yuv_raw_input) \ |
| 353 | --codec=av1 \ |
Jim Bankoski | f7f0437 | 2016-05-27 14:31:29 -0700 | [diff] [blame] | 354 | $@ \ |
Jim Bankoski | e78a964 | 2016-05-25 07:02:19 -0700 | [diff] [blame] | 355 | --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 Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 366 | # Parse the command line. |
| 367 | while [ -n "$1" ]; do |
| 368 | case "$1" in |
| 369 | --bin-path) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 370 | LIBAOM_BIN_PATH="$2" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 371 | shift |
| 372 | ;; |
| 373 | --config-path) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 374 | LIBAOM_CONFIG_PATH="$2" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 375 | shift |
| 376 | ;; |
| 377 | --filter) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 378 | AOM_TEST_FILTER="$2" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 379 | shift |
| 380 | ;; |
| 381 | --run-disabled-tests) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 382 | AOM_TEST_RUN_DISABLED_TESTS=yes |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 383 | ;; |
| 384 | --help) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 385 | aom_test_usage |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 386 | exit |
| 387 | ;; |
| 388 | --test-data-path) |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 389 | LIBAOM_TEST_DATA_PATH="$2" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 390 | shift |
| 391 | ;; |
Tom Finegan | 926a6f6 | 2014-07-10 15:17:05 -0700 | [diff] [blame] | 392 | --prefix) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 393 | AOM_TEST_PREFIX="$2" |
Tom Finegan | 926a6f6 | 2014-07-10 15:17:05 -0700 | [diff] [blame] | 394 | shift |
| 395 | ;; |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 396 | --verbose) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 397 | AOM_TEST_VERBOSE_OUTPUT=yes |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 398 | ;; |
Tom Finegan | 1d29ce5 | 2014-04-30 11:03:15 -0700 | [diff] [blame] | 399 | --show-program-output) |
| 400 | devnull= |
| 401 | ;; |
Tom Finegan | f34d728 | 2014-09-19 11:09:39 -0700 | [diff] [blame] | 402 | --list-tests) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 403 | AOM_TEST_LIST_TESTS=yes |
Tom Finegan | f34d728 | 2014-09-19 11:09:39 -0700 | [diff] [blame] | 404 | ;; |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 405 | *) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 406 | aom_test_usage |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 407 | exit 1 |
| 408 | ;; |
| 409 | esac |
| 410 | shift |
| 411 | done |
| 412 | |
| 413 | # Handle running the tests from a build directory without arguments when running |
| 414 | # the tests on *nix/macosx. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 415 | LIBAOM_BIN_PATH="${LIBAOM_BIN_PATH:-.}" |
| 416 | LIBAOM_CONFIG_PATH="${LIBAOM_CONFIG_PATH:-.}" |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 417 | LIBAOM_TEST_DATA_PATH="${LIBAOM_TEST_DATA_PATH:-.}" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 418 | |
| 419 | # Create a temporary directory for output files, and a trap to clean it up. |
| 420 | if [ -n "${TMPDIR}" ]; then |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 421 | AOM_TEST_TEMP_ROOT="${TMPDIR}" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 422 | elif [ -n "${TEMPDIR}" ]; then |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 423 | AOM_TEST_TEMP_ROOT="${TEMPDIR}" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 424 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 425 | AOM_TEST_TEMP_ROOT=/tmp |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 426 | fi |
| 427 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 428 | AOM_TEST_OUTPUT_DIR="${AOM_TEST_TEMP_ROOT}/aom_test_$$" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 429 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 430 | if ! mkdir -p "${AOM_TEST_OUTPUT_DIR}" || \ |
| 431 | [ ! -d "${AOM_TEST_OUTPUT_DIR}" ]; then |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 432 | echo "${0##*/}: Cannot create output directory, giving up." |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 433 | echo "${0##*/}: AOM_TEST_OUTPUT_DIR=${AOM_TEST_OUTPUT_DIR}" |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 434 | exit 1 |
| 435 | fi |
| 436 | |
Tom Finegan | 39c5a4b | 2014-04-22 19:36:40 -0700 | [diff] [blame] | 437 | if [ "$(is_windows_target)" = "yes" ]; then |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 438 | AOM_TEST_EXE_SUFFIX=".exe" |
Tom Finegan | 39c5a4b | 2014-04-22 19:36:40 -0700 | [diff] [blame] | 439 | fi |
| 440 | |
Tom Finegan | 7da552c | 2014-04-23 17:18:56 -0700 | [diff] [blame] | 441 | # Variables shared by tests. |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 442 | VP8_IVF_FILE="${LIBAOM_TEST_DATA_PATH}/vp80-00-comprehensive-001.ivf" |
Johann | 472cd03 | 2017-10-19 10:06:26 -0700 | [diff] [blame] | 443 | AV1_IVF_FILE="" |
Tom Finegan | 7da552c | 2014-04-23 17:18:56 -0700 | [diff] [blame] | 444 | |
Johann | 472cd03 | 2017-10-19 10:06:26 -0700 | [diff] [blame] | 445 | AV1_WEBM_FILE="" |
| 446 | AV1_FPM_WEBM_FILE="" |
| 447 | AV1_LT_50_FRAMES_WEBM_FILE="" |
Tom Finegan | 7da552c | 2014-04-23 17:18:56 -0700 | [diff] [blame] | 448 | |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 449 | YUV_RAW_INPUT="${LIBAOM_TEST_DATA_PATH}/hantro_collage_w352h288.yuv" |
Tom Finegan | 7da552c | 2014-04-23 17:18:56 -0700 | [diff] [blame] | 450 | YUV_RAW_INPUT_WIDTH=352 |
| 451 | YUV_RAW_INPUT_HEIGHT=288 |
| 452 | |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 453 | Y4M_NOSQ_PAR_INPUT="${LIBAOM_TEST_DATA_PATH}/park_joy_90p_8_420_a10-1.y4m" |
| 454 | Y4M_720P_INPUT="${LIBAOM_TEST_DATA_PATH}/niklas_1280_720_30.y4m" |
Frank Galligan | 09acd26 | 2015-06-01 10:20:58 -0700 | [diff] [blame] | 455 | |
Tom Finegan | 7da552c | 2014-04-23 17:18:56 -0700 | [diff] [blame] | 456 | # Setup a trap function to clean up after tests complete. |
Tom Finegan | 36c39d6 | 2014-04-03 13:16:58 -0700 | [diff] [blame] | 457 | trap cleanup EXIT |
| 458 | |
Tom Finegan | c5d962d | 2014-04-28 20:56:37 -0700 | [diff] [blame] | 459 | vlog "$(basename "${0%.*}") test configuration: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 460 | LIBAOM_BIN_PATH=${LIBAOM_BIN_PATH} |
| 461 | LIBAOM_CONFIG_PATH=${LIBAOM_CONFIG_PATH} |
Yaowu Xu | 97aa09f | 2016-10-12 08:25:39 -0700 | [diff] [blame] | 462 | LIBAOM_TEST_DATA_PATH=${LIBAOM_TEST_DATA_PATH} |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 463 | 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 Finegan | 1557d4b | 2014-06-13 11:18:43 -0700 | [diff] [blame] | 475 | YUV_RAW_INPUT=${YUV_RAW_INPUT} |
| 476 | YUV_RAW_INPUT_WIDTH=${YUV_RAW_INPUT_WIDTH} |
Frank Galligan | 09acd26 | 2015-06-01 10:20:58 -0700 | [diff] [blame] | 477 | YUV_RAW_INPUT_HEIGHT=${YUV_RAW_INPUT_HEIGHT} |
| 478 | Y4M_NOSQ_PAR_INPUT=${Y4M_NOSQ_PAR_INPUT}" |
Tom Finegan | 4e7e1f1 | 2014-04-28 17:16:05 -0700 | [diff] [blame] | 479 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 480 | fi # End $AOM_TEST_TOOLS_COMMON_SH pseudo include guard. |