add test to crash EMS-ESP

This commit is contained in:
proddy
2021-07-03 20:20:56 +02:00
parent c217a40710
commit 3eb2202117
2 changed files with 14 additions and 3 deletions

View File

@@ -934,8 +934,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
shell.printfln(F("Testing RESTful API..."));
Mqtt::ha_enabled(false);
run_test("general");
DynamicJsonDocument doc(EMSESP_JSON_SIZE_XXLARGE_DYN);
JsonObject json = doc.to<JsonObject>();
AsyncWebServerRequest request;
request.method(HTTP_GET);
request.url("/api/thermostat/seltemp");
@@ -945,6 +943,18 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
EMSESP::webAPIService.webAPIService_get(&request);
#endif
}
if (command == "crash") {
shell.printfln(F("Forcing a crash..."));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdiv-by-zero"
#pragma GCC diagnostic ignored "-Wunused-variable"
uint8_t a = 2 / 0;
shell.printfln(F("Testing %s"), a);
#pragma GCC diagnostic pop
}
}
// simulates a telegram in the Rx queue, but without the CRC which is added automatically

View File

@@ -38,7 +38,8 @@ namespace emsesp {
// #define EMSESP_DEBUG_DEFAULT "board_profile"
// #define EMSESP_DEBUG_DEFAULT "shower_alert"
// #define EMSESP_DEBUG_DEFAULT "310"
#define EMSESP_DEBUG_DEFAULT "api"
// #define EMSESP_DEBUG_DEFAULT "api"
#define EMSESP_DEBUG_DEFAULT "crash"
class Test {
public: