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