summaryrefslogtreecommitdiffstats
path: root/test/vpp_lo_interface.py
blob: 36f56bed8d7337d77baf0fad0ee767ed427a4fa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from vpp_object import VppObject
from vpp_interface import VppInterface


class VppLoInterface(VppInterface, VppObject):
    """VPP loopback interface."""

    def __init__(self, test):
        """ Create VPP loopback interface """
        super(VppLoInterface, self).__init__(test)
        self.add_vpp_config()

    def add_vpp_config(self):
        r = self.test.vapi.create_loopback()
        self.set_sw_if_index(r.sw_if_index)

    def remove_vpp_config(self):
        self.test.vapi.delete_loopback(self.sw_if_index)

    def object_id(self):
        return "loopback-%d" % self._sw_if_index
MPILER_VERSION_GTE(major, minor) \ (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) #elif defined(__clang__) #define COMPILER_VERSION_GTE(major, minor) \ (__clang_major__ > (major) || \ (__clang_major__ == (major) && __clang_minor__ >= (minor))) #else /* disable all warning customization for all other compilers */ #define COMPILER_VERSION_GTE(maj, min) 0 #endif /* '#' needs to preceed a macro parameter */ #define WARN_TOSTR(x) #x /* * Macros to toggle off/on warnings * * Start by silencing pragma warnings so that we can explicitly silence * a warning introduced on some compiler version and not get a warning on older * versions of that same compiler. * * gcc corresponding warning is "Wpargma" * clang corresponding warning is "Wunknown-warning-option" * * For example, Wtautological-compare is introduced in gcc-6 and this would * trigger a Wpargma warning on gcc-5. * * Example usage to disable -Wtautological-compare warning: * WARN_OFF(tautological-compare) * if (...) { * WARN_ON(tautological-compare) * ; // conditional code * } */ #if defined(__GNUC__) && COMPILER_VERSION_GTE(4, 6) /* * GCC option to locally ignore warning was introduced in gcc-4.6 * gcc.gnu.org/gcc-4.6/changes.html */ #define WARN_PRAGMA(x) _Pragma (WARN_TOSTR (GCC diagnostic x)) #define WARN_OFF(x) \ WARN_PRAGMA (push) WARN_PRAGMA (ignored "-Wpragmas") \ WARN_PRAGMA (push) WARN_PRAGMA (ignored WARN_TOSTR (-W##x)) #define WARN_ON(x) \ WARN_PRAGMA (pop) \ WARN_PRAGMA (pop) #elif defined(__clang__) && COMPILER_VERSION_GTE(3, 3) /* * clang option to locally ignore warning was introduced in clang-3.3 * releases.llvm.org/3.3/tools/clang/docs/UsersManual.html#controlling-diagnostics-via-pragmas */ #define WARN_PRAGMA(x) _Pragma (WARN_TOSTR (clang diagnostic x)) #define WARN_OFF(x) \ WARN_PRAGMA (push) WARN_PRAGMA (ignored "-Wunknown-warning-option") \ WARN_PRAGMA (push) WARN_PRAGMA (ignored WARN_TOSTR (-W##x)) #define WARN_ON(x) \ WARN_PRAGMA (pop) \ WARN_PRAGMA (pop) #else /* Ignore WARN_* instruction for all other compilers */ #define WARN_OFF(x) #define WARN_ON(x) #endif /* * Clang supports a wider range of warnings than gcc. * Use those specific macros for the warnings that are only supported by clang */ #ifdef __clang__ #define WARN_OFF_CLANG(x) WARN_OFF (x) #define WARN_ON_CLANG(x) WARN_ON (x) #else #define WARN_OFF_CLANG(x) #define WARN_ON_CLANG(x) #endif /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */ #endif /* __included_warnings_h__ */