From f2eb14d381b7e490c0ed1394d1955fa860d9b018 Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Thu, 21 Nov 2024 11:29:53 +0100 Subject: [PATCH] tests: save bmp pcap in logdir instead of /tmp DEBUG_PCAP can be set True to manually enable pcap debugging when running bmp tests. Save bmp pcap in logdir (ie. /tmp/topotests/bgp_bmp.bgp_bmp_X/ instead of /tmp. Signed-off-by: Louis Scalbert Signed-off-by: Philippe Guibert --- tests/topotests/bgp_bmp/test_bgp_bmp_1.py | 4 ++-- tests/topotests/bgp_bmp/test_bgp_bmp_2.py | 4 ++-- tests/topotests/lib/bmp_collector/bmpserver.py | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/topotests/bgp_bmp/test_bgp_bmp_1.py b/tests/topotests/bgp_bmp/test_bgp_bmp_1.py index 493f357f4b4b..9fc8e127720f 100644 --- a/tests/topotests/bgp_bmp/test_bgp_bmp_1.py +++ b/tests/topotests/bgp_bmp/test_bgp_bmp_1.py @@ -73,9 +73,9 @@ def setup_module(mod): tgen.start_topology() if DEBUG_PCAP: - tgen.gears["r1"].run("rm /tmp/bmp.pcap") + pcap_file = os.path.join(tgen.logdir, "r1/bmp.pcap") tgen.gears["r1"].run( - "tcpdump -nni r1-eth0 -s 0 -w /tmp/bmp.pcap &", stdout=None + "tcpdump -nni r1-eth0 -s 0 -w {} &".format(pcap_file), stdout=None ) for rname, router in tgen.routers().items(): diff --git a/tests/topotests/bgp_bmp/test_bgp_bmp_2.py b/tests/topotests/bgp_bmp/test_bgp_bmp_2.py index 82d3824a1b93..21e4ce8abeae 100644 --- a/tests/topotests/bgp_bmp/test_bgp_bmp_2.py +++ b/tests/topotests/bgp_bmp/test_bgp_bmp_2.py @@ -85,9 +85,9 @@ def setup_module(mod): ) bmp_reset_seq() if DEBUG_PCAP: - tgen.gears["r1vrf"].run("rm /tmp/bmp_vrf.pcap") + pcap_file = os.path.join(tgen.logdir, "r1vrf/bmp.pcap") tgen.gears["r1vrf"].run( - "tcpdump -nni r1vrf-eth0 -s 0 -w /tmp/bmp_vrf.pcap &", stdout=None + "tcpdump -nni r1vrf-eth0 -s 0 -w {} &".format(pcap_file), stdout=None ) for rname, router in tgen.routers().items(): diff --git a/tests/topotests/lib/bmp_collector/bmpserver.py b/tests/topotests/lib/bmp_collector/bmpserver.py index a7c9743c9604..c42c3875633f 100755 --- a/tests/topotests/lib/bmp_collector/bmpserver.py +++ b/tests/topotests/lib/bmp_collector/bmpserver.py @@ -5,6 +5,8 @@ # Authored by Farid Mihoub # import argparse +import errno +import logging # XXX: something more reliable should be used "Twisted" a great choice. import os