Skip to content
Ulrond edited this page Nov 14, 2024 · 31 revisions

UT-Core Framework

ut-core is a modular unit testing framework designed to streamline and simplify the process of developing and executing tests within the RDK Central ecosystem. It provides a collection of tools, utilities, and conventions to help you build robust and reliable tests for your software components.

Objectives for the framework

Testing suites serve as engineering tools that scrutinise individual components, groups or layers of components during the development and debugging process. Such tests ascertain quality by running multiple rounds on locally revised code before its final commit.

Primary Objectives:

  • Pre-commit: Validation of local changes, build and execute the relevant testing suite for the desired component group or layer
  • Debugging: Tests must enable debugging for better variable examination and solitary step execution.
  • Sharing: Enable sharing and execution of tests by third-party vendors, ensuring completion before their delivery.
  • Independence: Permit deployment and execution on vendor boards and prototype hardware.

Secondary Objectives

To test the exposed low-level interfaces of components or groups of components

  • Initial Development: Develop & perform testing of the component during its initial development.
  • Change Management: Allow engineers to validate code changes on the components.
  • Validation: To test and validate interface upgrades which will cause upgrades to the testing suites, and documentation.
  • Isolated: Isolated components must run in clean environments and with minimised influences on the system.
  • Leverage: Leverage the low-level tests to build more complex requirements.
  • Repeatable: Provide a repeatable engineering environment for low-level control via a high-level language

High-level Host Framework Compatible: ut-raft can be used to provide prerequisites, interpret logs, perform analysis of data, draw graphs, formulate, conclusions, trends and results these will adapt based on findings and engineering analysis and requirements.

Key Features

  • Modular Design: ut-core is built with a modular architecture, allowing you to select and use the components that best suit your specific testing needs.
  • Flexible Test Definition: Define test cases and configurations using human-readable formats like YAML or JSON, making it easy to create and manage your tests.
  • Data-Driven Testing: Drive your tests with yaml/json input data to cover a wide range of scenarios and edge cases.
  • Rich Assertion Library: Validate your test results using a comprehensive set of built-in assertions, or create your own custom assertions.
  • Test Reporting: Generate detailed test reports to easily identify and diagnose issues.
  • Integration with CI/CD: Seamlessly integrate ut-core into your continuous integration and continuous delivery pipelines for automated testing.
  • Extensibility: Extend ut-core's functionality by developing custom modules or plugins.
  • Variants: Supports both C and C++ (as a direct swap for GTEST)
  • Black Box Testing: Primary designed as a black box testing framework Black-Box vs White-Box

Documentation

Here are some of the key modules within ut-core that you can explore in more detail:

The ut-core unit testing framework incorporates features from the ut-control module. You can find detailed information about ut-control on its wiki page: ut-control

ut-control

Control features have moved to a separate repo ut-control

Getting Started

  1. Installation: Follow the installation instructions in the ut-core repository to set up the framework in your development environment.
  2. Explore the Modules: Familiarize yourself with the different modules available in ut-core, each catering to specific testing needs.
  3. Define Your Tests: Use YAML or JSON to create test case definitions, input data, and expected results.
  4. Execute Your Tests: Run your tests using the ut-core test runner.
  5. Analyse Results: Review test reports to identify any failures or issues.

Running Tests

To execute your tests using the ut-core framework, the main argument features will be linked into your test. This executable provides various command-line switches to customize how your tests are run:

Example of the unit test

The unit tests are also a combined binary with ut-core, therefore it also has the switches.

./tests/bin/ut-test -h
Help
-a - Automated Mode
-b - Basic Mode
-f - <filename> - set the output filename for automated mode
-t - List all tests run to a file
-l - Set the log Path
-p - <profile_filename> - specify the profile to load YAML or JSON, also used by kvp_profile
-h - Help

Using the -p profile_filename switch

  • hdmiProfile.yml
hdmicec:
  config:
    extendedEnumsSupported: false
  • Passing a profile into the testing suite
./hdmi_cec -p hdmiProfile.yml

then in the testing code you would perform

bool extendedEnumsSupported = UT_KVP_PROFILE_GET_BOOL( "hdmicec/config/extendedEnumsSupported" ); 
if ( extendedEnumsSupported == false )
{
   /* Complete suite is disabled due to supportExtendedEnums == false */
    pSuite = UT_add_suite("test extended functions ", NULL, NULL );

    UT_add_test(pSuite, "test extended bool", test_bool);
    UT_add_test(pSuite, "test extended string", test_string);
    UT_add_test(pSuite, "test extended uint32", test_uint32);
}

Refer to the documentation for more information ut_kvp_profile: Key Value Pair Assertions for Unit Testing

Contributing

We welcome contributions to ut-core! If you have ideas for new features, bug fixes, or improvements to the documentation, please open an issue or submit a pull request on our GitHub repository.

Let us know if you have any questions or feedback!

Clone this wiki locally