diff options
author | Damjan Marion <damarion@cisco.com> | 2021-09-30 20:04:14 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2021-10-05 16:44:32 +0000 |
commit | 5546e43f7943d6edff6c6587ed4e7233e8002e28 (patch) | |
tree | 16b4a8ce7a63c4cf1ce7f367b0d0f1d9268f2849 | |
parent | efd967faff168d037066b6e6824d2a579adbef93 (diff) |
build: don't hardcode triplet, allow specifying custom lib dir
Type: fix
Change-Id: I33f364fda88914f88f9b976cb83e6d3ff466f0bb
Signed-off-by: Damjan Marion <damarion@cisco.com>
Signed-off-by: Ray Kinsella <mdr@ashroe.eu>
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | src/CMakeLists.txt | 6 | ||||
-rwxr-xr-x | src/pkg/debian/rules.in | 7 | ||||
-rw-r--r-- | src/vat/main.c | 3 | ||||
-rw-r--r-- | src/vat2/main.c | 3 | ||||
-rw-r--r-- | src/vlib/unix/plugin.c | 9 | ||||
-rw-r--r-- | src/vlib/unix/plugin.h | 1 | ||||
-rw-r--r-- | src/vpp/conf/startup.conf | 2 | ||||
-rw-r--r-- | src/vpp/vnet/main.c | 6 | ||||
-rw-r--r-- | src/vppinfra/config.h.in | 2 | ||||
-rwxr-xr-x | test/framework.py | 20 | ||||
-rwxr-xr-x | test/test_vcl.py | 24 |
12 files changed, 44 insertions, 44 deletions
@@ -377,8 +377,6 @@ wipe-release: test-wipe $(BR)/.deps.ok .PHONY: rebuild-release rebuild-release: wipe-release build-release -libexpand = $(subst $(subst ,, ),:,$(foreach lib,$(1),$(BR)/install-$(2)-native/vpp/$(lib)/$(3))) - export TEST_DIR ?= $(WS_ROOT)/test export RND_SEED ?= $(shell python3 -c 'import time; print(time.time())') @@ -388,10 +386,7 @@ define test make -C test \ VPP_BUILD_DIR=$(BR)/build-$(2)-native \ VPP_BIN=$(BR)/install-$(2)-native/vpp/bin/vpp \ - VPP_PLUGIN_PATH=$(call libexpand,$(libs),$(2),vpp_plugins) \ - VPP_TEST_PLUGIN_PATH=$(call libexpand,$(libs),$(2),vpp_api_test_plugins) \ VPP_INSTALL_PATH=$(BR)/install-$(2)-native/ \ - LD_LIBRARY_PATH=$(call libexpand,$(libs),$(2),) \ EXTENDED_TESTS=$(EXTENDED_TESTS) \ PYTHON=$(PYTHON) \ OS_ID=$(OS_ID) \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7bb5caad734..0448a5b640e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,6 +33,10 @@ if(CMAKE_VERSION VERSION_LESS 3.12) endmacro() endif() +if(NOT DEFINED CMAKE_INSTALL_LIBDIR AND EXISTS "/etc/debian_version") + set(CMAKE_INSTALL_LIBDIR "lib/${CMAKE_LIBRARY_ARCHITECTURE}") +endif() + include(CheckCCompilerFlag) include(CheckIPOSupported) include(GNUInstallDirs) @@ -152,7 +156,7 @@ endif() ############################################################################## option(VPP_SET_RPATH "Set rpath for resulting binaries and libraries." ON) if(VPP_SET_RPATH) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${VPP_LIBRARY_DIR}") endif() set(CMAKE_INSTALL_MESSAGE NEVER) diff --git a/src/pkg/debian/rules.in b/src/pkg/debian/rules.in index 15f8eb6f810..2af1fe7d966 100755 --- a/src/pkg/debian/rules.in +++ b/src/pkg/debian/rules.in @@ -23,8 +23,6 @@ build3vers := $(shell py3versions -sv) override_dh_strip: dh_strip --dbg-package=vpp-dbg -DEB_HOST_MULTIARCH = $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) - override_dh_install: @for c in @VPP_COMPONENTS@; do \ @CMAKE_COMMAND@ \ @@ -33,11 +31,6 @@ override_dh_install: -D CMAKE_INSTALL_PREFIX=@VPP_BINARY_DIR@/debian/$$c \ -P @CMAKE_BINARY_DIR@/cmake_install.cmake 2>&1 \ | grep -v 'Set runtime path of' ; \ - if [ -d debian/$$c/lib ] ; then \ - mv debian/$$c/lib debian/$$c/$(DEB_HOST_MULTIARCH) ; \ - mkdir -p debian/$$c/usr/lib ; \ - mv debian/$$c/$(DEB_HOST_MULTIARCH) debian/$$c/usr/lib ; \ - fi ; \ for d in bin include share ; do \ if [ -d debian/$$c/$$d ] ; then \ mkdir -p debian/$$c/usr ; \ diff --git a/src/vat/main.c b/src/vat/main.c index 70352e6bf95..c718197e30d 100644 --- a/src/vat/main.c +++ b/src/vat/main.c @@ -313,8 +313,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; } diff --git a/src/vat2/main.c b/src/vat2/main.c index 2d148472d42..dc27c6e608f 100644 --- a/src/vat2/main.c +++ b/src/vat2/main.c @@ -85,8 +85,7 @@ vat2_find_plugin_path () return; *p = 0; - s = format (0, "%s/lib/" CLIB_TARGET_TRIPLET "/vat2_plugins:" - "%s/lib/vat2_plugins", path, path); + s = format (0, "%s/" CLIB_LIB_DIR "/vat2_plugins", path, path); vec_add1 (s, 0); vat2_plugin_path = (char *) s; } diff --git a/src/vlib/unix/plugin.c b/src/vlib/unix/plugin.c index 4a7ff2753f2..891e2cb642d 100644 --- a/src/vlib/unix/plugin.c +++ b/src/vlib/unix/plugin.c @@ -594,7 +594,12 @@ vlib_plugin_early_init (vlib_main_t * vm) 0x7FFFFFFF /* aka no rate limit */ ); if (pm->plugin_path == 0) - pm->plugin_path = format (0, "%s%c", vlib_plugin_path, 0); + pm->plugin_path = format (0, "%s", vlib_plugin_path); + + if (pm->plugin_path_add) + pm->plugin_path = format (pm->plugin_path, ":%s", pm->plugin_path_add); + + pm->plugin_path = format (pm->plugin_path, "%c", 0); PLUGIN_LOG_DBG ("plugin path %s", pm->plugin_path); @@ -756,6 +761,8 @@ done: u8 *s = 0; if (unformat (input, "path %s", &s)) pm->plugin_path = s; + else if (unformat (input, "add-path %s", &s)) + pm->plugin_path_add = s; else if (unformat (input, "name-filter %s", &s)) pm->plugin_name_filter = s; else if (unformat (input, "vat-path %s", &s)) diff --git a/src/vlib/unix/plugin.h b/src/vlib/unix/plugin.h index e3555fe3ba9..1c46e6b196c 100644 --- a/src/vlib/unix/plugin.h +++ b/src/vlib/unix/plugin.h @@ -123,6 +123,7 @@ typedef struct /* paths and name filters */ u8 *plugin_path; + u8 *plugin_path_add; u8 *plugin_name_filter; u8 *vat_plugin_path; u8 *vat_plugin_name_filter; diff --git a/src/vpp/conf/startup.conf b/src/vpp/conf/startup.conf index ee10faa8683..a879db38864 100644 --- a/src/vpp/conf/startup.conf +++ b/src/vpp/conf/startup.conf @@ -201,6 +201,8 @@ cpu { # plugins { ## Adjusting the plugin path depending on where the VPP plugins are # path /ws/vpp/build-root/install-vpp-native/vpp/lib/vpp_plugins + ## Add additional directory to the plugin path + # add-path /tmp/vpp_plugins ## Disable all plugins by default and then selectively enable specific plugins # plugin default { disable } diff --git a/src/vpp/vnet/main.c b/src/vpp/vnet/main.c index e0c7b0dbf58..e9cef5e76a8 100644 --- a/src/vpp/vnet/main.c +++ b/src/vpp/vnet/main.c @@ -60,13 +60,11 @@ vpp_find_plugin_path () return; *p = 0; - s = format (0, "%s/lib/" CLIB_TARGET_TRIPLET "/vpp_plugins:" - "%s/lib/vpp_plugins", path, path); + s = format (0, "%s/" CLIB_LIB_DIR "/vpp_plugins", path, path); vec_add1 (s, 0); vlib_plugin_path = (char *) s; - 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; } diff --git a/src/vppinfra/config.h.in b/src/vppinfra/config.h.in index 7aad027a8b6..c2b804cd590 100644 --- a/src/vppinfra/config.h.in +++ b/src/vppinfra/config.h.in @@ -20,7 +20,7 @@ #define CLIB_LOG2_CACHE_LINE_BYTES @LOG2_CACHE_LINE_BYTES@ #endif -#define CLIB_TARGET_TRIPLET "@CMAKE_C_COMPILER_TARGET@" +#define CLIB_LIB_DIR "@VPP_LIBRARY_DIR@" #define CLIB_VECTOR_GROW_BY_ONE @VECTOR_GROW_BY_ONE@ #endif diff --git a/test/framework.py b/test/framework.py index 731c5e18043..aa533f7b641 100755 --- a/test/framework.py +++ b/test/framework.py @@ -415,18 +415,7 @@ class VppTestCase(CPUInterface, unittest.TestCase): c = os.getenv("CACHE_OUTPUT", "1") cls.cache_vpp_output = False if c.lower() in ("n", "no", "0") else True cls.vpp_bin = os.getenv('VPP_BIN', "vpp") - cls.plugin_path = os.getenv('VPP_PLUGIN_PATH') - cls.test_plugin_path = os.getenv('VPP_TEST_PLUGIN_PATH') - cls.extern_plugin_path = os.getenv('EXTERN_PLUGINS') - plugin_path = None - if cls.plugin_path is not None: - if cls.extern_plugin_path is not None: - plugin_path = "%s:%s" % ( - cls.plugin_path, cls.extern_plugin_path) - else: - plugin_path = cls.plugin_path - elif cls.extern_plugin_path is not None: - plugin_path = cls.extern_plugin_path + extern_plugin_path = os.getenv('EXTERN_PLUGINS') debug_cli = "" if cls.step or cls.debug_gdb or cls.debug_gdbserver: debug_cli = "cli-listen localhost:5002" @@ -454,6 +443,9 @@ class VppTestCase(CPUInterface, unittest.TestCase): "api-trace", "{", "on", "}", "api-segment", "{", "prefix", cls.get_api_segment_prefix(), "}", "cpu", "{", "main-core", str(cls.cpus[0]), ] + if extern_plugin_path is not None: + cls.extra_vpp_plugin_config.append( + "add-path %s" % extern_plugin_path) if cls.get_vpp_worker_count(): cls.vpp_cmdline.extend([ "corelist-workers", ",".join([str(x) for x in cls.cpus[1:]])]) @@ -473,10 +465,6 @@ class VppTestCase(CPUInterface, unittest.TestCase): if cls.extra_vpp_punt_config is not None: cls.vpp_cmdline.extend(cls.extra_vpp_punt_config) - if plugin_path is not None: - cls.vpp_cmdline.extend(["plugin_path", plugin_path]) - if cls.test_plugin_path is not None: - cls.vpp_cmdline.extend(["test_plugin_path", cls.test_plugin_path]) if not cls.debug_attach: cls.logger.info("vpp_cmdline args: %s" % cls.vpp_cmdline) diff --git a/test/test_vcl.py b/test/test_vcl.py index 68322651eb8..50d36d5317d 100755 --- a/test/test_vcl.py +++ b/test/test_vcl.py @@ -5,6 +5,7 @@ import unittest import os import subprocess import signal +import glob from framework import VppTestCase, VppTestRunner, running_extended_tests, \ Worker from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath, FibPathProto @@ -26,20 +27,33 @@ _have_iperf3 = have_app(iperf3) class VCLAppWorker(Worker): """ VCL Test Application Worker """ + libname = "libvcl_ldpreload.so" + + class LibraryNotFound(Exception): + pass + def __init__(self, build_dir, appname, executable_args, logger, env=None, role=None, *args, **kwargs): self.role = role + vpp_install_path = os.getenv('VPP_INSTALL_PATH') + + vcl_ldpreload_glob = "{}/**/{}".format(vpp_install_path, self.libname) + vcl_ldpreload_so = glob.glob(vcl_ldpreload_glob, recursive=True) + + if len(vcl_ldpreload_so) < 1: + raise LibraryNotFound("cannot locate library: {}".format( + self.libname)) + + vcl_ldpreload_so = vcl_ldpreload_so[0] + if env is None: env = {} - vcl_lib_dir = "%s/vpp/lib" % build_dir if "iperf" in appname: app = appname - env.update({'LD_PRELOAD': - "%s/libvcl_ldpreload.so" % vcl_lib_dir}) + env.update({'LD_PRELOAD': vcl_ldpreload_so}) elif "sock" in appname: app = "%s/vpp/bin/%s" % (build_dir, appname) - env.update({'LD_PRELOAD': - "%s/libvcl_ldpreload.so" % vcl_lib_dir}) + env.update({'LD_PRELOAD': vcl_ldpreload_so}) else: app = "%s/vpp/bin/%s" % (build_dir, appname) self.args = [app] + executable_args |