tests: add cli_return_response to vpp_papi_provider 35/22635/3
authorDave Barach <dave@barachs.net>
Wed, 9 Oct 2019 21:28:04 +0000 (17:28 -0400)
committerDave Wallace <dwallacelf@gmail.com>
Thu, 10 Oct 2019 15:51:09 +0000 (15:51 +0000)
To improve gcov/lcov code coverage stats, it's necessary to send
incorrect debug CLI commands; to force vpp into debug CLI error paths.

cli_return_response() sends commands and returns the response object,
so test vectors can handle failures.

Type: feature

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I4fab591c9d2e30c996f016e18e4fd69b9c5bed06

src/plugins/mactime/test/test_mactime.py
test/vpp_papi_provider.py

index ab3d537..892ae02 100644 (file)
@@ -149,7 +149,12 @@ class TestMactime(VppTestCase):
                 "show error"]
 
         for cmd in cmds:
-            self.logger.info(self.vapi.cli(cmd))
+            r = self.vapi.cli_return_response(cmd)
+            if r.retval != 0:
+                if hasattr(r, 'reply'):
+                    self.logger.info(cmd + " FAIL reply " + r.reply)
+                else:
+                    self.logger.info(cmd + " FAIL retval " + str(r.retval))
 
 if __name__ == '__main__':
     unittest.main(testRunner=VppTestRunner)
index 8cb7c97..12dcf10 100644 (file)
@@ -334,17 +334,28 @@ class VppPapiProvider(object):
         self.hook.after_api(api_fn.__name__, api_args)
         return reply
 
-    def cli(self, cli):
+    def cli_return_response(self, cli):
         """ Execute a CLI, calling the before/after hooks appropriately.
+        Return the reply without examining it
 
         :param cli: CLI to execute
-        :returns: CLI output
+        :returns: response object
 
         """
         self.hook.before_cli(cli)
         cli += '\n'
         r = self.papi.cli_inband(cmd=cli)
         self.hook.after_cli(cli)
+        return r
+
+    def cli(self, cli):
+        """ Execute a CLI, calling the before/after hooks appropriately.
+
+        :param cli: CLI to execute
+        :returns: CLI output
+
+        """
+        r = self.cli_return_response(cli)
         if r.retval == -156:
             raise CliSyntaxError(r.reply)
         if r.retval != 0: