Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flags to run_all.py for customizing test timeout and subdirectory traversal behavior #55

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions gtests/net/packetdrill/run_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,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):
Expand Down Expand Up @@ -142,7 +143,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):
Expand Down Expand Up @@ -208,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']]
Expand Down Expand Up @@ -236,9 +237,13 @@ 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')
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())

Expand Down