regression_test: Partial failure function in case there is a lanforge failure but Python doesn't fail

Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
Matthew Stidham
2021-12-02 09:49:24 -08:00
parent 7aa04ecbc3
commit a929e43205

View File

@@ -20,7 +20,12 @@ Help()
echo "If using the help flag, put the H flag at the end of the command after other flags." echo "If using the help flag, put the H flag at the end of the command after other flags."
} }
if [ -d "/home/lanforge/lanforge_env"] && pip3 install --upgrade lanforge-scripts || pip3 install --user -r ../requirements.txt --upgrade if [ -d "/home/lanforge/lanforge_env" ];
then
pip3 install --upgrade lanforge-scripts
else
pip3 install --user -r ../requirements.txt --upgrade
fi
while getopts ":h:s:S:p:w:m:A:r:F:B:U:D:H:" option; do while getopts ":h:s:S:p:w:m:A:r:F:B:U:D:H:" option; do
case "${option}" in case "${option}" in
@@ -499,28 +504,38 @@ function test() {
start=$(date +%s) start=$(date +%s)
# this command saves stdout and stderr to the stdout file, and has a special file for stderr text. # this command saves stdout and stderr to the stdout file, and has a special file for stderr text.
# Modified from https://unix.stackexchange.com/a/364176/327076 # Modified from https://unix.stackexchange.com/a/364176/327076
{ eval "$testcommand" 2>&1 >&3 3>&- | tee "${TEST_DIR}/${NAME}_stderr.txt" 3>&-; } > "${TEST_DIR}/${NAME}.txt" 3>&1 FILENAME="${TEST_DIR}/${NAME}"
chmod 664 "${TEST_DIR}/${NAME}.txt" { eval "$testcommand" 2>&1 >&3 3>&- | tee "${FILENAME}_stderr.txt" 3>&-; } > "${FILENAME}.txt" 3>&1
FILESIZE=$(stat -c%s "${TEST_DIR}/${NAME}_stderr.txt") || 0 chmod 664 "${FILENAME}.txt"
FILESIZE=$(stat -c%s "${FILENAME}_stderr.txt") || 0
end=$(date +%s) end=$(date +%s)
execution="$((end-start))" execution="$((end-start))"
if (( FILESIZE > 0)); then TEXT=$(cat "${FILENAME}".txt)
STDERR=""
if [[ "tests failed" == *"${TEXT}" ]]
then
TEXTCLASS="partial_failure"
TDTEXT="Partial Failure"
else
TEXTCLASS="success"
TDTEXT="Success"
fi
if (( FILESIZE > 0))
then
echo "Errors detected" echo "Errors detected"
results+=("<tr><td>${CURR_TEST_NAME}</td> TEXTCLASS="failure"
<td class='scriptdetails'>${testcommand}</td> TDTEXT="Failure"
<td class='failure'>Failure</td> STDERR="<a href=\"${URL2}/${NAME}_stderr.txt\" target=\"_blank\">STDERR</a>"
<td>${execution}</td>
<td><a href=\"${URL2}/${NAME}.txt\" target=\"_blank\">STDOUT</a></td>
<td><a href=\"${URL2}/${NAME}_stderr.txt\" target=\"_blank\">STDERR</a></td></tr>")
else else
echo "No errors detected" echo "No errors detected"
fi
results+=("<tr><td>${CURR_TEST_NAME}</td> results+=("<tr><td>${CURR_TEST_NAME}</td>
<td class='scriptdetails'>${testcommand}</td> <td class='scriptdetails'>${testcommand}</td>
<td class='success'>Success</td> <td class='${TEXTCLASS}'>${TDTEXT}</td>
<td>${execution}</td> <td>${execution}</td>
<td><a href=\"${URL2}/${NAME}.txt\" target=\"_blank\">STDOUT</a></td> <td><a href=\"${URL2}/${NAME}.txt\" target=\"_blank\">STDOUT</a></td>
<td></td></tr>") <td>${STDERR}</td></tr>")
fi
} }
function start_tests() { function start_tests() {