X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Futil.py;h=1ab5c1f2350213d25579a145e3f32536f9ac0e9a;hb=ffba3c3;hp=512bf9e3b7eeca2916a362961768d019f23daed8;hpb=75e7d1301475d49311d14e202936c62df0c07d10;p=vpp.git diff --git a/test/util.py b/test/util.py index 512bf9e3b7e..1ab5c1f2350 100644 --- a/test/util.py +++ b/test/util.py @@ -2,15 +2,17 @@ import socket import sys +import os.path from abc import abstractmethod, ABCMeta from cStringIO import StringIO -from scapy.layers.inet6 import in6_mactoifaceid +from scapy.utils6 import in6_mactoifaceid from scapy.layers.l2 import Ether from scapy.packet import Raw from scapy.layers.inet import IP from scapy.layers.inet6 import IPv6, IPv6ExtHdrFragment, IPv6ExtHdrRouting,\ IPv6ExtHdrHopByHop +from scapy.utils import hexdump from socket import AF_INET6 @@ -20,6 +22,8 @@ def ppp(headline, packet): old_stdout = sys.stdout sys.stdout = o print(headline) + hexdump(packet) + print("") packet.show() sys.stdout = old_stdout return o.getvalue() @@ -65,6 +69,39 @@ def mk_ll_addr(mac): return addr +def ip6_normalize(ip6): + return socket.inet_ntop(socket.AF_INET6, + socket.inet_pton(socket.AF_INET6, ip6)) + + +def get_core_path(tempdir): + return "%s/%s" % (tempdir, get_core_pattern()) + + +def is_core_present(tempdir): + return os.path.isfile(get_core_path(tempdir)) + + +def get_core_pattern(): + with open("/proc/sys/kernel/core_pattern", "r") as f: + corefmt = f.read().strip() + return corefmt + + +def check_core_path(logger, core_path): + corefmt = get_core_pattern() + if corefmt.startswith("|"): + logger.error( + "WARNING: redirecting the core dump through a" + " filter may result in truncated dumps.") + logger.error( + " You may want to check the filter settings" + " or uninstall it and edit the" + " /proc/sys/kernel/core_pattern accordingly.") + logger.error( + " current core pattern is: %s" % corefmt) + + class NumericConstant(object): __metaclass__ = ABCMeta