Skip to content

Commit 501679f

Browse files
tammelakuba-moo
authored andcommitted
selftests: tc-testing: cleanup on Ctrl-C
Cleanup net namespaces and other resources if we get a SIGINT (Ctrl-C). As user visible resources are allocated on a per test basis, it's only required to catch this condition when (possibly) running tests. So far calling post_suite is enough to free up anything that might linger. A missing keyword replacement for nsPlugin is also included. Signed-off-by: Pedro Tammela <[email protected]> Acked-by: Jamal Hadi Salim <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 56e16bc commit 501679f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def post_suite(self, index):
7878
print('{}.post_suite'.format(self.sub_class))
7979

8080
# Make sure we don't leak resources
81-
cmd = "$IP -a netns del"
81+
cmd = self._replace_keywords("$IP -a netns del")
8282

8383
if self.args.verbose > 3:
8484
print('_exec_cmd: command "{}"'.format(cmd))

tools/testing/selftests/tc-testing/tdc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,11 @@ def main():
10181018
if args.verbose > 2:
10191019
print('args is {}'.format(args))
10201020

1021-
set_operation_mode(pm, parser, args, remaining)
1021+
try:
1022+
set_operation_mode(pm, parser, args, remaining)
1023+
except KeyboardInterrupt:
1024+
# Cleanup on Ctrl-C
1025+
pm.call_post_suite(None)
10221026

10231027
if __name__ == "__main__":
10241028
main()

0 commit comments

Comments
 (0)