summaryrefslogtreecommitdiffstats
path: root/src/vat
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-01-18 13:28:22 +0100
committerDamjan Marion <dmarion@me.com>2019-01-20 16:14:24 +0000
commit4d2f86a1ebcfc952080386603354c4767d2c8825 (patch)
treed20ed373877bfbf145d3b7ed0773a0cdbfaee32e /src/vat
parente67c1d8242fec255e7449fedcbdec5c66bb3f7b2 (diff)
Rework of debian packaging
Change-Id: Ifede85d3af36f3ee6c6f8f92dcf5db0ed8f1bfeb Signed-off-by: Damjan Marion <damarion@cisco.com> Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vat')
-rw-r--r--src/vat/main.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/vat/main.c b/src/vat/main.c
index 295ccec2515..a5421140fb3 100644
--- a/src/vat/main.c
+++ b/src/vat/main.c
@@ -15,6 +15,7 @@
#include "vat.h"
#include "plugin.h"
#include <signal.h>
+#include <limits.h>
vat_main_t vat_main;
@@ -283,6 +284,37 @@ setup_signal_handlers (void)
}
}
+static void
+vat_find_plugin_path ()
+{
+ extern char *vat_plugin_path;
+ char *p, path[PATH_MAX];
+ int rv;
+ u8 *s;
+
+ /* find executable path */
+ if ((rv = readlink ("/proc/self/exe", path, PATH_MAX - 1)) == -1)
+ return;
+
+ /* readlink doesn't provide null termination */
+ path[rv] = 0;
+
+ /* strip filename */
+ if ((p = strrchr (path, '/')) == 0)
+ return;
+ *p = 0;
+
+ /* strip bin/ */
+ if ((p = strrchr (path, '/')) == 0)
+ return;
+ *p = 0;
+
+ s = format (0, "%s/lib/" CLIB_TARGET_TRIPLET "/vpp_api_test_plugins:"
+ "%s/lib/vpp_api_test_plugins", path, path);
+ vec_add1 (s, 0);
+ vat_plugin_path = (char *) s;
+}
+
int
main (int argc, char **argv)
{
@@ -309,6 +341,8 @@ main (int argc, char **argv)
vec_validate (vam->cmd_reply, 0);
vec_reset_length (vam->cmd_reply);
+ vat_find_plugin_path ();
+
unformat_init_command_line (a, argv);
while (unformat_check_input (a) != UNFORMAT_END_OF_INPUT)