ref: f1e0183c81ec3d01f43df7857e6985d216a4ec43
parent: 776a6cfd9eda879cdda1486f2f59807a3c2aed05
parent: 2ebe0aee11ff4d6ca97e909ba9d3b8946e0fcba8
author: James Zern <[email protected]>
date: Thu Feb 26 10:54:41 EST 2015
Merge "tools_common.sh: add directory name to error output"
--- a/test/tools_common.sh
+++ b/test/tools_common.sh
@@ -106,22 +106,24 @@
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