Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengfeihe committed Jul 7, 2024
1 parent e39de2b commit 2241be8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ci/run_tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

PCAP_FILE_PATH = os.path.join("Tests", "Pcap++Test", "PcapExamples", "example.pcap")


def get_ip_address(interface):
addresses = psutil.net_if_addrs().get(interface)
if not addresses:
Expand All @@ -15,6 +16,7 @@ def get_ip_address(interface):
return address.address
return None


def main():
parser = argparse.ArgumentParser()
parser.add_argument("--interface", type=str, required=True, help="interface to use")
Expand Down
6 changes: 5 additions & 1 deletion ci/run_tests/run_tests_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
os.path.join("Tests", "Pcap++Test", "PcapExamples", "example.pcap")
)


def get_ip_address(interface):
print(interface)
addresses = psutil.net_if_addrs().get(interface)
print(addresses)
if not addresses:
return None
for address in addresses:
if address.family == socket.AF_INET:
return address.address
return None


def find_interface():
completed_process = subprocess.run(
["tcpreplay.exe", "--listnics"],
Expand Down Expand Up @@ -73,7 +77,7 @@ def main():

tcpreplay_interface, ip_address = find_interface()
if not tcpreplay_interface or not ip_address:
print("Cannot find an interface to run tests on!")
print("Cannot find an interface to run tests on! Info from psutil.net_if_addrs() %s"% psutil.net_if_addrs())
exit(1)
print(f"Interface is {tcpreplay_interface} and IP address is {ip_address}")

Expand Down

0 comments on commit 2241be8

Please sign in to comment.