Skip to content

Commit

Permalink
Include log messages in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
esev committed Dec 25, 2024
1 parent a7d9e81 commit ce3597d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DebugConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define LOG_CRIT(...) SEGGER_RTT_printf(0, __VA_ARGS__)
#define LOG_TRACE(...) SEGGER_RTT_printf(0, __VA_ARGS__)
#else
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE) && !defined(PIO_UNIT_TESTING)
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
#define LOG_DEBUG(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_DEBUG, __VA_ARGS__)
#define LOG_INFO(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_INFO, __VA_ARGS__)
#define LOG_WARN(...) DEBUG_PORT.log(MESHTASTIC_LOG_LEVEL_WARN, __VA_ARGS__)
Expand Down
10 changes: 10 additions & 0 deletions test/TestUtil.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "TestUtil.h"
#include "SerialConsole.h"
#include "concurrency/OSThread.h"

void initializeTestEnvironment()
{
concurrency::hasBeenSetup = true;
concurrency::OSThread::setup();
consoleInit();
}
4 changes: 4 additions & 0 deletions test/TestUtil.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

// Initialize testing environment.
void initializeTestEnvironment();
2 changes: 2 additions & 0 deletions test/test_crypto/test_main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "CryptoEngine.h"

#include "TestUtil.h"
#include <unity.h>

void HexToBytes(uint8_t *result, const std::string hex, size_t len = 0)
Expand Down Expand Up @@ -170,6 +171,7 @@ void setup()
delay(10);
delay(2000);

initializeTestEnvironment();
UNITY_BEGIN(); // IMPORTANT LINE!
RUN_TEST(test_SHA256);
RUN_TEST(test_ECB_AES256);
Expand Down

0 comments on commit ce3597d

Please sign in to comment.