From 0db85ef360ec768df8dbd7f0964c386cd4150394 Mon Sep 17 00:00:00 2001 From: Daniel Erat Date: Wed, 9 Jun 2010 15:55:03 -0700 Subject: [PATCH] Make run_remote_tests.sh support --results_dir_root. Patch author: Andy Chan Original issue: http://codereview.chromium.org/2128016/show Reviewed by sosa@chromium.org. BUG=none TEST=none Review URL: http://codereview.chromium.org/2728006 --- run_remote_tests.sh | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/run_remote_tests.sh b/run_remote_tests.sh index 48b497d9fc..7418f284a1 100755 --- a/run_remote_tests.sh +++ b/run_remote_tests.sh @@ -149,15 +149,37 @@ function main() { exit 1 fi + # Check the validity of the user-specified result directory + # It must be within the /tmp directory + if [[ -n "${FLAGS_results_dir_root}" ]]; then + SUBSTRING=${FLAGS_results_dir_root:0:5} + if [[ ${SUBSTRING} != "/tmp/" ]]; then + echo "User-specified result directory must be within the /tmp directory" + echo "ex: --results_dir_root=/tmp/" + exit 1 + fi + fi + set -e # Set global TMP for remote_access.sh's sake - if [[ ${INSIDE_CHROOT} -eq 0 ]] - then - TMP=$(mktemp -d ${FLAGS_chroot}/tmp/run_remote_tests.XXXX) + # and if --results_dir_root is specified, + # set TMP and create dir appropriately + if [[ ${INSIDE_CHROOT} -eq 0 ]]; then + if [[ -n "${FLAGS_results_dir_root}" ]]; then + TMP=${FLAGS_chroot}${FLAGS_results_dir_root} + mkdir -m 777 ${TMP} + else + TMP=$(mktemp -d ${FLAGS_chroot}/tmp/run_remote_tests.XXXX) + fi TMP_INSIDE_CHROOT=$(echo ${TMP#${FLAGS_chroot}}) else - TMP=$(mktemp -d /tmp/run_remote_tests.XXXX) + if [[ -n "${FLAGS_results_dir_root}" ]]; then + TMP=${FLAGS_results_dir_root} + mkdir -m 777 ${TMP} + else + TMP=$(mktemp -d /tmp/run_remote_tests.XXXX) + fi TMP_INSIDE_CHROOT=${TMP} fi @@ -217,12 +239,6 @@ function main() { echo_color "yellow" " * " "${CONTROL_FILE}" done - if [[ -z "${FLAGS_results_dir_root}" ]]; then - FLAGS_results_dir_root="${TMP_INSIDE_CHROOT}" - fi - - mkdir -p "${FLAGS_results_dir_root}" - for control_file in ${control_files_to_run}; do # Assume a line starts with TEST_TYPE = control_file=$(remove_quotes "${control_file}")