diff --git a/tests/ptf_runner.py b/tests/ptf_runner.py index 80f12e19c6a..9633552ba68 100644 --- a/tests/ptf_runner.py +++ b/tests/ptf_runner.py @@ -32,6 +32,20 @@ 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="", @@ -39,6 +53,11 @@ def ptf_runner(host, testdir, testname, platform_dir=None, params={}, # 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"]: