Merge pull request #753 from dcooper16/mass_testing_command_line_error

Massing testing with command line error
This commit is contained in:
Dirk Wetter 2017-05-31 21:37:54 +02:00 committed by GitHub
commit bd015b9129

View File

@ -316,6 +316,7 @@ declare -a -i PARALLEL_TESTING_PID=() # process id for each child test (or 0
declare -a PARALLEL_TESTING_CMDLINE=() # command line for each child test
declare -i NR_PARALLEL_TESTS=0 # number of parallel tests run
declare -i NEXT_PARALLEL_TEST_TO_FINISH=0 # number of parallel tests that have completed and have been processed
declare FIRST_JSON_OUTPUT=true # true if no output has been added to $JSONFILE yet.
#################### SEVERITY ####################
@ -341,7 +342,7 @@ set_severity_level() {
SEVERITY_LEVEL=$CRITICAL
else
echo "Supported severity levels are LOW, MEDIUM, HIGH, CRITICAL!"
help
help 1
fi
}
@ -11175,6 +11176,10 @@ Options requiring a value can also be called with '=' e.g. testssl.sh -t=smtp --
URI always needs to be the last parameter.
EOF
# Set HTMLHEADER and JSONHEADER to false so that the cleanup() function won't
# try to write footers to the HTML and JSON files.
HTMLHEADER=false
JSONHEADER=false
#' Fix syntax highlight on sublime
"$CHILD_MASS_TESTING" && kill -s USR1 $PPID
exit $1
@ -12196,7 +12201,19 @@ create_mass_testing_cmdline() {
# next is the file itself, as no '=' was supplied
[[ "$cmd" == '--file' ]] && skip_next=true
elif [[ "$testing_type" == "serial" ]]; then
MASS_TESTING_CMDLINE[nr_cmds]="$cmd"
if "$JSONHEADER" && [[ "$cmd" == "--jsonfile-pretty"* ]]; then
>"$TEMPDIR/jsonfile_child.json"
MASS_TESTING_CMDLINE[nr_cmds]="--jsonfile-pretty=$TEMPDIR/jsonfile_child.json"
# next is the jsonfile itself, as no '=' was supplied
[[ "$cmd" == --jsonfile-pretty ]] && skip_next=true
elif "$JSONHEADER" && [[ "$cmd" == "--jsonfile"* ]]; then
>"$TEMPDIR/jsonfile_child.json"
MASS_TESTING_CMDLINE[nr_cmds]="--jsonfile=$TEMPDIR/jsonfile_child.json"
# next is the jsonfile itself, as no '=' was supplied
[[ "$cmd" == --jsonfile ]] && skip_next=true
else
MASS_TESTING_CMDLINE[nr_cmds]="$cmd"
fi
nr_cmds+=1
else
case "$cmd" in
@ -12273,14 +12290,19 @@ run_mass_testing() {
create_mass_testing_cmdline "serial" $cmdline
draw_line "=" $((TERM_WIDTH / 2)); outln;
outln "$(create_cmd_line_string "$0" "${MASS_TESTING_CMDLINE[@]}")"
"$first" || fileout_separator # this is needed for appended output, see #687
# we call ourselves here. $do_mass_testing is the parent, $CHILD_MASS_TESTING... you figured
if [[ -z "$(which "$0")" ]]; then
CHILD_MASS_TESTING=true "$RUN_DIR/$PROG_NAME" "${MASS_TESTING_CMDLINE[@]}"
else
CHILD_MASS_TESTING=true "$0" "${MASS_TESTING_CMDLINE[@]}"
fi
first=false
if "$JSONHEADER" && [[ -s "$TEMPDIR/jsonfile_child.json" ]]; then
# Need to ensure that a separator is only added if the test
# produced some JSON output.
"$first" || fileout_separator # this is needed for appended output, see #687
first=false
cat "$TEMPDIR/jsonfile_child.json" >> "$JSONFILE"
fi
done < "${FNAME}"
return $?
}
@ -12296,8 +12318,13 @@ get_next_message_testing_parallel_result() {
outln "${PARALLEL_TESTING_CMDLINE[NEXT_PARALLEL_TEST_TO_FINISH]}"
if [[ "$1" == "completed" ]]; then
cat "$TEMPDIR/term_output_$(printf "%08d" $NEXT_PARALLEL_TEST_TO_FINISH).log"
[[ $NEXT_PARALLEL_TEST_TO_FINISH -gt 0 ]] && fileout_separator # this is needed for appended output, see #687
"$JSONHEADER" && cat "$TEMPDIR/jsonfile_$(printf "%08d" $NEXT_PARALLEL_TEST_TO_FINISH).json" >> "$JSONFILE"
if "$JSONHEADER" && [[ -s "$TEMPDIR/jsonfile_$(printf "%08d" $NEXT_PARALLEL_TEST_TO_FINISH).json" ]]; then
# Need to ensure that a separator is only added if the test
# produced some JSON output.
"$FIRST_JSON_OUTPUT" || fileout_separator # this is needed for appended output, see #687
FIRST_JSON_OUTPUT=false
cat "$TEMPDIR/jsonfile_$(printf "%08d" $NEXT_PARALLEL_TEST_TO_FINISH).json" >> "$JSONFILE"
fi
"$CSVHEADER" && cat "$TEMPDIR/csvfile_$(printf "%08d" $NEXT_PARALLEL_TEST_TO_FINISH).csv" >> "$CSVFILE"
"$HTMLHEADER" && cat "$TEMPDIR/htmlfile_$(printf "%08d" $NEXT_PARALLEL_TEST_TO_FINISH).html" >> "$HTMLFILE"
elif [[ "$1" == "stopped" ]]; then