Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/ptf_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,32 @@ def ptf_collect(host, log_file, skip_pcap=False):
allure.attach.file(filename_pcap, 'ptf_pcap: ' + filename_pcap, allure.attachment_type.PCAP)


def get_dut_type(host):
dut_type_exists = host.stat(path="/sonic/dut_type.txt")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable indeed holds "stat" of file /sonic/dut_type.txt. It means more than just "exists". Maybe dut_type_stat is a better variable name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

if dut_type_exists["stat"]["exists"]:
dut_type = host.shell("cat /sonic/dut_type.txt")["stdout"]
if dut_type:
logger.info("DUT type is {}".format(dut_type))
return dut_type.lower()
else:
logger.warning("DUT type file is empty.")
else:
logger.warning("DUT type file doesn't exist.")
return "Unknown"


def ptf_runner(host, testdir, testname, platform_dir=None, params={},
platform="remote", qlen=0, relax=True, debug_level="info",
socket_recv_size=None, log_file=None, device_sockets=[], timeout=0, custom_options="",
module_ignore_errors=False, is_python3=False):
# Call virtual env ptf for migrated py3 scripts.
# ptf will load all scripts under ptftests, it will throw error for py2 scripts.
# So move migrated scripts to seperated py3 folder avoid impacting py2 scripts.
dut_type = get_dut_type(host)
if dut_type == "kvm" and params.get("kvm_support", True) is False:
logger.info("Skip test case {} for not support on KVM DUT".format(testname))
return True

if is_python3:
path_exists = host.stat(path="/root/env-python3/bin/ptf")
if path_exists["stat"]["exists"]:
Expand Down