summaryrefslogtreecommitdiff
path: root/src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py')
-rw-r--r--src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py b/src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py
index d44dee4333..61328a14fb 100644
--- a/src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py
+++ b/src/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py
@@ -1,4 +1,4 @@
1# $OpenBSD: tlsfuzzer.py,v 1.42 2021/09/03 13:26:20 tb Exp $ 1# $OpenBSD: tlsfuzzer.py,v 1.43 2021/09/03 14:50:36 tb Exp $
2# 2#
3# Copyright (c) 2020 Theo Buehler <tb@openbsd.org> 3# Copyright (c) 2020 Theo Buehler <tb@openbsd.org>
4# 4#
@@ -593,13 +593,14 @@ class TestRunner:
593 """ Runs the given tests troups against a server and displays stats. """ 593 """ Runs the given tests troups against a server and displays stats. """
594 594
595 def __init__( 595 def __init__(
596 self, timing=False, verbose=False, port=4433, use_tls1_3=True, 596 self, timing=False, verbose=False, host="localhost", port=4433,
597 dry_run=False, tests=[], scriptdir=tlsfuzzer_scriptdir, 597 use_tls1_3=True, dry_run=False, tests=[], scriptdir=tlsfuzzer_scriptdir,
598 ): 598 ):
599 self.tests = [] 599 self.tests = []
600 600
601 self.dryrun = dry_run 601 self.dryrun = dry_run
602 self.use_tls1_3 = use_tls1_3 602 self.use_tls1_3 = use_tls1_3
603 self.host = host
603 self.port = str(port) 604 self.port = str(port)
604 self.scriptdir = scriptdir 605 self.scriptdir = scriptdir
605 606
@@ -619,7 +620,7 @@ class TestRunner:
619 620
620 def run_script(self, test): 621 def run_script(self, test):
621 script = test.name 622 script = test.name
622 args = ["-p"] + [self.port] + test.args(self.use_tls1_3) 623 args = ["-h"] + [self.host] + ["-p"] + [self.port] + test.args(self.use_tls1_3)
623 624
624 if self.dryrun: 625 if self.dryrun:
625 if not self.verbose: 626 if not self.verbose:
@@ -685,11 +686,11 @@ class TestRunner:
685class TlsServer: 686class TlsServer:
686 """ Spawns an s_server listening on localhost:port if necessary. """ 687 """ Spawns an s_server listening on localhost:port if necessary. """
687 688
688 def __init__(self, port=4433): 689 def __init__(self, host="localhost", port=4433):
689 self.spawn = True 690 self.spawn = True
690 # Check whether a server is already listening on localhost:port 691 # Check whether a server is already listening on localhost:port
691 self.spawn = subprocess.run( 692 self.spawn = subprocess.run(
692 ["nc", "-c", "-z", "-T", "noverify", "localhost", str(port)], 693 ["nc", "-c", "-z", "-T", "noverify", host, str(port)],
693 stderr=subprocess.DEVNULL, 694 stderr=subprocess.DEVNULL,
694 ).returncode != 0 695 ).returncode != 0
695 696
@@ -785,18 +786,21 @@ def main():
785 list = False 786 list = False
786 missing = False 787 missing = False
787 dryrun = False 788 dryrun = False
789 host = "localhost"
788 port = 4433 790 port = 4433
789 slow = False 791 slow = False
790 timing = False 792 timing = False
791 verbose = False 793 verbose = False
792 794
793 argv = sys.argv[1:] 795 argv = sys.argv[1:]
794 opts, args = getopt.getopt(argv, "flmnp:stv", ["help"]) 796 opts, args = getopt.getopt(argv, "fh:lmnp:stv", ["help"])
795 for opt, arg in opts: 797 for opt, arg in opts:
796 if opt == '--help': 798 if opt == '--help':
797 usage() 799 usage()
798 elif opt == '-f': 800 elif opt == '-f':
799 failing = True 801 failing = True
802 elif opt == '-h':
803 host = arg
800 elif opt == '-l': 804 elif opt == '-l':
801 list = True 805 list = True
802 elif opt == '-m': 806 elif opt == '-m':
@@ -827,9 +831,9 @@ def main():
827 if list or missing: 831 if list or missing:
828 list_or_missing(missing) 832 list_or_missing(missing)
829 833
830 tls_server = TlsServer(port) 834 tls_server = TlsServer(host, port)
831 835
832 tests = TestRunner(timing, verbose, port, tls_server.has_tls1_3, dryrun) 836 tests = TestRunner(timing, verbose, host, port, tls_server.has_tls1_3, dryrun)
833 837
834 if args: 838 if args:
835 (dir, script) = os.path.split(args[0]) 839 (dir, script) = os.path.split(args[0])