feat/1030-more-unit-tests #29

Merged
ismail merged 17 commits from feat/1030-more-unit-tests into dev 2025-07-22 15:59:48 +02:00
Owner

Switched to ESP component based project tree structure, fixed some bugs and added more unit tests to cover more code. This PR closes #1030.

The project tree structure has been reorganised to align with Espressif's patterns. Test cases have been categorised for better maintainability and modularity, and more test cases have been implemented to prepare for automated testing in CI/CD pipelines.

The one large test file (test_relay_chn.c) has broken down into categories each category having its own test file. A utility shell script has also been implemented for building tests and testing in qemu. add more tests to increase coverage and break down tests into categories.

All related tickets for this PR:

TICKET-1030 - Add more unit tests
TICKET-1033 - Espressif's project tree based structure
TICKET-1037 - RELAY_CHN_ID_ALL issue in get_state* functions
TICKET-1048 - Implement missing destroy function
TICKET-1049 - Fix listener memory allocation bug
TICKET-1050 - Fix missing NULL handling in relay_chn_create
TICKET-1051 - Add test cases for direction flipping
TICKET-1052 - Add test cases for RELAY_CHN_ID_ALL
TICKET-1054 - Break down test cases into categories
TICKET-1056 - Add missing test cases for tilt API
TICKET-1057 - Fix imbalanced tilt count control logic

Refs #1030, #1033, #1037, #1048, #1049, #1050, #1051, #1052, #1054, #1056, #1057.

Switched to ESP component based project tree structure, fixed some bugs and added more unit tests to cover more code. This PR closes #1030. The project tree structure has been reorganised to align with Espressif's patterns. Test cases have been categorised for better maintainability and modularity, and more test cases have been implemented to prepare for automated testing in CI/CD pipelines. The one large test file ([test_relay_chn.c](/blob/0ebe1c791ee8bb9df2a977f098835fdc2eccf09b/app_test/main/test_relay_chn.c)) has broken down into categories each category having its own test file. A utility shell script has also been implemented for building tests and testing in qemu. add more tests to increase coverage and break down tests into categories. All related tickets for this PR: TICKET-1030 - Add more unit tests TICKET-1033 - Espressif's project tree based structure TICKET-1037 - `RELAY_CHN_ID_ALL` issue in `get_state*` functions TICKET-1048 - Implement missing destroy function TICKET-1049 - Fix listener memory allocation bug TICKET-1050 - Fix missing `NULL` handling in `relay_chn_create` TICKET-1051 - Add test cases for direction flipping TICKET-1052 - Add test cases for `RELAY_CHN_ID_ALL` TICKET-1054 - Break down test cases into categories TICKET-1056 - Add missing test cases for tilt API TICKET-1057 - Fix imbalanced tilt count control logic Refs #1030, #1033, #1037, #1048, #1049, #1050, #1051, #1052, #1054, #1056, #1057.
ismail added 17 commits 2025-07-22 15:48:54 +02:00
Restructured the project tree to align with Espressif's project tree pattern and practice. Also updated the affected cmake files.

Fixes: #1033
Fix the issue where get_state* functions do not handle when id is RELAY_CHN_ID_ALL.
Fixes #1037.
Clean the unnecessary codes and logging macros to keep the test output cleaner.
Add fail tests for the `get_state*` functions.
The component allocates resources (timers, event loop) in relay_chn_create but never frees them. This is a resource leak.
Hence, a destroy function added to free the resources gracefully.

Fixes #1048.
- Replaced the buggy, oldschool, plain pointer based list approach with more robust FreeRTOS linked list implementation for the listener API. Fixes #1049.

- Added relevant test cases. Refs #1030.
Fixes #1050.
Added tests for covering initialization error handling cases like; NULL pointer, invalid GPIO count etc.

This changed implied removing the `relay_chn_create` from the Unity's `setUp` function and place it in each testcase.

Refs #1050, #1030.
Closes #1051.
Add test cases to test all relevant functions that support operating with the `RELAY_CHN_ID_ALL` channel id.

Closes #1052.
Break down tests into categories to improve maintainability and test granularity. This makes it easier to execute unit tests in CI/CD pipelines.

Closes #1054.
Fixed the tilt count logic that causes an imbalance in tilting within the same run frame but opposite direction.

Fixes #1057.
Added missing test cases for the tilt API.

Closes #1056.
ismail self-assigned this 2025-07-22 15:54:39 +02:00
ismail merged commit 5734f47cd3 into dev 2025-07-22 15:59:48 +02:00
Sign in to join this conversation.