Add spotless to check line endings (#1055)

This commit is contained in:
Austin Shalit
2018-05-16 22:47:35 -04:00
committed by Peter Johnson
parent 11d46713d1
commit 2e0709f05b
5 changed files with 110 additions and 99 deletions

View File

@@ -37,28 +37,28 @@ TEST_RUN_ARGS=""
PARAM_ARGS=${@:2}
if [[ "$1" = java ]]; then
LANGUAGE=$1
LOCAL_TEST_FILE=$DEFAULT_LOCAL_JAVA_TEST_FILE
DESTINATION_TEST_FILE=$DEFAULT_DESTINATION_JAVA_TEST_FILE
LANGUAGE=$1
LOCAL_TEST_FILE=$DEFAULT_LOCAL_JAVA_TEST_FILE
DESTINATION_TEST_FILE=$DEFAULT_DESTINATION_JAVA_TEST_FILE
elif [[ "$1" = cpp ]]; then
LANGUAGE=$1
LOCAL_TEST_FILE=$DEFAULT_LOCAL_CPP_TEST_FILE
DESTINATION_TEST_FILE=$DEFAULT_DESTINATION_CPP_TEST_FILE
LANGUAGE=$1
LOCAL_TEST_FILE=$DEFAULT_LOCAL_CPP_TEST_FILE
DESTINATION_TEST_FILE=$DEFAULT_DESTINATION_CPP_TEST_FILE
elif [[ "$1" = "-h" ]]; then
printf "Usage:\n"
echo "$usage"
exit
printf "Usage:\n"
echo "$usage"
exit
else
printf "Invalid language selection: %s\n\n" "$1" >&2
echo "$usage" >&2
exit 1
printf "Invalid language selection: %s\n\n" "$1" >&2
echo "$usage" >&2
exit 1
fi
# Check if the test file to upload exists
if [[ ! -e ${LOCAL_TEST_FILE} ]]; then
printf "The test file does not exist: %s\nAre you sure that you compiled the tests??\n\n" "${LOCAL_TEST_FILE}" >&2
echo "$usage" >&2
exit 1
printf "The test file does not exist: %s\nAre you sure that you compiled the tests??\n\n" "${LOCAL_TEST_FILE}" >&2
echo "$usage" >&2
exit 1
fi
TEST_RUN_ARGS="${@:2}"
@@ -73,17 +73,17 @@ SCP_NATIVE_LIBRARIES="scp ${DEFAULT_LIBRARY_NATIVE_FILES}/* ${ROBOT_ADDRESS}:${D
CONFIG_NATIVE_LIBRARIES="ssh -t ${ADMIN_ROBOT_ADDRESS} ldconfig"
if [ $(which sshpass) ]; then
sshpass -p "" ${SCP_NATIVE_LIBRARIES}
sshpass -p "" ${CONFIG_NATIVE_LIBRARIES}
sshpass -p "" ${SCP_TEST_SCRIPT}
sshpass -p "" ${SSH_CHMOD_AND_MAKE_TEMP_TEST_DIR}
sshpass -p "" ${SCP_TEST_PROGRAM}
sshpass -p "" ${SSH_RUN_TESTS}
sshpass -p "" ${SCP_NATIVE_LIBRARIES}
sshpass -p "" ${CONFIG_NATIVE_LIBRARIES}
sshpass -p "" ${SCP_TEST_SCRIPT}
sshpass -p "" ${SSH_CHMOD_AND_MAKE_TEMP_TEST_DIR}
sshpass -p "" ${SCP_TEST_PROGRAM}
sshpass -p "" ${SSH_RUN_TESTS}
else
eval ${SCP_NATIVE_LIBRARIES}
eval ${CONFIG_NATIVE_LIBRARIES}
eval ${SCP_TEST_SCRIPT}
eval ${SSH_CHMOD_AND_MAKE_TEMP_TEST_DIR}
eval ${SCP_TEST_PROGRAM}
eval ${SSH_RUN_TESTS}
eval ${SCP_NATIVE_LIBRARIES}
eval ${CONFIG_NATIVE_LIBRARIES}
eval ${SCP_TEST_SCRIPT}
eval ${SSH_CHMOD_AND_MAKE_TEMP_TEST_DIR}
eval ${SCP_TEST_PROGRAM}
eval ${SSH_RUN_TESTS}
fi

View File

@@ -17,14 +17,14 @@ flock -x 200 || exit 1
# Ensure the teststand is dead
SSH_STOP_TESTSTAND="ssh -t ${ROBOT_ADDRESS} sh -c '/etc/init.d/teststand stop; sleep 1'"
if [ $(which sshpass) ]; then
sshpass -p "" ${SSH_STOP_TESTSTAND}
sshpass -p "" ${SSH_STOP_TESTSTAND}
else
eval ${SSH_STOP_TESTSTAND}
eval ${SSH_STOP_TESTSTAND}
fi
# If there are already test results in the repository then remove them
if [[ -e ${DEFAULT_LOCAL_TEST_RESULTS_DIR} ]]; then
rm -R ${DEFAULT_LOCAL_TEST_RESULTS_DIR}
rm -R ${DEFAULT_LOCAL_TEST_RESULTS_DIR}
fi
# Make the directory where the tests should live
@@ -33,9 +33,9 @@ mkdir ${DEFAULT_LOCAL_TEST_RESULTS_DIR} 2>/dev/null
# Remove the preivous test results from the the robot
SSH_REMOVE_OLD_TEST_RESULTS="ssh -t ${ROBOT_ADDRESS} rm -R ${DEFAULT_DESTINATION_TEST_RESULTS_DIR}; mkdir ${DEFAULT_DESTINATION_TEST_RESULTS_DIR}"
if [ $(which sshpass) ]; then
sshpass -p "" ${SSH_REMOVE_OLD_TEST_RESULTS}
sshpass -p "" ${SSH_REMOVE_OLD_TEST_RESULTS}
else
eval ${SSH_REMOVE_OLD_TEST_RESULTS}
eval ${SSH_REMOVE_OLD_TEST_RESULTS}
fi
printf "Running cpp test\n"
@@ -46,9 +46,9 @@ printf "Running cpp test\n"
# Retrive the C++ Test Results
SCP_GET_CPP_TEST_RESULT="scp ${ROBOT_ADDRESS}:${DEFAULT_DESTINATION_CPP_TEST_RESULTS} ${DEFAULT_LOCAL_CPP_TEST_RESULT}"
if [ $(which sshpass) ]; then
sshpass -p "" ${SCP_GET_CPP_TEST_RESULT}
sshpass -p "" ${SCP_GET_CPP_TEST_RESULT}
else
eval ${SCP_GET_CPP_TEST_RESULT}
eval ${SCP_GET_CPP_TEST_RESULT}
fi
sleep 10
@@ -59,9 +59,9 @@ sleep 10
# Retrive the Java Test Results
SCP_GET_JAVA_TEST_RESULT="scp ${ROBOT_ADDRESS}:${DEFAULT_DESTINATION_JAVA_TEST_RESULTS} ${DEFAULT_LOCAL_JAVA_TEST_RESULT}"
if [ $(which sshpass) ]; then
sshpass -p "" ${SCP_GET_JAVA_TEST_RESULT}
sshpass -p "" ${SCP_GET_JAVA_TEST_RESULT}
else
eval ${SCP_GET_JAVA_TEST_RESULT}
eval ${SCP_GET_JAVA_TEST_RESULT}
fi
# Make sure that we got test results back.

View File

@@ -34,10 +34,10 @@ Where:
# Are you trying to run this program on a platform other than the roboRIO?
if [[ ! -e "${DEFAULT_TEST_DIR}" ]]; then
printf "Failed to find %s\nAre you trying to run this file on your local computer?\n" "${DEFAULT_TEST_DIR}"
printf "This script should only be run on the roboRIO.\n\n"
echo "$usage"
exit 1
printf "Failed to find %s\nAre you trying to run this file on your local computer?\n" "${DEFAULT_TEST_DIR}"
printf "This script should only be run on the roboRIO.\n\n"
echo "$usage"
exit 1
fi
LANGUAGE=none
@@ -53,21 +53,21 @@ DEFAULT_ARGS=""
# Determine the language that we are attempting to run
if [[ "$1" = java ]]; then
LANGUAGE=$1
TEST_FILE=$DEFAULT_JAVA_TEST_NAME
DEFAULT_ARGS=$DEFAULT_JAVA_TEST_ARGS
LANGUAGE=$1
TEST_FILE=$DEFAULT_JAVA_TEST_NAME
DEFAULT_ARGS=$DEFAULT_JAVA_TEST_ARGS
elif [[ "$1" = cpp ]]; then
LANGUAGE=$1
TEST_FILE=$DEFAULT_CPP_TEST_NAME
DEFAULT_ARGS=$DEFAULT_CPP_TEST_ARGS
LANGUAGE=$1
TEST_FILE=$DEFAULT_CPP_TEST_NAME
DEFAULT_ARGS=$DEFAULT_CPP_TEST_ARGS
elif [[ "$1" = "-h" ]]; then
#If the first argument is the help option
#Allow it to be searhced for in getopts
PARAM_ARGS=${@}
#If the first argument is the help option
#Allow it to be searhced for in getopts
PARAM_ARGS=${@}
else
printf "Invalid language selection: %s\n\n" "$1" >&2
echo "$usage" >&2
exit 1
printf "Invalid language selection: %s\n\n" "$1" >&2
echo "$usage" >&2
exit 1
fi
PARAM_COUNTER=2
@@ -75,41 +75,41 @@ printf "Param Args ${PARAM_ARGS}\n"
# Check for optional paramaters
while getopts ':hmd:A' option $PARAM_ARGS ; do
case "$option" in
h)
# Print the help message
printf "Usage:\n"
echo "$usage"
exit
;;
A)
# Remove the default arguments
RUN_WITH_DEFAULT_ARGS=false
PARAM_COUNTER=$[$PARAM_COUNTER +1]
;;
d)
TEST_DIR=$OPTARG
# Since we are selecting the directory the run args start from the 5th argument
PARAM_COUNTER=$[$PARAM_COUNTER +2]
;;
?)
# When an unknown param is found then we are done so break
break
;;
esac
case "$option" in
h)
# Print the help message
printf "Usage:\n"
echo "$usage"
exit
;;
A)
# Remove the default arguments
RUN_WITH_DEFAULT_ARGS=false
PARAM_COUNTER=$[$PARAM_COUNTER +1]
;;
d)
TEST_DIR=$OPTARG
# Since we are selecting the directory the run args start from the 5th argument
PARAM_COUNTER=$[$PARAM_COUNTER +2]
;;
?)
# When an unknown param is found then we are done so break
break
;;
esac
done
TEST_RUN_ARGS=${@:$[$PARAM_COUNTER +1]}
if [[ "$RUN_WITH_DEFAULT_ARGS" == true ]]; then
TEST_RUN_ARGS="${DEFAULT_ARGS} ${TEST_RUN_ARGS}"
TEST_RUN_ARGS="${DEFAULT_ARGS} ${TEST_RUN_ARGS}"
fi
# Make sure at least two paramaters are passed or four if running with -d option
if [[ $# -lt $PARAM_COUNTER ]]; then
printf "Invalid arg count. Should be %s, was %s.\n" "${PARAM_COUNTER}" "$#"
echo "$usage"
exit 1
printf "Invalid arg count. Should be %s, was %s.\n" "${PARAM_COUNTER}" "$#"
echo "$usage"
exit 1
fi
# Kill all running robot programs
@@ -117,11 +117,11 @@ killall java FRCUserProgram
# 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}"
echo "$usage"
exit 1
printf "Failed to find %s.\nDid you copy the test file correctly?\n" "${TEST_DIR}/${TEST_FILE}"
echo "$usage"
exit 1
elif [[ $TEST_DIR != "$DEFAULT_TEST_DIR" ]]; then
mv "${TEST_DIR}/${TEST_FILE}" "${DEFAULT_TEST_DIR}"
mv "${TEST_DIR}/${TEST_FILE}" "${DEFAULT_TEST_DIR}"
fi
# Make sure the excecutable file has permission to run
@@ -133,11 +133,11 @@ export eval `/sbin/fw_printenv DeviceCode FPGADeviceCode DeviceDesc TargetClass`
# Store the run command for the language
RUN_COMMAND=none
if [[ ${LANGUAGE} = java ]]; then
chmod a+x ${DEFAULT_JAVA_TEST_NAME}
RUN_COMMAND="env LD_LIBRARY_PATH=/opt/GenICam_v3_0_NI/bin/Linux32_ARM/:/usr/local/frc/lib ${DEFAULT_PATH_TO_JRE} -ea -jar ${DEFAULT_JAVA_TEST_NAME} ${TEST_RUN_ARGS}"
chmod a+x ${DEFAULT_JAVA_TEST_NAME}
RUN_COMMAND="env LD_LIBRARY_PATH=/opt/GenICam_v3_0_NI/bin/Linux32_ARM/:/usr/local/frc/lib ${DEFAULT_PATH_TO_JRE} -ea -jar ${DEFAULT_JAVA_TEST_NAME} ${TEST_RUN_ARGS}"
elif [[ ${LANGUAGE} = cpp ]]; then
chmod a+x ${DEFAULT_CPP_TEST_NAME}
RUN_COMMAND="./${DEFAULT_CPP_TEST_NAME} ${TEST_RUN_ARGS}"
chmod a+x ${DEFAULT_CPP_TEST_NAME}
RUN_COMMAND="./${DEFAULT_CPP_TEST_NAME} ${TEST_RUN_ARGS}"
fi
printf "Running: %s\n\n" "${RUN_COMMAND}"
@@ -148,10 +148,10 @@ echo ${CORE_LOCATION} > /proc/sys/kernel/core_pattern
ulimit -c unlimited
eval ${RUN_COMMAND}
if [[ $? -gt 127 && -e ${CORE_LOCATION} ]]; then
mv ${CORE_LOCATION} ${COREDUMP_DIR}/core.${LANGUAGE}
if [[ ${LANGUAGE} = java ]]; then
cp -p ${DEFAULT_JAVA_TEST_NAME} ${COREDUMP_DIR}/
elif [[ ${LANGUAGE} = cpp ]]; then
cp -p ${DEFAULT_CPP_TEST_NAME} ${COREDUMP_DIR}/
fi
mv ${CORE_LOCATION} ${COREDUMP_DIR}/core.${LANGUAGE}
if [[ ${LANGUAGE} = java ]]; then
cp -p ${DEFAULT_JAVA_TEST_NAME} ${COREDUMP_DIR}/
elif [[ ${LANGUAGE} = cpp ]]; then
cp -p ${DEFAULT_CPP_TEST_NAME} ${COREDUMP_DIR}/
fi
fi