tests: fix test-help formatting
[vpp.git] / src / vat / main.c
index 70352e6..e7c0818 100644 (file)
@@ -13,6 +13,7 @@
  * limitations under the License.
  */
 #include "vat.h"
+#include <dlfcn.h>
 #include "plugin.h"
 #include <signal.h>
 #include <limits.h>
@@ -97,7 +98,7 @@ do_one_file (vat_main_t * vam)
            rv = write (1, "exec# ", 6);
        }
 
-      _vec_len (vam->inbuf) = 4096;
+      vec_set_len (vam->inbuf, 4096);
 
       if (vam->do_exit ||
          fgets ((char *) vam->inbuf, vec_len (vam->inbuf), vam->ifp) == 0)
@@ -181,7 +182,7 @@ do_one_file (vat_main_t * vam)
       if (vam->regenerate_interface_table)
        {
          vam->regenerate_interface_table = 0;
-         api_sw_interface_dump (vam);
+         vam->api_sw_interface_dump (vam);
        }
 
       /* Hack to pick up new client index after memfd_segment_create pivot */
@@ -266,6 +267,7 @@ setup_signal_handlers (void)
          /* these signals take the default action */
        case SIGABRT:
        case SIGKILL:
+       case SIGCONT:
        case SIGSTOP:
        case SIGUSR1:
        case SIGUSR2:
@@ -313,8 +315,7 @@ vat_find_plugin_path ()
     return;
   *p = 0;
 
-  s = format (0, "%s/lib/" CLIB_TARGET_TRIPLET "/vpp_api_test_plugins:"
-             "%s/lib/vpp_api_test_plugins", path, path);
+  s = format (0, "%s/" CLIB_LIB_DIR "/vpp_api_test_plugins", path, path);
   vec_add1 (s, 0);
   vat_plugin_path = (char *) s;
 }
@@ -381,6 +382,30 @@ vlib_call_init_exit_functions (vlib_main_t *vm,
                                            1 /* do_sort */, is_global);
 }
 
+static void
+vat_register_interface_dump (vat_main_t *vam)
+{
+  void *handle;
+  plugin_info_t *pi;
+
+  vec_foreach (pi, vat_plugin_main.plugin_info)
+    {
+      handle = dlsym (pi->handle, "api_sw_interface_dump");
+      if (handle)
+       {
+         vam->api_sw_interface_dump = handle;
+         break;
+       }
+    }
+
+  if (!vam->api_sw_interface_dump)
+    {
+      fformat (stderr,
+              "sw_interface_dump not found in interface_test plugin!\n");
+      exit (1);
+    }
+}
+
 int
 main (int argc, char **argv)
 {
@@ -485,9 +510,6 @@ main (int argc, char **argv)
 
   vam->json_output = json_output;
 
-  if (!json_output)
-    api_sw_interface_dump (vam);
-
   vec_validate (vam->inbuf, 4096);
 
   load_features ();
@@ -495,6 +517,11 @@ main (int argc, char **argv)
   vam->current_file = (u8 *) "plugin-init";
   vat_plugin_init (vam);
 
+  vat_register_interface_dump (vam);
+
+  if (!json_output)
+    vam->api_sw_interface_dump (vam);
+
   /* Set up the init function hash table */
   vgm->init_functions_called = hash_create (0, 0);