starting with component unit testing (running on device)

Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
2024-05-17 12:03:16 +02:00
parent 05f8519864
commit 0944d29597
18 changed files with 127 additions and 13 deletions

View File

@@ -1,3 +0,0 @@
idf_component_register(SRCS "osr_ble.c"
INCLUDE_DIRS "."
PRIV_REQUIRES "nvs_flash")

View File

@@ -1,18 +0,0 @@
#include "osr_ble.h"
#include <nvs.h>
#include <nvs_flash.h>
void nvs_init() {
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES ||
ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
}
void osr_ble_init() {
nvs_init();
}

View File

@@ -1,3 +0,0 @@
#pragma once
void osr_ble_init();

View File

@@ -0,0 +1,2 @@
idf_component_register(SRCS "logger.c"
INCLUDE_DIRS "include")

View File

@@ -0,0 +1,5 @@
#pragma once
int add(int a, int b);
void log_message(const char* message);

View File

@@ -0,0 +1,11 @@
#include "logger.h"
#include <stdio.h>
int add(int a, int b) {
return a + b;
}
void log_message(const char* message) {
printf("%s\n", message);
}

View File

@@ -0,0 +1,3 @@
idf_component_register(SRC_DIRS "."
INCLUDE_DIRS "."
REQUIRES cmock logger)

View File

@@ -0,0 +1,7 @@
#include "unity.h"
#include "logger.h"
TEST_CASE("Add two numbers", "[logger]") {
TEST_ASSERT_EQUAL(3, add(1, 2));
}