autogenerate.sh: Running the Framework Generation Script - rdkcentral/ut-core GitHub Wiki

Instructions: Running the Framework Generation Script

Overview

These instructions guide engineering teams on using the autogenerate.sh script to automatically generate Level 1 (L1) and Level 2 (L2) testing suite frameworks.


Purpose of the Autogen Script

The primary purpose of the autogenerate.sh script is to streamline the initial setup and integration of unit tests for API definitions, allowing engineers to quickly build a complete and fully integrated testing framework with the ut-core testing structure. The script takes input header files and generates all necessary components to create a Linux-compatible, buildable test suite, including:

  • Directory Structure: Automatically creates subdirectories and organizes files as required by the ut-core framework for a seamless integration.
  • Stub Generation: Generates all necessary stubs for functions referenced in the headers, allowing immediate compilation and functionality within the test suite.
  • Usable Testing Suite: Provides engineers with a ready-to-use test framework that can be customized and expanded to meet specific testing requirements.

This tool accelerates the creation of a complete testing framework from scratch, enabling engineers to go from 0% to a fully functional, buildable test suite. Engineers can then fill out this framework to test individual functions or groups of functions according to their testing needs.


Autogen Command

To run the autogen script, use:

./autogenerate.sh <api-def-repo-url/-c/-clean/-b/-branch/-h/-help>

Autogen Options Explained

Argument Optional? Description Examples
api-def-repo-url No URL of the API definitions repo to be cloned or the directory path to be copied [email protected]:rdkcentral/hal-deepsleepmanager.git or /home/user/workspace/RdkWanManager
-clean or -c Yes Deletes the workspace directory (including cloned repos) -clean, -c
-branch or -b Yes Checks out a specific branch in the API definitions repo, applicable only with urls -branch hal-review, -b main
-help or -h Yes Shows usage information for the script -help, -h

Note: To include debug statements, set the environment variable AGT_DEBUG before running the script:

export AGT_DEBUG=1

Use Cases Supported by autogenerate.sh

The autogenerate.sh script supports various use cases for generating test frameworks, providing flexibility for repository URLs, user-specified directories, and custom header file locations.

  1. API Definition Repository URL
    The API definition URL can be any accessible Git repository URL or directory path. Example commands:

    ./autogenerate.sh [email protected]:rdkcentral/rdk-halif-device_settings.git
    ./autogenerate.sh https://github.com/rdkcentral/RdkWanManager.git
    ./autogenerate.sh /home/user/workspace/RdkWanManager
    
  2. Unit Test Directory
    The unit test directory can be either:

    • Cloned from a user-provided URL.
    • Specified as an absolute directory path by the user.

    When prompted, enter the URL or absolute path, or leave blank to skip:

    # URL input example
    Please input the URL (or leave blank to skip): https://github.com/comcast-sky/skysr213-platform-hal.git
    
    # Absolute path input example
    Please input the directory (absolute) path (or leave blank to skip):    /home/user/workspace/RdkWanManager
    
  3. Header File Location
    The script can generate tests for header files located within the include folder or any other location within the API Definition directory cloned or copied by the script.


Example Commands

  1. Generate Test Framework
    Generates L1 and L2 test frameworks for the deepsleepmanager repo, including template directories and files in the API definition and ut directories, and skeletons if needed:

    ./autogenerate.sh [email protected]:rdkcentral/hal-deepsleepmanager.git
    
  2. Generate Test Framework on Specific Branch
    Generates the L1 and L2 test frameworks for deepsleepmanager on the hal-review branch of the API definition repo:

    ./autogenerate.sh [email protected]:rdkcentral/hal-deepsleepmanager.git -b hal-review
    
  3. Delete Workspace Directory
    Deletes the workspace directory if it exists:

    ./autogenerate.sh [email protected]:rdkcentral/hal-powermanager.git -c
    
  4. Display Script Usage
    Shows the usage information for the autogen script:

    ./autogenerate.sh -h
    

Terminology Index

Term Definition Relative Location Created
Workspace Directory created to clone repos and build the test framework [ut-core-dir]/workspace
API Definitions Main repo where header files (e.g., HAL repo) reside [ut-core-dir]/workspace/[API-definitions-dir]
UT Directory under API definition in workspace for Unit Tests (e.g., HALTest repo) [ut-core-dir]/workspace/[API-definitions-dir]/ut
Skeletons Generated skeleton code for header files in the API Definition [ut-core-dir]/workspace/[API-definitions-dir]/ut/skeletons/src
Tests L1 and L2 tests generated for header files in the API Definition [ut-core-dir]/workspace/[API-definitions-dir]/ut/src
L1 Tests Functional tests for each function in header files [ut-core-dir]/workspace/[API-definitions-dir]/ut/src/test_L1_*
L2 Tests Operational tests for module functionality [ut-core-dir]/workspace/[API-definitions-dir]/ut/src/test_L2_*