mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Kill FRC_NetCommDaemon as well as robot programs. (#780)
Also use flock on Jenkins side to prevent multiple simultaneous runs, instead of using teststand mutex.
This commit is contained in:
@@ -9,32 +9,18 @@
|
||||
# Configurable variables
|
||||
source config.sh
|
||||
|
||||
# Setup the mutex release before we grab it
|
||||
mutexTaken=false
|
||||
# This function should run even if the script exits abnormally
|
||||
function finish {
|
||||
if [ "$mutexTaken" == true ]; then
|
||||
SSH_GIVE_MUTEX="ssh -t ${ROBOT_ADDRESS} /usr/local/frc/bin/teststand give --name=$(whoami)"
|
||||
if [ $(which sshpass) ]; then
|
||||
sshpass -p "" ${SSH_GIVE_MUTEX}
|
||||
else
|
||||
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"
|
||||
eval ${SSH_GIVE_MUTEX}
|
||||
fi
|
||||
mutexTaken=false
|
||||
fi
|
||||
}
|
||||
trap finish EXIT SIGINT
|
||||
(
|
||||
# Wait for lock
|
||||
printf "Getting exclusive lock for RIO execution...\n"
|
||||
flock -x 200 || exit 1
|
||||
|
||||
|
||||
|
||||
# Take the mutex from the driver station
|
||||
mutexTaken=true
|
||||
SSH_TAKE_MUTEX="ssh -t ${ROBOT_ADDRESS} /usr/local/frc/bin/teststand take --name=$(whoami)"
|
||||
# To work around memory leak, kill NetComm and restart the teststand
|
||||
# (the teststand dies when NetComm is killed)
|
||||
SSH_RESTART_NETCOMM="ssh -t ${ROBOT_ADDRESS} sh -c 'killall FRC_NetCommDaemon; sleep 1; /etc/init.d/teststand stop; /etc/init.d/teststand start; sleep 1'"
|
||||
if [ $(which sshpass) ]; then
|
||||
sshpass -p "" ${SSH_TAKE_MUTEX}
|
||||
sshpass -p "" ${SSH_RESTART_NETCOMM}
|
||||
else
|
||||
eval ${SSH_TAKE_MUTEX}
|
||||
eval ${SSH_RESTART_NETCOMM}
|
||||
fi
|
||||
|
||||
# If there are already test results in the repository then remove them
|
||||
@@ -56,7 +42,7 @@ fi
|
||||
printf "Running cpp test\n"
|
||||
|
||||
# Run the C++ Tests
|
||||
./deploy-and-run-test-on-robot.sh cpp -m -A "--gtest_output=xml:${DEFAULT_DESTINATION_CPP_TEST_RESULTS}"
|
||||
./deploy-and-run-test-on-robot.sh cpp -A "--gtest_output=xml:${DEFAULT_DESTINATION_CPP_TEST_RESULTS}"
|
||||
|
||||
# Retrive the C++ Test Results
|
||||
SCP_GET_CPP_TEST_RESULT="scp ${ROBOT_ADDRESS}:${DEFAULT_DESTINATION_CPP_TEST_RESULTS} ${DEFAULT_LOCAL_CPP_TEST_RESULT}"
|
||||
@@ -67,7 +53,7 @@ else
|
||||
fi
|
||||
|
||||
# Run the Java Tests
|
||||
./deploy-and-run-test-on-robot.sh java -m
|
||||
./deploy-and-run-test-on-robot.sh java
|
||||
|
||||
# Retrive the Java Test Results
|
||||
SCP_GET_JAVA_TEST_RESULT="scp ${ROBOT_ADDRESS}:${DEFAULT_DESTINATION_JAVA_TEST_RESULTS} ${DEFAULT_LOCAL_JAVA_TEST_RESULT}"
|
||||
@@ -89,3 +75,4 @@ if [ ! -e ${DEFAULT_LOCAL_JAVA_TEST_RESULT} ]; then
|
||||
fi
|
||||
|
||||
# The mutex is released when this program exits
|
||||
) 200>/var/lock/jenkins.rio.exclusivelock
|
||||
|
||||
Reference in New Issue
Block a user