Compare commits

...

7 Commits

Author SHA1 Message Date
8cd866d16d Run test on native environment
Some checks failed
PlatformIO CI / build (push) Failing after 1m3s
2024-04-10 21:17:37 +10:00
38d91e6c30 WIP: Create Workflow for Gitea
Bump python version in workflow

Try different container
2024-04-10 21:15:20 +10:00
88caab56a2 Commit generated .vscode/extensions.json 2024-04-10 21:14:04 +10:00
d3325b71cd Fixes to unit tests to work on native platform 2024-04-10 21:13:45 +10:00
3d315be27f Add a native environment to platformio.ini 2024-04-10 21:12:33 +10:00
71dbf1f4ca Rename runParseUnityTests to just runUnityTests 2024-04-10 21:11:12 +10:00
7f7e02a8b7 Avoid including Arduino.h where possible 2024-04-10 21:10:31 +10:00
9 changed files with 79 additions and 8 deletions

View File

@@ -0,0 +1,25 @@
name: PlatformIO CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install PlatformIO Core
run: pip install --upgrade platformio
- name: Build PlatformIO Project
run: pio test --environment native

10
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

View File

@@ -1,7 +1,7 @@
#ifndef BUFFERFILLER_H #ifndef BUFFERFILLER_H
#define BUFFERFILLER_H #define BUFFERFILLER_H
#include <Arduino.h> #include <stdint.h>
#include "PacketCRC.h" #include "PacketCRC.h"
#include "PacketTypes.h" #include "PacketTypes.h"

View File

@@ -1,7 +1,7 @@
#ifndef PACKET_PARSER_H #ifndef PACKET_PARSER_H
#define PACKET_PARSER_H #define PACKET_PARSER_H
#include <Arduino.h> #include <vector>
#include "PacketTypes.h" #include "PacketTypes.h"
class PacketParser { class PacketParser {

View File

@@ -1,7 +1,7 @@
#ifndef PACKET_TYPES_H #ifndef PACKET_TYPES_H
#define PACKET_TYPES_H #define PACKET_TYPES_H
#include <Arduino.h> #include <stdint.h>
#include <variant> #include <variant>
// Define packet types // Define packet types

View File

@@ -1,7 +1,7 @@
#ifndef RFPOWERVIEW_H #ifndef RFPOWERVIEW_H
#define RFPOWERVIEW_H #define RFPOWERVIEW_H
#include <Arduino.h> #include <stdint.h>
#include <RF24.h> #include <RF24.h>
#include "PacketReceiver.h" #include "PacketReceiver.h"
#include "PacketParser.h" #include "PacketParser.h"

View File

@@ -21,3 +21,13 @@ lib_deps =
robtillaart/CRC @ 1.0.2 robtillaart/CRC @ 1.0.2
nrf24/RF24 @ 1.4.8 nrf24/RF24 @ 1.4.8
rlogiacco/CircularBuffer @ 1.3.3 rlogiacco/CircularBuffer @ 1.3.3
[env:native]
platform = native
lib_deps =
${env.lib_deps}
ArduinoFake
build_src_filter =
+<**/*.cpp>
-<**/RFPowerView.cpp>
-<**/PacketReceiver.cpp>

View File

@@ -2,6 +2,14 @@
#include <Arduino.h> #include <Arduino.h>
#include "PacketCRC.h" #include "PacketCRC.h"
void setUp()
{
}
void tearDown()
{
}
void run_calculate_test(const uint8_t *packet_data, const uint16_t expected_checksum) void run_calculate_test(const uint8_t *packet_data, const uint16_t expected_checksum)
{ {
PacketCRC packetCRC; PacketCRC packetCRC;
@@ -83,3 +91,8 @@ void setup()
runUnityTests(); runUnityTests();
} }
void loop() {} void loop() {}
int main(void)
{
return runUnityTests();
}

View File

@@ -2,6 +2,14 @@
#include <Arduino.h> #include <Arduino.h>
#include "PacketParser.h" #include "PacketParser.h"
void setUp()
{
}
void tearDown()
{
}
void run_parse_test(const uint8_t *packet_data, Packet &packet) void run_parse_test(const uint8_t *packet_data, Packet &packet)
{ {
PacketParser packetParser; PacketParser packetParser;
@@ -44,7 +52,7 @@ void test_parse_open()
TEST_ASSERT_TRUE(packet.type == PacketType::OPEN); TEST_ASSERT_TRUE(packet.type == PacketType::OPEN);
} }
int runParseUnityTests(void) int runUnityTests(void)
{ {
UNITY_BEGIN(); UNITY_BEGIN();
RUN_TEST(test_parse_stop); RUN_TEST(test_parse_stop);
@@ -63,6 +71,11 @@ void setup()
// establishes connection with a board Serial interface // establishes connection with a board Serial interface
delay(2000); delay(2000);
runParseUnityTests(); runUnityTests();
} }
void loop() {} void loop() {}
int main(void)
{
return runUnityTests();
}