Skip to content

Commit

Permalink
Merge pull request #369 from kivancsikert/testing/catch2
Browse files Browse the repository at this point in the history
Add Catch2 for testing
  • Loading branch information
lptr authored Feb 11, 2025
2 parents ac9979c + 2be06a7 commit b991f2c
Show file tree
Hide file tree
Showing 95 changed files with 515 additions and 223 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,28 @@ jobs:
debug-${{ matrix.environment }}.zip
if-no-files-found: error

test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: esp-idf build
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.4
target: esp32s3
command: idf.py build
path: test

- name: esp-idf test
run: |
docker run -v .:/project -w /project/test -e HOME=/tmp -e WOKWI_CLI_TOKEN=${{ secrets.WOKWI_CLI_TOKEN }} lptr/pytest-embedded:latest pytest --embedded-services idf,wokwi ./pytest_catch2.py
release:
needs: build
needs:
- build
- test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
Expand Down
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
/data-unused/

# ESP-IDF generated files
/build/
/managed_components/
/sdkconfig*
!/sdkconfig*.defaults
/dependencies*.lock
build/

sdkconfig*
!sdkconfig*.defaults

managed_components/
dependencies*.lock

__pycache__/
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ FetchContent_Declare(
GIT_TAG "1abe2e5194b1a45c8878229ad893a058816cdd18"
)
FetchContent_MakeAvailable(espidflib)
set(EXTRA_COMPONENT_DIRS ${espidflib_SOURCE_DIR}/components)

set(EXTRA_COMPONENT_DIRS ${espidflib_SOURCE_DIR}/components ${CMAKE_SOURCE_DIR}/components)

if(NOT DEFINED UD_GEN)
set(UD_GEN "$ENV{UD_GEN}")
Expand Down Expand Up @@ -64,11 +63,14 @@ else()
endif()
add_link_options("-Wl,--gc-sections")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

# Keep struct initializers simple
add_compile_options("-Wno-missing-field-initializers")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
idf_build_set_property(MINIMAL_BUILD ON)

project(ugly-duckling)

# Use `idf.py -DFSUPLOAD=1 flash` to upload the data partition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

#include <esp_sleep.h>

#include <kernel/MovingAverage.hpp>
#include <kernel/ShutdownManager.hpp>
#include <kernel/Task.hpp>
#include <kernel/Telemetry.hpp>
#include <kernel/drivers/BatteryDriver.hpp>
#include <MovingAverage.hpp>
#include <ShutdownManager.hpp>
#include <Task.hpp>
#include <Telemetry.hpp>
#include <drivers/BatteryDriver.hpp>

using namespace farmhub::kernel::drivers;

Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions components/kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
idf_component_register(
INCLUDE_DIRS "."
)
4 changes: 2 additions & 2 deletions main/kernel/Component.hpp → components/kernel/Component.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <kernel/Named.hpp>
#include <kernel/mqtt/MqttRoot.hpp>
#include <Named.hpp>
#include <mqtt/MqttRoot.hpp>

using namespace farmhub::kernel::mqtt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include <freertos/FreeRTOS.h>

#include <kernel/Time.hpp>
#include <kernel/BootClock.hpp>
#include <Time.hpp>
#include <BootClock.hpp>

using namespace std::chrono;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <ArduinoJson.h>

#include <kernel/FileSystem.hpp>
#include <FileSystem.hpp>

using std::list;
using std::ref;
Expand Down
4 changes: 2 additions & 2 deletions main/kernel/Console.hpp → components/kernel/Console.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <kernel/Log.hpp>
#include <kernel/Concurrent.hpp>
#include <Log.hpp>
#include <Concurrent.hpp>

