diff options
author | Klement Sekera <ksekera@cisco.com> | 2022-01-28 11:31:01 +0000 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2022-01-31 14:52:44 +0000 |
commit | c0a2f0ec9b2574441dd3280fe6ae25de5491f7a0 (patch) | |
tree | 27d25bc4513c7ad7b853e3fb15efc467615418d5 | |
parent | 6de58f5fd0c9d47a65e24d3617e465b9fa8d8872 (diff) |
tests: support skipping to test method with STEP
Allow entering a test name on stack trace window with STEP=y option
instead of a number. This allows to run a whole suite and skip all tests
until a particular test is hit.
Type: improvement
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I23e45f8022b82545365b8921390e0e106e02b39c
-rw-r--r-- | test/hook.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/test/hook.py b/test/hook.py index 7f2b8e01640..7f7a7c31b25 100644 --- a/test/hook.py +++ b/test/hook.py @@ -149,11 +149,24 @@ class StepHook(PollHook): self.skip_stack = None self.skip_num = None self.skip_count = 0 + self.break_func = None super(StepHook, self).__init__(test) def skip(self): - if self.skip_stack is None: - return False + if self.break_func is not None: + return self.should_skip_func_based() + if self.skip_stack is not None: + return self.should_skip_stack_based() + + def should_skip_func_based(self): + stack = traceback.extract_stack() + for e in stack: + if e[2] == self.break_func: + self.break_func = None + return False + return True + + def should_skip_stack_based(self): stack = traceback.extract_stack() counter = 0 skip = True @@ -186,6 +199,7 @@ class StepHook(PollHook): print(single_line_delim) print("You may enter a number of stack frame chosen from above") print("Calls in/below that stack frame will be not be stepped anymore") + print("Alternatively, enter a test function name to stop at") print(single_line_delim) while True: print("Enter your choice, if any, and press ENTER to continue " @@ -197,6 +211,8 @@ class StepHook(PollHook): if choice is not None: num = int(choice) except ValueError: + if choice.startswith("test_"): + break print("Invalid input") continue if choice is not None and (num < 0 or num >= len(stack)): @@ -204,8 +220,12 @@ class StepHook(PollHook): continue break if choice is not None: - self.skip_stack = stack - self.skip_num = num + if choice.startswith("test_"): + self.break_func = choice + else: + self.break_func = None + self.skip_stack = stack + self.skip_num = num def before_cli(self, cli): """ Wait for ENTER before executing CLI """ |