compile with EMSESP_TEST to run tests (not DEBUG)

This commit is contained in:
Proddy
2023-02-21 21:28:19 +01:00
parent a6a1d44204
commit 6438d1ee57
9 changed files with 21 additions and 33 deletions

View File

@@ -37,7 +37,7 @@ CXX_STANDARD := -std=c++11
# Defined Symbols
#----------------------------------------------------------------------
DEFINES += -DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_PROGMEM=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DARDUINOJSON_USE_DOUBLE=0
DEFINES += -DEMSESP_DEBUG -DEMSESP_STANDALONE
DEFINES += -DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_TEST
DEFINES += $(ARGS)
DEFAULTS = -DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.5.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"

View File

@@ -2,7 +2,7 @@
[common]
; custom build flags
; options are: EMSESP_DEBUG, EMSESP_UART_DEBUG, EMSESP_DEBUG_SENSOR, EMSESP_WIFI_TWEAK, EMSESP_DEFAULT_BOARD_PROFILE
; options are: EMSESP_DEBUG, EMSESP_UART_DEBUG, EMSESP_DEBUG_SENSOR, EMSESP_WIFI_TWEAK, EMSESP_DEFAULT_BOARD_PROFILE, EMSESP_TEST
; my_build_flags = -DEMSESP_DEBUG -DEMSESP_DEFAULT_BOARD_PROFILE=\"NODEMCU\"
; my_build_flags = -DEMSESP_DEBUG_SENSOR
; my_build_flags = -DEMSESP_DEBUG -DCORE_DEBUG_LEVEL=5 ; 5=verbose, 4=debug, 3=info

View File

@@ -149,7 +149,7 @@ platform = native
build_flags =
-DARDUINO
-DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_PROGMEM=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DARDUINOJSON_USE_DOUBLE=0
-DEMSESP_DEBUG -DEMSESP_STANDALONE
-DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_TEST
-DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.5.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
-lpthread
-std=gnu++17 -Og -ggdb

View File

