Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-iot: Unit test and debug ota_agent_task.c #93

Merged
merged 6 commits into from
Sep 27, 2024

Conversation

urutva
Copy link
Contributor

@urutva urutva commented Sep 26, 2024

Description

This MR expands mock coverage across the FRI codebase, adding and
modifying existing mocks.
The mocks added are intended to support testing of ota_agent_task.c.
76 tests are added for ota_agent_task.c, and unsafe usage of memcpy
is fixed in the file under test.

Test Steps

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

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

This commit expands mock coverage across the FRI codebase, adding and
modifying existing mocks.
The mocks added are intended to support testing of `ota_agent_task.c`.

Signed-off-by: Reuben Cartwright <Reuben.Cartwright@arm.com>
Some files were used by ota_agent_task.c but not directly included.
This commit fixes this.

Signed-off-by: Reuben Cartwright <Reuben.Cartwright@arm.com>
This commit makes the static functions in ota_agent_task.c visible
if the UNIT_TESTING macro is defined.
The methodology is documented already in `unit_testing.md`.

This is justified because:
- These functions need to be tested.
- Functions other than `vStartOtaTask` cannot be refactored to be
non-static, as only `vStartOtaTask` should be called in another file.

Signed-off-by: Reuben Cartwright <Reuben.Cartwright@arm.com>
The function `otaAppCallback` is called upon an event such as a new
file block being received, or the OTA image being activated.
The function then redundantly checks the OTA state via `OTA_GetState`,
which reduces code clarity via duplication including redundant
calls to the ota update's active and inactive hooks.
This fix has been tested via passing Arm's internal CI.

Signed-off-by: Reuben Cartwright <Reuben.Cartwright@arm.com>
Adds 76 unit tests.

The CMakeLists.txt within the tests subdirectory are also modified so
that the tests run on calling ctest.

Signed-off-by: Reuben Cartwright <Reuben.Cartwright@arm.com>
This commit fixes usage of memcpy with potentially user-defined inputs,
without checking that the buffer could fit these inputs.

Signed-off-by: Reuben Cartwright <Reuben.Cartwright@arm.com>
@urutva urutva requested a review from a team as a code owner September 26, 2024 12:54
@urutva urutva merged commit ca1fe7b into FreeRTOS:main Sep 27, 2024
16 checks passed
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.

4 participants