Skip to content

Improve uart gpio test #25

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Repo as shared ardino core tests using unity platform.
## Pre-conditions
Before running Unity tests, please ensure the following pre-conditions are met:

1. **Install Arduino CLI**:
- Download and install Arduino CLI. You can download the Windows version of Arduino CLI from the following link:
[Arduino CLI Download Link](https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_64bit.zip)
- Add `arduino-cli.exe` to your system's PATH environment variable to access it from the command line.

2. **Update submodule**:
### Install Arduino CLI:
- Download and install Arduino CLI: https://arduino.github.io/arduino-cli/latest/installation/
You may need to add it to your system's PATH environment variable to access it from terminal.
### Install Make:
- Install GNU make: https://www.gnu.org/software/make/. We use currently Makefile to manage how we execute different tests.
### Update submodule:
- The Unity test framework is included as submodule in this project. The Unity test framework files should be located in the `unity` folder. Run `git submodule update --init --recursive` to update them. If you are nor familiar with submodules, check out: https://git-scm.com/book/en/v2/Git-Tools-Submodules

## Usage
Expand Down
39 changes: 2 additions & 37 deletions src/corelibs/digitalio/test_digitalio_single.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,43 +113,12 @@ TEST_IFX(digitalio_single_internal, test_digitalio_read_write_output_opendrain)

TEST_ASSERT_EQUAL_MESSAGE(LOW, digitalRead(TEST_DIGITALIO_INPUT), "Input Pin should be set to LOW initially");

digitalWrite(TEST_DIGITALIO_OUTPUT, HIGH);
TEST_ASSERT_EQUAL_MESSAGE(HIGH, digitalRead(TEST_DIGITALIO_INPUT), "Input Pin should be set to HIGH");
digitalWrite(TEST_DIGITALIO_OUTPUT, HIGH);
// Skip assert as it may not be set to HIGH due to open-drain configuration
digitalWrite(TEST_DIGITALIO_OUTPUT, LOW);
TEST_ASSERT_EQUAL_MESSAGE(LOW, digitalRead(TEST_DIGITALIO_INPUT), "Input Pin should be set to LOW");
}

/**
* @brief Test invalid pin number handling in pinMode
*/
TEST_IFX(digitalio_single_internal, test_pinMode_invalid_pin) {
pinMode(INVALID_PIN, OUTPUT);
// No assertion as pinMode doesn't return a value, but ensure no crash
}

/**
* @brief Test invalid pin number handling in digitalWrite
*/
TEST_IFX(digitalio_single_internal, test_digitalWrite_invalid_pin) {
digitalWrite(INVALID_PIN, HIGH);
// No assertion as digitalWrite doesn't return a value, but ensure no crash
}

/**
* @brief Test invalid pin number handling in digitalRead
*/
TEST_IFX(digitalio_single_internal, test_digitalRead_invalid_pin) {
TEST_ASSERT_EQUAL_MESSAGE(LOW, digitalRead(INVALID_PIN), "Should return LOW for invalid pin");
}

/**
* @brief Test invalid pin mode
*/
TEST_IFX(digitalio_single_internal, test_invalid_pinmode) {
pinMode(TEST_DIGITALIO_INPUT, 255);
// No assertion as pinMode doesn't return a value, but ensure no crash
}

/**
* @brief Test group runner to run all test cases in this group.
*/
Expand All @@ -159,10 +128,6 @@ static TEST_GROUP_RUNNER(digitalio_single_internal)
RUN_TEST_CASE(digitalio_single_internal, test_digitalio_read_write_input_pullup);
RUN_TEST_CASE(digitalio_single_internal, test_digitalio_read_write_input_pulldown);
RUN_TEST_CASE(digitalio_single_internal, test_digitalio_read_write_output_opendrain);
RUN_TEST_CASE(digitalio_single_internal, test_pinMode_invalid_pin);
RUN_TEST_CASE(digitalio_single_internal, test_digitalWrite_invalid_pin);
RUN_TEST_CASE(digitalio_single_internal, test_digitalRead_invalid_pin);
RUN_TEST_CASE(digitalio_single_internal, test_invalid_pinmode);
}

/**
Expand Down
26 changes: 26 additions & 0 deletions src/corelibs/uart/test_uart_connected2_rx.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/*
* test_uart_connected2_rx.cpp
*
* This file contains tests for UART communication using the Arduino framework.
* It verifies the ability to send and receive data between UART devices at
* different baud rates and ensures the proper functioning of UART APIs.
*
* The tests use Serial1 (or more Serial instances) for UART communication
* and Serial for reporting test results.
* To run this test file, you need two boards, each with two or more serial ports enabled,
* with their respective TX and RX ports connected.
*
* Example for each Serial:
*
* terminal
* | ^
* v Serial |
* RX ^ TX
* |
* report status
* |
* TX <---> RX
* Serial1
*/


// std includes

// test includes
Expand Down
25 changes: 25 additions & 0 deletions src/corelibs/uart/test_uart_connected2_tx.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
* test_uart_connected2_tx.cpp
*
* This file contains tests for UART communication using the Arduino framework.
* It verifies the ability to send and receive data between UART devices at
* different baud rates and ensures the proper functioning of UART APIs.
*
* The tests use Serial1 (or more Serial instances) for UART communication
* and Serial for reporting test results.
* To run this test file, you need two boards, each with two or more serial ports enabled,
* with their respective TX and RX ports connected.
*
* Example for each Serial:
*
* terminal
* | ^
* v Serial |
* RX ^ TX
* |
* report status
* |
* TX <---> RX
* Serial1
*/

// std includes

// test includes
Expand Down