From d83eccdff435f60fdd483bd4b902bf8a1d95531e Mon Sep 17 00:00:00 2001 From: Neetha John Date: Wed, 30 Jun 2021 04:03:21 -0700 Subject: [PATCH] [202012] [pfcwd] Fix the return code in invalid case (#1698) Backport #1691 - What I did Set the correct return code when pfcwd command is specified with invalid options Signed-off-by: Neetha John --- pfcwd/main.py | 2 +- tests/pfcwd_test.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pfcwd/main.py b/pfcwd/main.py index 9b038316ca..99118e0638 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -244,7 +244,7 @@ def start(self, action, restoration_time, ports, detection_time): click.echo("Failed to run command, invalid options:") for opt in invalid_ports: click.echo(opt) - exit() + exit(1) self.start_cmd(action, restoration_time, ports, detection_time) diff --git a/tests/pfcwd_test.py b/tests/pfcwd_test.py index 9a97ff7b33..bbd50f4220 100644 --- a/tests/pfcwd_test.py +++ b/tests/pfcwd_test.py @@ -255,7 +255,7 @@ def test_pfcwd_start_ports_invalid(self): obj=db ) print(result.output) - assert result.exit_code == 0 + assert result.exit_code == 1 assert result.output == pfcwd_show_start_config_output_fail @classmethod @@ -447,7 +447,7 @@ def test_pfcwd_start_ports_masic_invalid(self): obj=db ) print(result.output) - assert result.exit_code == 0 + assert result.exit_code == 1 assert result.output == show_pfc_config_start_fail # get config after the command, config shouldn't change