From 4e4aa26c789f2c856a9cfa00d4289d60afe40045 Mon Sep 17 00:00:00 2001 From: Tanner Love Date: Wed, 14 Jul 2021 13:33:37 -0400 Subject: [PATCH 1/2] net-test: packetdrill: run_all: add timeout flag Enable passing a custom timeout value to run_all.py. If unspecified, the default remains 180. Tested: on kernel netdev-netnext/master HEAD at commit 5e437416ff669 (1) verify default timeout remains 180: $ python ./packetdrill/run_all.py -S -v -L -l tcp/mss/mss-getsockopt-tcp_maxseg-server.pkt OK [/export/hda3/tmp/tannerlove/net/tcp/mss/mss-getsockopt-tcp_maxseg-server.pkt (ipv4)] stdout: stderr: OK [/export/hda3/tmp/tannerlove/net/tcp/mss/mss-getsockopt-tcp_maxseg-server.pkt (ipv6)] stdout: stderr: OK [/export/hda3/tmp/tannerlove/net/tcp/mss/mss-getsockopt-tcp_maxseg-server.pkt (ipv4-mapped-v6)] stdout: stderr: Ran 3 tests: 3 passing, 0 failing, 0 timed out (3.83 sec): tcp/mss/mss-getsockopt-tcp_maxseg-server.pkt (2) verify -t 0 results in timeout: python ./packetdrill/run_all.py -S -v -L -l -t 0 tcp/mss/mss-getsockopt-tcp_maxseg-server.pkt KILL [/export/hda3/tmp/tannerlove/net/tcp/mss/mss-getsockopt-tcp_maxseg-server.pkt (ipv4)] stdout: stderr: KILL [/export/hda3/tmp/tannerlove/net/tcp/mss/mss-getsockopt-tcp_maxseg-server.pkt (ipv4-mapped-v6)] stdout: stderr: KILL [/export/hda3/tmp/tannerlove/net/tcp/mss/mss-getsockopt-tcp_maxseg-server.pkt (ipv6)] stdout: stderr: Ran 3 tests: 0 passing, 0 failing, 3 timed out (1.85 sec): tcp/mss/mss-getsockopt-tcp_maxseg-server.pkt Signed-off-by: Tanner Love --- gtests/net/packetdrill/run_all.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtests/net/packetdrill/run_all.py b/gtests/net/packetdrill/run_all.py index 516f2b20..beb5b583 100755 --- a/gtests/net/packetdrill/run_all.py +++ b/gtests/net/packetdrill/run_all.py @@ -19,7 +19,6 @@ def __init__(self, args): self.args = args self.tools_path = os.path.abspath('./packetdrill') self.default_args = '--send_omit_free' - self.max_runtime = 180 self.num_pass = 0 self.num_fail = 0 self.num_timedout = 0 @@ -142,7 +141,7 @@ def PollTest(self, test): def PollTestSet(self, procs, time_start): """Wait until a,l tests in procs have finished or until timeout.""" - while time.time() - time_start < self.max_runtime and procs: + while time.time() - time_start < self.args['timeout_sec'] and procs: time.sleep(1) for entry in procs: if self.PollTest(entry): @@ -239,6 +238,8 @@ def ParseArgs(): args.add_argument('-p', '--parallelize_dirs', action='store_true') args.add_argument('-s', '--subdirs', action='store_true') args.add_argument('-S', '--serialized', action='store_true') + args.add_argument('-t', '--timeout_sec', nargs='?', const=180, type=int, + default=180) args.add_argument('-v', '--verbose', action='store_true') return vars(args.parse_args()) From cc2a0bbd76429592853f1557d06e7601ce69d539 Mon Sep 17 00:00:00 2001 From: Tanner Love Date: Wed, 14 Jul 2021 16:14:13 -0400 Subject: [PATCH 2/2] net-test: packetdrill: run_all: add --no-traverse_subdirs flag When flag is specified, run_all.py does not look for .pkt files in subdirectories of the specified directory. Tested: (on kernel netdev-netnext/master HEAD at commit 5e437416ff669) Currently there are no existing cases where we have both a foo/bar.pkt and a foo/baz/buz.pkt. To simulate this likely future scenario, I did: (0) setup: duplicate a test in a parent dir $ cp gtests/net/tcp/fastopen/server/client-ack-dropped-then-recovery-ms-timestamps.pkt \ gtests/net/tcp/fastopen/client-ack-dropped-then-recovery-ms-timestamps.pkt (1) verify that subdirs are traversed when flag is not specified $ python ./packetdrill/run_all.py -S -v -L -l tcp/fastopen OK [/export/hda3/tmp/tannerlove/net/tcp/fastopen/client-ack-dropped-then-recovery-ms-timestamps.pkt (ipv4)] stdout: stderr: OK [/export/hda3/tmp/tannerlove/net/tcp/fastopen/client-ack-dropped-then-recovery-ms-timestamps.pkt (ipv6)] stdout: stderr: OK [/export/hda3/tmp/tannerlove/net/tcp/fastopen/server/client-ack-dropped-then-recovery-ms-timestamps.pkt (ipv4-mapped-v6)] stdout: stderr: OK [/export/hda3/tmp/tannerlove/net/tcp/fastopen/client-ack-dropped-then-recovery-ms-timestamps.pkt (ipv4-mapped-v6)] stdout: stderr: OK [/export/hda3/tmp/tannerlove/net/tcp/fastopen/server/client-ack-dropped-then-recovery-ms-timestamps.pkt (ipv6)] stdout: stderr: OK [/export/hda3/tmp/tannerlove/net/tcp/fastopen/server/client-ack-dropped-then-recovery-ms-timestamps.pkt (ipv4)] stdout: stderr: Ran 6 tests: 6 passing, 0 failing, 0 timed out (4.32 sec): tcp/fastopen (2) verify that subdirs are not traversed when flag is specified $ python ./packetdrill/run_all.py -S -v -L -l --no-traverse_subdirs tcp/fastopen OK [/export/hda3/tmp/tannerlove/net/tcp/fastopen/client-ack-dropped-then-recovery-ms-timestamps.pkt (ipv4)] stdout: stderr: OK [/export/hda3/tmp/tannerlove/net/tcp/fastopen/client-ack-dropped-then-recovery-ms-timestamps.pkt (ipv6)] stdout: stderr: OK [/export/hda3/tmp/tannerlove/net/tcp/fastopen/client-ack-dropped-then-recovery-ms-timestamps.pkt (ipv4-mapped-v6)] stdout: stderr: Ran 3 tests: 3 passing, 0 failing, 0 timed out (2.64 sec): tcp/fastopen Signed-off-by: Tanner Love --- gtests/net/packetdrill/run_all.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gtests/net/packetdrill/run_all.py b/gtests/net/packetdrill/run_all.py index beb5b583..df7931c9 100755 --- a/gtests/net/packetdrill/run_all.py +++ b/gtests/net/packetdrill/run_all.py @@ -31,6 +31,8 @@ def FindTests(self, path='.'): for dirpath, _, filenames in os.walk(path): for filename in fnmatch.filter(filenames, '*.pkt'): tests.append(dirpath + '/' + filename) + if not self.args['traverse_subdirs']: + break return sorted(tests) def StartTest(self, path, variant, extra_args=None): @@ -207,7 +209,7 @@ def RunAll(self, args): """Construct a test set for each subdirectory and run them in parallel.""" errors = 0 - if args['subdirs']: + if args['subdirs'] and args['traverse_subdirs']: paths = self.FindSubDirs(args['path']) else: paths = [args['path']] @@ -235,6 +237,8 @@ def ParseArgs(): help='requires verbose') args.add_argument('-L', '--log_on_success', action='store_true', help='requires verbose') + args.add_argument('--no-traverse_subdirs', dest='traverse_subdirs', + action='store_false') args.add_argument('-p', '--parallelize_dirs', action='store_true') args.add_argument('-s', '--subdirs', action='store_true') args.add_argument('-S', '--serialized', action='store_true')