-
Notifications
You must be signed in to change notification settings - Fork 0
utCFramework Manual (utSuiteNavigator.py)
Ulrond edited this page Oct 15, 2024
·
1 revision
The utCFramework class facilitates interaction with and execution of C-based unit test suites built with the ut-core framework (https://github.com/rdkcentral/ut-core). It provides methods for starting the test suite, selecting specific tests or suites, providing input to interactive tests, and collecting test results.
class utCFramework:
"""This module supports the selection of C Type tests
"""
def __init__(self, session:consoleInterface, log:logModule = None):
# ... (Initialization logic) ...
def start(self, command:str ):
"""start the suite
...
"""
# ... (Implementation) ...
def stop(self):
"""stops the active suite
...
"""
# ... (Implementation) ...
def select(self, suite_name: str, test_name:str = None, promptWithAnswers: list = None ):
"""select a test from the suite to execute and wait for Prompt
...
"""
# ... (Implementation) ...
def inputPrompts(self, promptsWithAnswers: dict):
"""
Sends the specific prompts and sends corresponding input values.
...
"""
# ... (Implementation) ...
def find_index_in_output(self, output, target_name):
"""
Finds the index of a target name in the shell output.
...
"""
# ... (Implementation) ...
def collect_results(self, output):
"""
Collects and interprets the results from the test execution output.
...
"""
# ... (Implementation) ...To use the utCFramework class, create an instance with the following arguments:
-
session: AconsoleInterfaceobject, which provides methods for interacting with the device's console (e.g., sending commands and reading output). -
log(optional): AlogModuleobject for logging purposes. If not provided, a default logger is created.
-
start(command): Starts the ut-core based C unit test suite using the providedcommand. -
stop(): Stops the currently running test suite. -
select(suite_name, test_name=None, promptWithAnswers=None): Navigates the test suite menu to select and run a specific test suite or test case.-
suite_name: The name of the test suite. -
test_name(optional): The name of the test case within the suite. If None, the entire suite is run. -
promptWithAnswers(optional): A list of dictionaries, each containing information about an interactive prompt expected during the test execution.
-
-
inputPrompts(promptsWithAnswers): Handles interactive prompts during test execution by providing predefined answers. -
find_index_in_output(output, target_name): Helper function to find the index of a specific test suite or test case in the console output. -
collect_results(output): Analyzes the output from the test execution and determines whether the test passed or failed.
Example Usage
# Assuming 'shell' is a consoleInterface object
framework = utCFramework(session=shell)
# Start the ut-core test suite
framework.start(command="./run_tests.sh")
# Select and run a specific test case
framework.select(suite_name="TestSuite1", test_name="TestCase2")
# Stop the test suite
framework.stop()This manual provides a basic understanding of the utCFramework class, specifically designed for interacting with the ut-core C unit testing framework. Refer to the code and inline comments for more detailed information and advanced usage scenarios.