From 1b0d41ac86aa2ad18645c277d8e7d414d59b8df2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 23 Apr 2022 08:32:29 -0500 Subject: [PATCH] MARLIN_TEST_BUILD option --- Marlin/Configuration_adv.h | 3 ++ Marlin/src/MarlinCore.cpp | 9 ++++++ Marlin/src/tests/marlin_tests.cpp | 47 +++++++++++++++++++++++++++++++ ini/features.ini | 1 + platformio.ini | 2 +- 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 Marlin/src/tests/marlin_tests.cpp diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 7ec7ed40a7f9c..17552eef16144 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -4463,6 +4463,9 @@ // //#define PINS_DEBUGGING +// Enable Tests that will run at startup and produce a report +//#define MARLIN_TEST_BUILD + // Enable Marlin dev mode which adds some special commands //#define MARLIN_DEV_MODE diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 50172f98b95b6..c0ae01230732e 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -252,6 +252,11 @@ #include "feature/easythreed_ui.h" #endif +#if ENABLED(MARLIN_TEST_BUILD) + void runStartupTests(); + void runPeriodicTests(); +#endif + PGMSTR(M112_KILL_STR, "M112 Shutdown"); MarlinState marlin_state = MF_INITIALIZING; @@ -1637,6 +1642,8 @@ void setup() { marlin_state = MF_RUNNING; SETUP_LOG("setup() completed."); + + TERN_(MARLIN_TEST_BUILD, runStartupTests()); } /** @@ -1671,5 +1678,7 @@ void loop() { TERN_(HAS_TFT_LVGL_UI, printer_state_polling()); + TERN_(MARLIN_TEST_BUILD, runPeriodicTests()); + } while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards } diff --git a/Marlin/src/tests/marlin_tests.cpp b/Marlin/src/tests/marlin_tests.cpp new file mode 100644 index 0000000000000..89e5664345d8c --- /dev/null +++ b/Marlin/src/tests/marlin_tests.cpp @@ -0,0 +1,47 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../inc/MarlinConfigPre.h" + +#if ENABLED(MARLIN_TEST_BUILD) + +#include "../module/endstops.h" +#include "../module/motion.h" +#include "../module/planner.h" +#include "../module/settings.h" +#include "../module/stepper.h" +#include "../module/temperature.h" + +// Individual tests are localized in each module. +// Each test produces its own report. + +// Startup tests are run at the end of setup() +void runStartupTests() { + // Call post-setup tests here to validate behaviors. +} + +// Periodic tests are run from within loop() +void runPeriodicTests() { + // Call periodic tests here to validate behaviors. +} + +#endif // MARLIN_TEST_BUILD diff --git a/ini/features.ini b/ini/features.ini index 1ee8f3d8955dc..e1b5de70ab3be 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -14,6 +14,7 @@ YHCB2004 = red-scorp/LiquidCrystal_AIP31068@^1.0.4 HAS_TFT_LVGL_UI = lvgl=https://github.com/makerbase-mks/LVGL-6.1.1-MKS/archive/master.zip src_filter=+ extra_scripts=download_mks_assets.py +MARLIN_TEST_BUILD = src_filter=+ POSTMORTEM_DEBUGGING = src_filter=+ + build_flags=-funwind-tables MKS_WIFI_MODULE = QRCode=https://github.com/makerbase-mks/QRCode/archive/master.zip diff --git a/platformio.ini b/platformio.ini index ac52fd7a1f47c..08debb6ff33b5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -49,7 +49,7 @@ extra_scripts = pre:buildroot/share/PlatformIO/scripts/preflight-checks.py post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py lib_deps = -default_src_filter = + - - + +default_src_filter = + - - + - - - - - - - - - - - - -