namespace farmhub::kernel {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include <ArduinoJson.h>

#include <kernel/NvsStore.hpp>
#include <kernel/Strings.hpp>
#include <NvsStore.hpp>
#include <Strings.hpp>

namespace farmhub::kernel {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include <esp_private/esp_clk.h>

#include <kernel/BatteryManager.hpp>
#include <kernel/Strings.hpp>
#include <kernel/drivers/RtcDriver.hpp>
#include <kernel/drivers/WiFiDriver.hpp>
#include <BatteryManager.hpp>
#include <Strings.hpp>
#include <drivers/RtcDriver.hpp>
#include <drivers/WiFiDriver.hpp>

using namespace farmhub::kernel::drivers;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#include <esp_http_client.h>
#include <esp_https_ota.h>

#include <kernel/FileSystem.hpp>
#include <kernel/Log.hpp>
#include <kernel/Watchdog.hpp>
#include <kernel/drivers/WiFiDriver.hpp>
#include <FileSystem.hpp>
#include <Log.hpp>
#include <Watchdog.hpp>
#include <drivers/WiFiDriver.hpp>

namespace farmhub::kernel {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include <i2cdev.h>

#include <kernel/Pin.hpp>
#include <kernel/Strings.hpp>
#include <Pin.hpp>
#include <Strings.hpp>

namespace farmhub::kernel {

Expand Down
25 changes: 11 additions & 14 deletions main/kernel/KernelStatus.hpp → components/kernel/KernelStatus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,20 @@

#include <freertos/FreeRTOS.h>

#include <devices/DeviceConfiguration.hpp>

#include <kernel/I2CManager.hpp>
#include <kernel/NetworkUtil.hpp>
#include <kernel/PowerManager.hpp>
#include <kernel/StateManager.hpp>
#include <kernel/Watchdog.hpp>
#include <kernel/drivers/LedDriver.hpp>
#include <kernel/drivers/MdnsDriver.hpp>
#include <kernel/drivers/RtcDriver.hpp>
#include <kernel/drivers/SwitchManager.hpp>
#include <kernel/drivers/WiFiDriver.hpp>
#include <kernel/mqtt/MqttDriver.hpp>
#include <I2CManager.hpp>
#include <NetworkUtil.hpp>
#include <PowerManager.hpp>
#include <StateManager.hpp>
#include <Watchdog.hpp>
#include <drivers/LedDriver.hpp>
#include <drivers/MdnsDriver.hpp>
#include <drivers/RtcDriver.hpp>
#include <drivers/SwitchManager.hpp>
#include <drivers/WiFiDriver.hpp>
#include <mqtt/MqttDriver.hpp>

using namespace std::chrono;
using namespace std::chrono_literals;
using namespace farmhub::devices;
using namespace farmhub::kernel::drivers;
using namespace farmhub::kernel::mqtt;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <nvs_flash.h>

#include <ArduinoJson.h>
#include <kernel/Concurrent.hpp>
#include <Concurrent.hpp>

namespace farmhub::kernel {

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <esp_pm.h>

#include <kernel/Concurrent.hpp>
#include <Concurrent.hpp>

#if defined(CONFIG_IDF_TARGET_ESP32S2)
// Apparently on ESP32S2 things start to break down if we go below 80 MHz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include <driver/gpio.h>
#include <driver/rtc_io.h>

#include <kernel/BootClock.hpp>
#include <kernel/Concurrent.hpp>
#include <kernel/Log.hpp>
#include <kernel/Pin.hpp>
#include <kernel/PowerManager.hpp>
#include <BootClock.hpp>
#include <Concurrent.hpp>
#include <Log.hpp>
#include <Pin.hpp>
#include <PowerManager.hpp>

namespace farmhub::kernel {

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <functional>
#include <list>

#include <kernel/Task.hpp>
#include <Task.hpp>

namespace farmhub::kernel {

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion main/kernel/State.hpp → components/kernel/State.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <freertos/FreeRTOS.h>
#include <freertos/event_groups.h>

#include <kernel/Time.hpp>
#include <Time.hpp>

using namespace std::chrono;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <kernel/State.hpp>
#include <State.hpp>

namespace farmhub::kernel {

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions main/kernel/Task.hpp → components/kernel/Task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>

#include <kernel/Log.hpp>
#include <kernel/Time.hpp>
#include <Log.hpp>
#include <Time.hpp>

using namespace std::chrono;

Expand Down
4 changes: 2 additions & 2 deletions main/kernel/Telemetry.hpp → components/kernel/Telemetry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include <ArduinoJson.h>

#include <kernel/BootClock.hpp>
#include <kernel/Task.hpp>
#include <BootClock.hpp>
#include <Task.hpp>

namespace farmhub::kernel {

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <esp_check.h>

#include <kernel/Time.hpp>
#include <Time.hpp>

namespace farmhub::kernel {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <chrono>
#include <limits>

#include <kernel/Pin.hpp>
#include <kernel/Telemetry.hpp>
#include <Pin.hpp>
#include <Telemetry.hpp>

using farmhub::kernel::PinPtr;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <kernel/I2CManager.hpp>
#include <kernel/drivers/BatteryDriver.hpp>
#include <I2CManager.hpp>
#include <drivers/BatteryDriver.hpp>

using namespace farmhub::kernel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <atomic>
#include <chrono>

#include <kernel/PwmManager.hpp>
#include <kernel/drivers/MotorDriver.hpp>
#include <PwmManager.hpp>
#include <drivers/MotorDriver.hpp>

using namespace std::chrono;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <atomic>
#include <chrono>

#include <kernel/PwmManager.hpp>
#include <kernel/drivers/MotorDriver.hpp>
#include <PwmManager.hpp>
#include <drivers/MotorDriver.hpp>

using namespace std::chrono;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <atomic>
#include <chrono>

#include <kernel/PwmManager.hpp>
#include <kernel/drivers/MotorDriver.hpp>
#include <PwmManager.hpp>
#include <drivers/MotorDriver.hpp>

using namespace std::chrono;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <chrono>
#include <vector>

#include <kernel/Concurrent.hpp>
#include <kernel/Pin.hpp>
#include <kernel/Task.hpp>
#include <Concurrent.hpp>
#include <Pin.hpp>
#include <Task.hpp>

using namespace std::chrono;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include <mdns.h>

#include <kernel/Concurrent.hpp>
#include <kernel/NvsStore.hpp>
#include <kernel/State.hpp>
#include <kernel/Task.hpp>
#include <Concurrent.hpp>
#include <NvsStore.hpp>
#include <State.hpp>
#include <Task.hpp>

namespace farmhub::kernel::drivers {

Expand Down
File renamed without changes.
Loading

0 comments on commit b991f2c

Please sign in to comment.