make test: save + dump VPP api trace log; VPP-640

Change-Id: I20aacc927f2b04f42b0a7220c4283560b4d2a359
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
diff --git a/test/framework.py b/test/framework.py
index beed180..90e0574 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -142,6 +142,7 @@
             debug_cli = "cli-listen localhost:5002"
         cls.vpp_cmdline = [cls.vpp_bin,
                            "unix", "{", "nodaemon", debug_cli, "}",
+                           "api-trace", "{", "on", "}",
                            "api-segment", "{", "prefix", cls.shm_prefix, "}"]
         if cls.plugin_path is not None:
             cls.vpp_cmdline.extend(["plugin_path", cls.plugin_path])
@@ -336,6 +337,16 @@
             self.logger.info(self.vapi.ppcli("show error"))
             self.logger.info(self.vapi.ppcli("show run"))
             self.registry.remove_vpp_config(self.logger)
+            # Save/Dump VPP api trace log
+            api_trace = "vpp_api_trace.%s.log" % self._testMethodName
+            tmp_api_trace = "/tmp/%s" % api_trace
+            vpp_api_trace_log = "%s/%s" % (self.tempdir, api_trace)
+            self.logger.info(self.vapi.ppcli("api trace save %s" % api_trace))
+            self.logger.info("Moving %s to %s\n" % (tmp_api_trace,
+                                                    vpp_api_trace_log))
+            os.rename(tmp_api_trace, vpp_api_trace_log)
+            self.logger.info(self.vapi.ppcli("api trace dump %s" %
+                                             vpp_api_trace_log))
 
     def setUp(self):
         """ Clear trace before running each test"""