diff --git a/modules/test/ntp/python/src/ntp_module.py b/modules/test/ntp/python/src/ntp_module.py index 22fbf40ed..33729a8d1 100644 --- a/modules/test/ntp/python/src/ntp_module.py +++ b/modules/test/ntp/python/src/ntp_module.py @@ -14,6 +14,7 @@ """NTP test module""" from test_module import TestModule from scapy.all import rdpcap, IP, IPv6, NTP, UDP, Ether +from scapy.error import Scapy_Exception import os from collections import defaultdict @@ -185,8 +186,12 @@ def extract_ntp_data(self): # Read the pcap files packets = (rdpcap(self.startup_capture_file) + - rdpcap(self.monitor_capture_file) + - rdpcap(self.ntp_server_capture_file)) + rdpcap(self.monitor_capture_file)) + + try: + packets += rdpcap(self.ntp_server_capture_file) + except (FileNotFoundError, Scapy_Exception): + LOGGER.error('ntp.pcap not found or empty, ignoring') # Iterate through NTP packets for packet in packets: @@ -238,9 +243,15 @@ def extract_ntp_data(self): def _ntp_network_ntp_support(self): LOGGER.info('Running ntp.network.ntp_support') - packet_capture = (rdpcap(STARTUP_CAPTURE_FILE) + - rdpcap(MONITOR_CAPTURE_FILE) + - rdpcap(NTP_SERVER_CAPTURE_FILE)) + + # Read the pcap files + packet_capture = (rdpcap(self.startup_capture_file) + + rdpcap(self.monitor_capture_file)) + + try: + packet_capture += rdpcap(self.ntp_server_capture_file) + except (FileNotFoundError, Scapy_Exception): + LOGGER.error('ntp.pcap not found or empty, ignoring') device_sends_ntp4 = False device_sends_ntp3 = False @@ -276,9 +287,15 @@ def _ntp_network_ntp_support(self): def _ntp_network_ntp_dhcp(self): LOGGER.info('Running ntp.network.ntp_dhcp') - packet_capture = (rdpcap(STARTUP_CAPTURE_FILE) + - rdpcap(MONITOR_CAPTURE_FILE) + - rdpcap(NTP_SERVER_CAPTURE_FILE)) + + # Read the pcap files + packet_capture = (rdpcap(self.startup_capture_file) + + rdpcap(self.monitor_capture_file)) + + try: + packet_capture += rdpcap(self.ntp_server_capture_file) + except (FileNotFoundError, Scapy_Exception): + LOGGER.error('ntp.pcap not found or empty, ignoring') device_sends_ntp = False ntp_to_local = False