Skip to content

test/automated: Add initial test framework implementation#3566

Open
wiktorkwiatkowski wants to merge 1 commit intoapache:masterfrom
wiktorkwiatkowski:automated_tests
Open

test/automated: Add initial test framework implementation#3566
wiktorkwiatkowski wants to merge 1 commit intoapache:masterfrom
wiktorkwiatkowski:automated_tests

Conversation

@wiktorkwiatkowski
Copy link
Contributor

@wiktorkwiatkowski wiktorkwiatkowski commented Jan 29, 2026

The framework provides macros for defining test cases and test suites with automatic counting of passed and failed tests.

Features:

  • MTEST_CASE macro for defining individual test cases
  • MTEST_SUITE macro for grouping test cases into suites
  • MTEST_INIT_ASSERT, MTEST_CLEANUP_ASSERT, and MTEST_CASE_ASSERT
    macros for test assertions with formatted output per test phase
  • MTEST_INIT and MTEST_CLEANUP for initializing/deinitializing necessary resources
  • MTEST_RUN_INIT and MTEST_RUN_CLEANUP for executing initialization and cleanup

Init and cleanup are optional for the user to define. Any configuration to be done must be run explicitly by the user via the defined macros MTEST_RUN_INIT and MTEST_RUN_CLEANUP at the beginning and end of the suite, test cases should be placed between those two macros.

Example usage:

    MTEST_INIT(pwm_test)
    {
        pwm = pwm_open();
        MTEST_INIT_ASSERT(pwm == NULL, "Device not available");
    }

    MTEST_CLEANUP(pwm_test)
    {
        int rc = pwm_disable(pwm);
        MTEST_CLEANUP_ASSERT(rc == 0, "Disable PWM failed");
    }

    MTEST_CASE(pwm_duty_test)
    {
        int top = pwm_get_top_value(pwm);
        MTEST_CASE_ASSERT(top > 0, "Get top value");
        
        int rc = pwm_set_duty_cycle(pwm, 0, top / 2);
        MTEST_CASE_ASSERT(rc == 0, "Set duty 50%%");
    }

    MTEST_SUITE(pwm_test)
    {
        MTEST_RUN_INIT(pwm_test);
        pwm_duty_test();
        MTEST_RUN_CLEANUP(pwm_test);
    }

The framework provides macros for defining test cases and test
suites with automatic counting of passed and failed tests.

Features:
- MTEST_CASE macro for defining individual test cases
- MTEST_SUITE macro for grouping test cases into suites
- MTEST_INIT_ASSERT, MTEST_CLEANUP_ASSERT, and MTEST_CASE_ASSERT
  macros for test assertions with formatted output per test phase
- MTEST_INIT and MTEST_CLEANUP for initializing/deinitializing
  necessary resources
- MTEST_RUN_INIT and MTEST_RUN_CLEANUP for executing
  initialization and cleanup

Init and cleanup are optional for the user to define. Any
configuration to be done must be run explicitly by the user
via the defined macros MTEST_RUN_INIT and MTEST_RUN_CLEANUP
at the beginning and end of the suite, test cases should be
placed between those two macros.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments