Skip to content
Merged
Changes from all 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_stat = host.stat(path="/sonic/dut_type.txt")
if dut_type_stat["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