blob: 71b4945e2144a4fe4203d6e62fed7c8a74f490cc [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001#!/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
10source config.sh
11
12# Setup the mutex release before we grab it
13mutexTaken=false
14# This function should run even if the script exits abnormally
15function 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}
27trap finish EXIT SIGINT
28
29
30
31# Take the mutex from the driver station
32mutexTaken=true
33SSH_TAKE_MUTEX="ssh -t ${ROBOT_ADDRESS} /usr/local/frc/bin/teststand take --name=$(whoami)"
34if [ $(which sshpass) ]; then
35 sshpass -p "" ${SSH_TAKE_MUTEX}
36else
37 eval ${SSH_TAKE_MUTEX}
38fi
39
40# If there are already test results in the repository then remove them
41if [[ -e ${DEFAULT_LOCAL_TEST_RESULTS_DIR} ]]; then
42 rm -R ${DEFAULT_LOCAL_TEST_RESULTS_DIR}
43fi
44
45# Make the directory where the tests should live
46mkdir ${DEFAULT_LOCAL_TEST_RESULTS_DIR} 2>/dev/null
47
48# Remove the preivous test results from the the robot
49SSH_REMOVE_OLD_TEST_RESULTS="ssh -t ${ROBOT_ADDRESS} rm -R ${DEFAULT_DESTINATION_TEST_RESULTS_DIR}; mkdir ${DEFAULT_DESTINATION_TEST_RESULTS_DIR}"
50if [ $(which sshpass) ]; then
51 sshpass -p "" ${SSH_REMOVE_OLD_TEST_RESULTS}
52else
53 eval ${SSH_REMOVE_OLD_TEST_RESULTS}
54fi
55
56printf "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
62SCP_GET_CPP_TEST_RESULT="scp ${ROBOT_ADDRESS}:${DEFAULT_DESTINATION_CPP_TEST_RESULTS} ${DEFAULT_LOCAL_CPP_TEST_RESULT}"
63if [ $(which sshpass) ]; then
64 sshpass -p "" ${SCP_GET_CPP_TEST_RESULT}
65else
66 eval ${SCP_GET_CPP_TEST_RESULT}
67fi
68
69# Run the Java Tests
70./deploy-and-run-test-on-robot.sh java -m
71
72# Retrive the Java Test Results
73SCP_GET_JAVA_TEST_RESULT="scp ${ROBOT_ADDRESS}:${DEFAULT_DESTINATION_JAVA_TEST_RESULTS} ${DEFAULT_LOCAL_JAVA_TEST_RESULT}"
74if [ $(which sshpass) ]; then
75 sshpass -p "" ${SCP_GET_JAVA_TEST_RESULT}
76else
77 eval ${SCP_GET_JAVA_TEST_RESULT}
78fi
79
80# Make sure that we got test results back.
81if [ ! -e ${DEFAULT_LOCAL_CPP_TEST_RESULT} ]; then
82 echo "There are no results from the C++ tests; they must have failed."
83 exit 100
84fi
85
86if [ ! -e ${DEFAULT_LOCAL_JAVA_TEST_RESULT} ]; then
87 echo "There are no results from the Java tests; they must have failed."
88 exit 101
89fi
90
91# The mutex is released when this program exits