John Park | 7eb9042 | 2018-01-27 12:04:57 -0800 | [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 | ( |
| 13 | # Wait for lock |
| 14 | printf "Getting exclusive lock for RIO execution...\n" |
| 15 | flock -x 200 || exit 1 |
| 16 | |
| 17 | # Ensure the teststand is dead |
| 18 | SSH_STOP_TESTSTAND="ssh -t ${ROBOT_ADDRESS} sh -c '/etc/init.d/teststand stop; sleep 1'" |
| 19 | if [ $(which sshpass) ]; then |
| 20 | sshpass -p "" ${SSH_STOP_TESTSTAND} |
| 21 | else |
| 22 | eval ${SSH_STOP_TESTSTAND} |
| 23 | fi |
| 24 | |
| 25 | # If there are already test results in the repository then remove them |
| 26 | if [[ -e ${DEFAULT_LOCAL_TEST_RESULTS_DIR} ]]; then |
| 27 | rm -R ${DEFAULT_LOCAL_TEST_RESULTS_DIR} |
| 28 | fi |
| 29 | |
| 30 | # Make the directory where the tests should live |
| 31 | mkdir ${DEFAULT_LOCAL_TEST_RESULTS_DIR} 2>/dev/null |
| 32 | |
| 33 | # Remove the preivous test results from the the robot |
| 34 | SSH_REMOVE_OLD_TEST_RESULTS="ssh -t ${ROBOT_ADDRESS} rm -R ${DEFAULT_DESTINATION_TEST_RESULTS_DIR}; mkdir ${DEFAULT_DESTINATION_TEST_RESULTS_DIR}" |
| 35 | if [ $(which sshpass) ]; then |
| 36 | sshpass -p "" ${SSH_REMOVE_OLD_TEST_RESULTS} |
| 37 | else |
| 38 | eval ${SSH_REMOVE_OLD_TEST_RESULTS} |
| 39 | fi |
| 40 | |
| 41 | printf "Running cpp test\n" |
| 42 | |
| 43 | # Run the C++ Tests |
| 44 | ./deploy-and-run-test-on-robot.sh cpp -A "--gtest_output=xml:${DEFAULT_DESTINATION_CPP_TEST_RESULTS}" |
| 45 | |
| 46 | # Retrive the C++ Test Results |
| 47 | SCP_GET_CPP_TEST_RESULT="scp ${ROBOT_ADDRESS}:${DEFAULT_DESTINATION_CPP_TEST_RESULTS} ${DEFAULT_LOCAL_CPP_TEST_RESULT}" |
| 48 | if [ $(which sshpass) ]; then |
| 49 | sshpass -p "" ${SCP_GET_CPP_TEST_RESULT} |
| 50 | else |
| 51 | eval ${SCP_GET_CPP_TEST_RESULT} |
| 52 | fi |
| 53 | |
| 54 | sleep 10 |
| 55 | |
| 56 | # Run the Java Tests |
| 57 | ./deploy-and-run-test-on-robot.sh java |
| 58 | |
| 59 | # Retrive the Java Test Results |
| 60 | SCP_GET_JAVA_TEST_RESULT="scp ${ROBOT_ADDRESS}:${DEFAULT_DESTINATION_JAVA_TEST_RESULTS} ${DEFAULT_LOCAL_JAVA_TEST_RESULT}" |
| 61 | if [ $(which sshpass) ]; then |
| 62 | sshpass -p "" ${SCP_GET_JAVA_TEST_RESULT} |
| 63 | else |
| 64 | eval ${SCP_GET_JAVA_TEST_RESULT} |
| 65 | fi |
| 66 | |
| 67 | # Make sure that we got test results back. |
| 68 | if [ ! -e ${DEFAULT_LOCAL_CPP_TEST_RESULT} ]; then |
| 69 | echo "There are no results from the C++ tests; they must have failed." |
| 70 | exit 100 |
| 71 | fi |
| 72 | |
| 73 | if [ ! -e ${DEFAULT_LOCAL_JAVA_TEST_RESULT} ]; then |
| 74 | echo "There are no results from the Java tests; they must have failed." |
| 75 | exit 101 |
| 76 | fi |
| 77 | |
| 78 | # The mutex is released when this program exits |
| 79 | ) 200>/var/lock/jenkins.rio.exclusivelock |