@@ -21,7 +21,7 @@
#include "emsesp.h"
#include "version.h"
#if defined(EMSESP_DEBUG)
#if defined(EMSESP_TEST)
#include "test/test.h"
#endif
@@ -66,13 +66,9 @@ static std::vector<std::string> log_level_autocomplete(Shell & shell, const std:
}
static void setup_commands(std::shared_ptr<Commands> & commands) {
// add for all contexts
// log, exit, help
for (unsigned int context = ShellContext::MAIN; context < ShellContext::END; context++) {
commands->add_command(context, CommandFlags::USER, {F_(exit)}, EMSESPShell::main_exit_function);
commands->add_command(context, CommandFlags::USER, {F_(help)}, EMSESPShell::main_help_function);
}
commands->add_command(ShellContext::MAIN, CommandFlags::USER, {F_(exit)}, EMSESPShell::main_exit_function);
commands->add_command(ShellContext::MAIN, CommandFlags::USER, {F_(help)}, EMSESPShell::main_help_function);
commands->add_command(ShellContext::MAIN, CommandFlags::USER, {F_(log)}, {F_(log_level_optional)}, console_log_level, log_level_autocomplete);
//
@@ -125,7 +121,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
// System commands
//
#if defined(EMSESP_DEBUG)
#if defined(EMSESP_TEST)
// create commands test
commands->add_command(ShellContext::MAIN,
CommandFlags::USER,
@@ -238,7 +234,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
#endif
*/
#ifdef EMSESP_DEBUG
#if defined(EMSESP_DEBUG)
// only for debug
commands->add_command(
ShellContext::MAIN,

View File

@@ -189,7 +189,7 @@ MAKE_NOTRANSLATION(tpl_date, "Format: < dd.mm.yyyy >")
MAKE_NOTRANSLATION(tpl_input, "Format: <inv>[<evu1><evu2><evu3><comp><aux><cool><heat><dhw><pv>]")
MAKE_NOTRANSLATION(tpl_input4, "Format: <inv>[<comp><aux><cool><heat><dhw><pv>]")
#if defined(EMSESP_DEBUG)
#if defined(EMSESP_TEST)
MAKE_NOTRANSLATION(test_cmd, "run a test")
#endif

View File

@@ -25,7 +25,7 @@
#include <semver200.h>
#if defined(EMSESP_DEBUG)
#if defined(EMSESP_TEST)
#include "test/test.h"
#endif
@@ -54,7 +54,7 @@ Adafruit_NeoPixel pixels(1, 7, NEO_GRB + NEO_KHZ800);
namespace emsesp {
// Languages supported. Note: the order is important and must match locale_translations.h
#ifdef EMSESP_DEBUG
#if defined(EMSESP_DEBUG)
// in Debug mode use one language (en) to save flash memory needed for the tests
const char * const languages[] = {EMSESP_LOCALE_EN};
#else
@@ -260,7 +260,6 @@ void System::syslog_init() {
syslog_.destination(syslog_host_.c_str(), syslog_port_);
syslog_.hostname(hostname().c_str());
// register the command
// removed in 3.6.0
// Command::add(EMSdevice::DeviceType::SYSTEM, F_(syslog), System::command_syslog_level, FL_(changeloglevel_cmd), CommandFlag::ADMIN_ONLY);
@@ -356,9 +355,7 @@ void System::wifi_tweak() {
bool s1 = WiFi.getSleep();
WiFi.setSleep(false); // turn off sleep - WIFI_PS_NONE
bool s2 = WiFi.getSleep();
#if defined(EMSESP_DEBUG)
LOG_DEBUG("[DEBUG] Adjusting WiFi - Tx power %d->%d, Sleep %d->%d", p1, p2, s1, s2);
#endif
LOG_DEBUG("Adjusting WiFi - Tx power %d->%d, Sleep %d->%d", p1, p2, s1, s2);
#endif
}
@@ -420,7 +417,7 @@ void System::start() {
void System::button_OnClick(PButton & b) {
LOG_DEBUG("Button pressed - single click");
#ifdef EMSESP_DEBUG
#if defined(EMSESP_DEBUG)
#ifndef EMSESP_STANDALONE
Test::listDir(LittleFS, FS_CONFIG_DIRECTORY, 3);
#endif
@@ -749,7 +746,7 @@ void System::commands_init() {
// restart and watch (and test) are also exposed as Console commands
Command::add(EMSdevice::DeviceType::SYSTEM, F_(restart), System::command_restart, FL_(restart_cmd), CommandFlag::ADMIN_ONLY);
Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, FL_(watch_cmd));
#if defined(EMSESP_DEBUG)
#if defined(EMSESP_TEST)
Command::add(EMSdevice::DeviceType::SYSTEM, ("test"), System::command_test, FL_(test_cmd));
#endif
@@ -1045,9 +1042,7 @@ bool System::check_upgrade(bool factory_settings) {
// see if we're missing a version, will be < 3.5.0b13 from Dec 23 2022
missing_version = (settingsVersion.empty() || (settingsVersion.length() < 5));
if (missing_version) {
#ifdef EMSESP_DEBUG
LOG_DEBUG("No version information found (%s)", settingsVersion.c_str());
#endif
settingsVersion = "3.4.4"; // this was the last stable version
}
}
@@ -1085,9 +1080,7 @@ bool System::check_upgrade(bool factory_settings) {
// if we're coming from 3.4.4 or 3.5.0b14 then we need to apply new settings
if (missing_version) {
#ifdef EMSESP_DEBUG
LOG_DEBUG("Setting MQTT ID Entity to v3.4 format");
#endif
EMSESP::esp8266React.getMqttSettingsService()->update(
[&](MqttSettings & mqttSettings) {
mqttSettings.entity_format = 0; // use old Entity ID format from v3.4
@@ -1400,7 +1393,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
return true;
}
#if defined(EMSESP_DEBUG)
#if defined(EMSESP_TEST)
// run a test, e.g. http://ems-esp/api?device=system&cmd=test&data=boiler
bool System::command_test(const char * value, const int8_t id) {
return Test::run_test(value, id);

View File

@@ -55,14 +55,13 @@ class System {
static bool command_publish(const char * value, const int8_t id);
static bool command_fetch(const char * value, const int8_t id);
static bool command_restart(const char * value, const int8_t id);
#if defined(EMSESP_DEBUG)
static bool command_test(const char * value, const int8_t id);
#endif
static bool command_syslog_level(const char * value, const int8_t id);
static bool command_watch(const char * value, const int8_t id);
static bool command_info(const char * value, const int8_t id, JsonObject & output);
static bool command_commands(const char * value, const int8_t id, JsonObject & output);
#if defined(EMSESP_TEST)
static bool command_test(const char * value, const int8_t id);
#endif
std::string reset_reason(uint8_t cpu) const;

View File

@@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(EMSESP_DEBUG) || defined(EMSESP_STANDALONE)
#if defined(EMSESP_STANDALONE) || defined(EMSESP_TEST)
#include "test.h"
@@ -1785,7 +1785,7 @@ void Test::add_device(uint8_t device_id, uint8_t product_id) {
uart_telegram({device_id, EMSESP_DEFAULT_EMS_BUS_ID, EMSdevice::EMS_TYPE_VERSION, 0, product_id, 1, 0});
}
#ifdef EMSESP_DEBUG
#ifdef EMSESP_TEST
#ifndef EMSESP_STANDALONE
void Test::listDir(fs::FS & fs, const char * dirname, uint8_t levels) {
Serial.println();

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(EMSESP_DEBUG) || defined(EMSESP_STANDALONE)
#if defined(EMSESP_STANDALONE) || defined(EMSESP_TEST)
#ifndef EMSESP_TEST_H
#define EMSESP_TEST_H