added verbose option (new default puts stdout and stderr in /dev/null)

This commit is contained in:
cwshugg 2022-03-28 20:10:48 -04:00
parent 5d9c9688d3
commit 005efe2f5e

View File

@ -267,6 +267,7 @@ def usage():
-t testname Run a test by itself, its name given as testname -t testname Run a test by itself, its name given as testname
-l List available tests -l List available tests
-6 host Hostname of IPv6 localhost (default: localhost6) -6 host Hostname of IPv6 localhost (default: localhost6)
-v Send output from the server to stdout
-o outputfile Send output from the server to an output file -o outputfile Send output from the server to an output file
""") """)
@ -2326,7 +2327,6 @@ class VideoStreaming(Doc_Print_Test_Case):
rg_left = "" if rg[0] == -1 else "%d" % rg[0] rg_left = "" if rg[0] == -1 else "%d" % rg[0]
rg_right = "" if rg[1] == -1 else "%d" % rg[1] rg_right = "" if rg[1] == -1 else "%d" % rg[1]
rgheader = "bytes=%s-%s" % (rg_left, rg_right) rgheader = "bytes=%s-%s" % (rg_left, rg_right)
print("TESTING: Range: %s" % rgheader)
# send a request with the Range header # send a request with the Range header
response = None response = None
@ -2467,7 +2467,7 @@ def print_points(minreq, extra, malicious, ipv6, auth, fallback, video):
if __name__ == '__main__': if __name__ == '__main__':
try: try:
opts, args = getopt.getopt(sys.argv[1:], "ndhs:t:o:l6:w", \ opts, args = getopt.getopt(sys.argv[1:], "ndhs:t:vo:l6:w", \
["help"]) ["help"])
except getopt.GetoptError as err: except getopt.GetoptError as err:
# print help information and exit: # print help information and exit:
@ -2477,6 +2477,7 @@ if __name__ == '__main__':
server_path = None server_path = None
run_slow = False run_slow = False
verbose = False
individual_test = None individual_test = None
runIPv6 = True runIPv6 = True
list_tests = False list_tests = False
@ -2495,6 +2496,8 @@ if __name__ == '__main__':
list_tests = True list_tests = True
elif o in ("-w"): elif o in ("-w"):
run_slow = True run_slow = True
elif o in ("-v"):
verbose = True
elif o in ("-o"): elif o in ("-o"):
output_file_name = a output_file_name = a
elif o in ("-6"): elif o in ("-6"):
@ -2562,8 +2565,15 @@ if __name__ == '__main__':
# Open the server on this machine # Open the server on this machine
server = subprocess.Popen(args, preexec_fn = make_new_pgrp, server = subprocess.Popen(args, preexec_fn = make_new_pgrp,
stdout=output_file, stderr=subprocess.STDOUT) stdout=output_file, stderr=subprocess.STDOUT)
else: elif verbose == False:
# open the server with stdout unspecified (by default it will go to
# the terminal).
server = subprocess.Popen(args, preexec_fn = make_new_pgrp) server = subprocess.Popen(args, preexec_fn = make_new_pgrp)
else:
# if the above fail, put stdout and stderr into /dev/null
server = subprocess.Popen(args, preexec_fn = make_new_pgrp,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
# Register the atexit function to shutdown the server on Python exit # Register the atexit function to shutdown the server on Python exit
atexit.register(make_clean_up_testing(server)) atexit.register(make_clean_up_testing(server))