mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
Runs DS enabled loop in process (#785)
Solves mutex issues, and other issues with the existing teststand software. And simplifies the unit test structure.
This commit is contained in:
committed by
Peter Johnson
parent
26a36779a6
commit
fa0b4428e9
@@ -17,45 +17,20 @@ source config.sh
|
||||
DEFAULT_TEST_DIR=${DEFAULT_DESTINATION_DIR}
|
||||
DEFAULT_PATH_TO_JRE=/usr/local/frc/JRE/bin/java
|
||||
|
||||
usage="$(basename "$0") [-h] (java|cpp) name [-d test_dir] [-m] [-A] [arg] [arg]...
|
||||
usage="$(basename "$0") [-h] (java|cpp) name [-d test_dir] [-A] [arg] [arg]...
|
||||
A script designed to run the integration tests.
|
||||
This script should only be run on the roborio.
|
||||
Where:
|
||||
-h Show this help text
|
||||
name The name of the user trying to run the tests (used for driver station)
|
||||
-d The directory where the tests have been placed.
|
||||
This is done to prevent overwriting an already running program
|
||||
in the case where another user already has the driver station mutex.
|
||||
This is done to prevent overwriting an already running program.
|
||||
This scrip will automatically move the test into the ${DEFAULT_TEST_DIR}
|
||||
directory when the driver station mutex is released.
|
||||
directory.
|
||||
Default: Assumes the test is in the same directory as this scrip.
|
||||
-m The driver station mutex will be handled manually.
|
||||
-A Do not use the default arguments for the given language.
|
||||
arg The arguments to be passed to test."
|
||||
|
||||
mutexTaken=false
|
||||
driverStationEnabled=false
|
||||
# This function should run even if the script exits abnormally
|
||||
function finish {
|
||||
if [ "$driverStationEnabled" == true ]; then
|
||||
/usr/local/frc/bin/teststand ds --name="${NAME}" disable
|
||||
driverStationEnabled=false
|
||||
fi
|
||||
if [ "$mutexTaken" == true ]; then
|
||||
/usr/local/frc/bin/teststand give --name="${NAME}"
|
||||
mutexTaken=false
|
||||
fi
|
||||
}
|
||||
trap finish EXIT SIGINT
|
||||
|
||||
# This function should be run asynchronysly to enable the tests 10
|
||||
# seconds after they have been run.
|
||||
function enableIn10Seconds {
|
||||
/usr/local/frc/bin/teststand ds --name="${NAME}" disable
|
||||
driverStationEnabled=true
|
||||
sleep 10
|
||||
/usr/local/frc/bin/teststand ds --name="${NAME}" enable
|
||||
}
|
||||
|
||||
# Are you trying to run this program on a platform other than the roboRIO?
|
||||
if [[ ! -e "${DEFAULT_TEST_DIR}" ]]; then
|
||||
@@ -75,7 +50,6 @@ PARAM_ARGS=${@:3}
|
||||
TEST_RUN_ARGS=${@:3}
|
||||
RUN_WITH_DEFAULT_ARGS=true
|
||||
DEFAULT_ARGS=""
|
||||
MUTEX_OVERRIDE=false
|
||||
|
||||
# Determine the language that we are attempting to run
|
||||
if [[ "$1" = java ]]; then
|
||||
@@ -113,10 +87,6 @@ while getopts ':hmd:A' option $PARAM_ARGS ; do
|
||||
RUN_WITH_DEFAULT_ARGS=false
|
||||
PARAM_COUNTER=$[$PARAM_COUNTER +1]
|
||||
;;
|
||||
m)
|
||||
MUTEX_OVERRIDE=true
|
||||
PARAM_COUNTER=$[$PARAM_COUNTER +1]
|
||||
;;
|
||||
d)
|
||||
TEST_DIR=$OPTARG
|
||||
# Since we are selecting the directory the run args start from the 5th argument
|
||||
@@ -142,19 +112,9 @@ if [[ $# -lt $PARAM_COUNTER ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If the mutex has been retrived a higher level in the tree
|
||||
if [ "$MUTEX_OVERRIDE" == false ]; then
|
||||
# Attempt to take the mutex for the driver station
|
||||
mutexTaken=true
|
||||
/usr/local/frc/bin/teststand take --name="${NAME}"
|
||||
else
|
||||
printf "Override driver station control enabled.\n"
|
||||
fi
|
||||
|
||||
# Kill all running robot programs
|
||||
killall java FRCUserProgram
|
||||
|
||||
# Once we have the mutex no other tests are running
|
||||
# If we are running with the -d argument move the test to the DEFAULT_TEST_DIR
|
||||
if [[ ! -e "${TEST_DIR}/${TEST_FILE}" ]]; then
|
||||
printf "Failed to find %s.\nDid you copy the test file correctly?\n" "${TEST_DIR}/${TEST_FILE}"
|
||||
@@ -166,9 +126,6 @@ fi
|
||||
|
||||
# Make sure the excecutable file has permission to run
|
||||
|
||||
# Setup the driver station to enable automatically in 10 seconds without waiting for the function to excecute.
|
||||
enableIn10Seconds&
|
||||
|
||||
# Get the serial number and FPGADeviceCode for this rio
|
||||
export serialnum=`/sbin/fw_printenv -n serial#`
|
||||
export eval `/sbin/fw_printenv DeviceCode FPGADeviceCode DeviceDesc TargetClass`
|
||||
|
||||
Reference in New Issue
Block a user