1#!/bin/bash 2# 3# Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6USAGE="Usage: deploy_private_test.sh -a PATH_TO_PUBLIC_AUTOTEST \ 7-p PATH_TO_PRIVATE_AUTOTEST" 8HELP="${USAGE} 9 Link server side tests under PATH_TO_PRIVATE_AUTOTEST \ 10to PATH_TO_PUBLIC_AUTOTEST 11 12 PATH_TO_PRIVATE_AUTOTEST defaults to \ 13/usr/local/autotest/site_utils/autotest_private 14 PATH_TO_PUBLIC_AUTOTEST defaults to \ 15/usr/local/autotest" 16 17AUTOTEST_ROOT="/usr/local/autotest" 18PRIVATE_AUTOTEST_ROOT="${AUTOTEST_ROOT}/site_utils/autotest_private" 19 20while getopts ":p:a:h" opt; do 21 case $opt in 22 a) 23 AUTOTEST_ROOT=$OPTARG 24 ;; 25 p) 26 PRIVATE_AUTOTEST_ROOT=$OPTARG 27 ;; 28 h) 29 echo "${HELP}" >&2 30 exit 0 31 ;; 32 \?) 33 echo "Invalid option: -$OPTARG" >&2 34 echo "${USAGE}" >&2 35 exit 1 36 ;; 37 esac 38done 39 40if [ ! -d "${AUTOTEST_ROOT}" ]; then 41 echo "Invalid public autotest root: ${AUTOTEST_ROOT}" >&2 42 exit 1 43fi 44 45if [ ! -d "${PRIVATE_AUTOTEST_ROOT}" ]; then 46 echo "Invalid private autotest root: ${PRIVATE_AUTOTEST_ROOT}" >&2 47 exit 1 48fi 49 50PUBLIC_SERVER_TESTS_DIR="${AUTOTEST_ROOT}/server/site_tests" 51PUBLIC_SERVER_SUITES_DIR="${PUBLIC_SERVER_TESTS_DIR}/suites" 52PUBLIC_CLIENT_TESTS_DIR="${AUTOTEST_ROOT}/client/site_tests" 53 54PRIVATE_SERVER_TESTS_DIR="${PRIVATE_AUTOTEST_ROOT}/server/site_tests" 55PRIVATE_SERVER_SUITES_DIR="${PRIVATE_SERVER_TESTS_DIR}/suites" 56PRIVATE_CLIENT_TESTS_DIR="${PRIVATE_AUTOTEST_ROOT}/client/site_tests" 57 58echo "Removing existing symbolic links in ${PUBLIC_SERVER_TESTS_DIR}, \ 59${PUBLIC_CLIENT_TESTS_DIR} and ${PUBLIC_SERVER_SUITES_DIR}" 60find ${PUBLIC_SERVER_TESTS_DIR} -type l -exec rm -v {} \; 61find ${PUBLIC_CLIENT_TESTS_DIR} -type l -exec rm -v {} \; 62find ${PUBLIC_SERVER_SUITES_DIR} -type l -exec rm -v {} \; 63echo "Creating links for tests..." 64find ${PRIVATE_SERVER_TESTS_DIR} -mindepth 1 -maxdepth 1 \ 65 -type d ! -path ${PRIVATE_SERVER_SUITES_DIR} \ 66 -exec ln -v -s {} ${PUBLIC_SERVER_TESTS_DIR} \; 67find ${PRIVATE_CLIENT_TESTS_DIR} -mindepth 1 -maxdepth 1 \ 68 -type d ! -path ${PRIVATE_SERVER_SUITES_DIR} \ 69 -exec ln -v -s {} ${PUBLIC_CLIENT_TESTS_DIR} \; 70echo "Creating links for suites..." 71find ${PRIVATE_SERVER_SUITES_DIR} -mindepth 1 -maxdepth 1 -type f \ 72 -exec ln -v -s {} ${PUBLIC_SERVER_SUITES_DIR} \; 73