Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | #*----------------------------------------------------------------------------*# |
| 3 | #* Copyright (c) FIRST 2014. All Rights Reserved. *# |
| 4 | #* Open Source Software - may be modified and shared by FRC teams. The code *# |
| 5 | #* must be accompanied by the FIRST BSD license file in the root directory of *# |
| 6 | #* the project. *# |
| 7 | #*----------------------------------------------------------------------------*# |
| 8 | |
| 9 | # Configurable variables |
| 10 | source config.sh |
| 11 | |
| 12 | # Setup the mutex release before we grab it |
| 13 | mutexTaken=false |
| 14 | # This function should run even if the script exits abnormally |
| 15 | function finish { |
| 16 | if [ "$mutexTaken" == true ]; then |
| 17 | SSH_GIVE_MUTEX="ssh -t ${ROBOT_ADDRESS} /usr/local/frc/bin/teststand give --name=$(whoami)" |
| 18 | if [ $(which sshpass) ]; then |
| 19 | sshpass -p "" ${SSH_GIVE_MUTEX} |
| 20 | else |
| 21 | printf "WARNING!!! THIS IS HOW THE MUTEX IS RELEASED!\nIF YOU CHOOSE TO 'ctr+c' NOW YOU WILL HAVE TO HAND BACK THE MUTEX MANUALLY ON THE ROBOT.\n" |
| 22 | eval ${SSH_GIVE_MUTEX} |
| 23 | fi |
| 24 | mutexTaken=false |
| 25 | fi |
| 26 | } |
| 27 | trap finish EXIT SIGINT |
| 28 | |
| 29 | |
| 30 | |
| 31 | # Take the mutex from the driver station |
| 32 | mutexTaken=true |
| 33 | SSH_TAKE_MUTEX="ssh -t ${ROBOT_ADDRESS} /usr/local/frc/bin/teststand take --name=$(whoami)" |
| 34 | if [ $(which sshpass) ]; then |
| 35 | sshpass -p "" ${SSH_TAKE_MUTEX} |
| 36 | else |
| 37 | eval ${SSH_TAKE_MUTEX} |
| 38 | fi |
| 39 | |
| 40 | # If there are already test results in the repository then remove them |
| 41 | if [[ -e ${DEFAULT_LOCAL_TEST_RESULTS_DIR} ]]; then |
| 42 | rm -R ${DEFAULT_LOCAL_TEST_RESULTS_DIR} |
| 43 | fi |
| 44 | |
| 45 | # Make the directory where the tests should live |
| 46 | mkdir ${DEFAULT_LOCAL_TEST_RESULTS_DIR} 2>/dev/null |
| 47 | |
| 48 | # Remove the preivous test results from the the robot |
| 49 | SSH_REMOVE_OLD_TEST_RESULTS="ssh -t ${ROBOT_ADDRESS} rm -R ${DEFAULT_DESTINATION_TEST_RESULTS_DIR}; mkdir ${DEFAULT_DESTINATION_TEST_RESULTS_DIR}" |
| 50 | if [ $(which sshpass) ]; then |
| 51 | sshpass -p "" ${SSH_REMOVE_OLD_TEST_RESULTS} |
| 52 | else |
| 53 | eval ${SSH_REMOVE_OLD_TEST_RESULTS} |
| 54 | fi |
| 55 | |
| 56 | printf "Running cpp test\n" |
| 57 | |
| 58 | # Run the C++ Tests |
| 59 | ./deploy-and-run-test-on-robot.sh cpp -m -A "--gtest_output=xml:${DEFAULT_DESTINATION_CPP_TEST_RESULTS}" |
| 60 | |
| 61 | # Retrive the C++ Test Results |
| 62 | SCP_GET_CPP_TEST_RESULT="scp ${ROBOT_ADDRESS}:${DEFAULT_DESTINATION_CPP_TEST_RESULTS} ${DEFAULT_LOCAL_CPP_TEST_RESULT}" |
| 63 | if [ $(which sshpass) ]; then |
| 64 | sshpass -p "" ${SCP_GET_CPP_TEST_RESULT} |
| 65 | else |
| 66 | eval ${SCP_GET_CPP_TEST_RESULT} |
| 67 | fi |
| 68 | |
| 69 | # Run the Java Tests |
| 70 | ./deploy-and-run-test-on-robot.sh java -m |
| 71 | |
| 72 | # Retrive the Java Test Results |
| 73 | SCP_GET_JAVA_TEST_RESULT="scp ${ROBOT_ADDRESS}:${DEFAULT_DESTINATION_JAVA_TEST_RESULTS} ${DEFAULT_LOCAL_JAVA_TEST_RESULT}" |
| 74 | if [ $(which sshpass) ]; then |
| 75 | sshpass -p "" ${SCP_GET_JAVA_TEST_RESULT} |
| 76 | else |
| 77 | eval ${SCP_GET_JAVA_TEST_RESULT} |
| 78 | fi |
| 79 | |
| 80 | # Make sure that we got test results back. |
| 81 | if [ ! -e ${DEFAULT_LOCAL_CPP_TEST_RESULT} ]; then |
| 82 | echo "There are no results from the C++ tests; they must have failed." |
| 83 | exit 100 |
| 84 | fi |
| 85 | |
| 86 | if [ ! -e ${DEFAULT_LOCAL_JAVA_TEST_RESULT} ]; then |
| 87 | echo "There are no results from the Java tests; they must have failed." |
| 88 | exit 101 |
| 89 | fi |
| 90 | |
| 91 | # The mutex is released when this program exits |