blob: f6bcad16a7c6830d77553f8822945d68eeee4631 [file] [log] [blame]
#
# Copyright (c) 2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import subprocess
from . import linux, runner
from .test_definition import ApplicationPaths, TestDefinition, TestTarget
def target_for_name(name: str):
if name.startswith("TV_") or name.startswith("Test_TC_MC_") or name.startswith("Test_TC_LOWPOWER_") or name.startswith("Test_TC_KEYPADINPUT_") or name.startswith("Test_TC_APPLAUNCHER_") or name.startswith("Test_TC_MEDIAINPUT_") or name.startswith("Test_TC_WAKEONLAN_") or name.startswith("Test_TC_CHANNEL_") or name.startswith("Test_TC_MEDIAPLAYBACK_") or name.startswith("Test_TC_AUDIOOUTPUT_") or name.startswith("Test_TC_TGTNAV_") or name.startswith("Test_TC_APBSC_") or name.startswith("Test_TC_CONTENTLAUNCHER_") or name.startswith("Test_TC_ALOGIN_"):
return TestTarget.TV
if name.startswith("DL_") or name.startswith("Test_TC_DRLK_"):
return TestTarget.LOCK
if name.startswith("OTA_"):
return TestTarget.OTA
if name.startswith("Test_TC_BRBINFO_"):
return TestTarget.BRIDGE
return TestTarget.ALL_CLUSTERS
def tests_with_command(chip_tool: str, is_manual: bool):
"""Executes `chip_tool` binary to see what tests are available, using cmd
to get the list.
"""
cmd = "list"
if is_manual:
cmd += "-manual"
result = subprocess.run([chip_tool, "tests", cmd], capture_output=True)
for name in result.stdout.decode("utf8").split("\n"):
if not name:
continue
target = target_for_name(name)
yield TestDefinition(
run_name=name, name=name, target=target, is_manual=is_manual
)
def AllTests(chip_tool: str):
for test in tests_with_command(chip_tool, is_manual=False):
yield test
for test in tests_with_command(chip_tool, is_manual=True):
yield test
__all__ = [
"TestTarget",
"TestDefinition",
"AllTests",
"ApplicationPaths",
"linux",
"runner",
]