summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2015-02-26 12:57:30 -0800
committerJames Zern <jzern@google.com>2015-02-26 12:57:30 -0800
commit2ebe0aee11ff4d6ca97e909ba9d3b8946e0fcba8 (patch)
tree519fa0ad467ae51a02b19208d787e0c4c52211e4
parent3e1d14a6ce812dece1f50800c2a29431b25822b7 (diff)
downloadlibvpx-2ebe0aee11ff4d6ca97e909ba9d3b8946e0fcba8.tar
libvpx-2ebe0aee11ff4d6ca97e909ba9d3b8946e0fcba8.tar.gz
libvpx-2ebe0aee11ff4d6ca97e909ba9d3b8946e0fcba8.tar.bz2
libvpx-2ebe0aee11ff4d6ca97e909ba9d3b8946e0fcba8.zip
tools_common.sh: add directory name to error output
+ add a helper function to reduce the duplication this is a bit clearer when the environment variable is set, but the directory is missing Change-Id: I08f9b56122b5741bb40a5f795f7f82f5b49f1047
-rwxr-xr-xtest/tools_common.sh26
1 files changed, 14 insertions, 12 deletions
diff --git a/test/tools_common.sh b/test/tools_common.sh
index 8e8d78592..dffd4c491 100755
--- a/test/tools_common.sh
+++ b/test/tools_common.sh
@@ -106,22 +106,24 @@ check_git_hashes() {
fi
}
+# $1 is the name of an environment variable containing a directory name to
+# test.
+test_env_var_dir() {
+ local dir=$(eval echo "\${$1}")
+ if [ ! -d "${dir}" ]; then
+ elog "'${dir}': No such directory"
+ elog "The $1 environment variable must be set to a valid directory."
+ return 1
+ fi
+}
+
# This script requires that the LIBVPX_BIN_PATH, LIBVPX_CONFIG_PATH, and
# LIBVPX_TEST_DATA_PATH variables are in the environment: Confirm that
# the variables are set and that they all evaluate to directory paths.
verify_vpx_test_environment() {
- if [ ! -d "${LIBVPX_BIN_PATH}" ]; then
- echo "The LIBVPX_BIN_PATH environment variable must be set."
- return 1
- fi
- if [ ! -d "${LIBVPX_CONFIG_PATH}" ]; then
- echo "The LIBVPX_CONFIG_PATH environment variable must be set."
- return 1
- fi
- if [ ! -d "${LIBVPX_TEST_DATA_PATH}" ]; then
- echo "The LIBVPX_TEST_DATA_PATH environment variable must be set."
- return 1
- fi
+ test_env_var_dir "LIBVPX_BIN_PATH" \
+ && test_env_var_dir "LIBVPX_CONFIG_PATH" \
+ && test_env_var_dir "LIBVPX_TEST_DATA_PATH"
}
# Greps vpx_config.h in LIBVPX_CONFIG_PATH for positional parameter one, which