Skip to content

Add CMock+Unity unit tests for FreeRTOS-Kernel PR #1418#74

Open
chinglee-iot wants to merge 1 commit into
mainfrom
unit-test/pr-1418
Open

Add CMock+Unity unit tests for FreeRTOS-Kernel PR #1418#74
chinglee-iot wants to merge 1 commit into
mainfrom
unit-test/pr-1418

Conversation

@chinglee-iot
Copy link
Copy Markdown
Owner

Description

This pull request adds CMock + Unity unit tests for the changes introduced
in FreeRTOS-Kernel PR #1418,
which adds the vTaskSetSchedulerCoreMask() and uxTaskGetSchedulerCoreMask()
APIs for per-core scheduler masking in SMP builds.

Kernel PR: FreeRTOS/FreeRTOS-Kernel#1418

New test suite: FreeRTOS/Test/CMock/smp/scheduler_core_mask/

Functional test plan

The following scenarios are verified end-to-end via the public API:

Test Scenario
test_vTaskSetSchedulerCoreMask_before_scheduler_starts Mask is stored correctly when called before the scheduler starts; no yield is issued
test_uxTaskGetSchedulerCoreMask_returns_current_mask Round-trip: Set then Get returns the identical value
test_uxTaskGetSchedulerCoreMask_while_scheduler_running Getter takes the critical-section path when the scheduler is running
test_vTaskSetSchedulerCoreMask_all_cores_enabled Re-applying the same all-enabled mask leaves all tasks running and issues no yields
test_vTaskSetSchedulerCoreMask_disable_core_running_nonidle Disabling a core that runs a non-idle task triggers a yield; the idle task takes over that core
test_vTaskSetSchedulerCoreMask_enable_previously_disabled_core Re-enabling a previously disabled core triggers a yield; a user task is dispatched back to it

Coverage test plan

The following branch conditions not reachable via the public API are covered
by the coverage test file:

Test Branch covered
test_coverage_vTaskSetSchedulerCoreMask_invalid_mask configASSERT false-branch (tasks.c:3150) — out-of-range mask
test_coverage_vTaskSetSchedulerCoreMask_disable_core_idle_task Disabled core already running idle task → prvYieldCore NOT called (tasks.c:3181 branch 1)
test_coverage_vTaskSetSchedulerCoreMask_disable_current_core prvYieldCore same-core path → xYieldPendings set instead of portYIELD_CORE (tasks.c:3183 branch 0)
test_coverage_vTaskSetSchedulerCoreMask_enable_current_core Re-enable current core → xYieldPendings path (tasks.c:3188 branch 0)
test_coverage_prvSelectHighestPriorityTask_preemption_disabled_core Non-idle task excluded as preemption target for disabled core (tasks.c:960–961)
test_coverage_prvSelectHighestPriorityTask_disabled_core_not_running NOT_RUNNING non-idle task not assigned to disabled core (tasks.c:1117 branch 1)
test_coverage_prvSelectHighestPriorityTask_disabled_core_already_running Already-running non-idle task not continued on disabled core (tasks.c:1141 branch 1)

Test results

  • Tests passed : 273 (0 regressions in existing SMP suites)
  • Tests failed : 0
  • Changed-line coverage : 100%

Test Steps

  1. Clone the FreeRTOS repository and initialise submodules:
    git clone https://github.com/FreeRTOS/FreeRTOS.git
    cd FreeRTOS
    git submodule update --init FreeRTOS/Source FreeRTOS/Test/CMock/CMock
    
  2. Run the new test suite:
    cd FreeRTOS/Test/CMock
    make -C smp/scheduler_core_mask
    
  3. Verify no regressions in the full SMP suite:
    make -C smp
    

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

FreeRTOS-Kernel PR #1418: FreeRTOS/FreeRTOS-Kernel#1418

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Add a new SMP test suite scheduler_core_mask covering the
vTaskSetSchedulerCoreMask() and uxTaskGetSchedulerCoreMask() APIs
introduced by FreeRTOS/FreeRTOS-Kernel#1418.

Also add taskTASK_SCHEDULED_TO_YIELD alias to global_vars.h so that
test files can reference the same macro name used in tasks.c.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants