From 2ccdc4f9ed232af3b55fe633fafe64a9be508ff8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 4 Aug 2022 17:56:09 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20MARLIN=5FTE?= =?UTF-8?q?ST=5FBUILD=20=E2=80=93=20for=20future=20use=20(#24077)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 3 ++ Marlin/src/MarlinCore.cpp | 18 +++++++----- Marlin/src/tests/marlin_tests.cpp | 47 +++++++++++++++++++++++++++++++ Marlin/src/tests/marlin_tests.h | 25 ++++++++++++++++ ini/features.ini | 1 + platformio.ini | 2 +- 6 files changed, 88 insertions(+), 8 deletions(-) create mode 100644 Marlin/src/tests/marlin_tests.cpp create mode 100644 Marlin/src/tests/marlin_tests.h diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index b076949a88..921d36b7a8 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -4295,6 +4295,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 31b6184317..921c3c60bc 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -39,17 +39,13 @@ #endif #include -#include "core/utility.h" - +#include "module/endstops.h" #include "module/motion.h" #include "module/planner.h" -#include "module/endstops.h" -#include "module/temperature.h" -#include "module/settings.h" #include "module/printcounter.h" // PrintCounter or Stopwatch - +#include "module/settings.h" #include "module/stepper.h" -#include "module/stepper/indirection.h" +#include "module/temperature.h" #include "gcode/gcode.h" #include "gcode/parser.h" @@ -248,6 +244,10 @@ #include "feature/easythreed_ui.h" #endif +#if ENABLED(MARLIN_TEST_BUILD) + #include "tests/marlin_tests.h" +#endif + PGMSTR(M112_KILL_STR, "M112 Shutdown"); MarlinState marlin_state = MF_INITIALIZING; @@ -1635,6 +1635,8 @@ void setup() { marlin_state = MF_RUNNING; SETUP_LOG("setup() completed."); + + TERN_(MARLIN_TEST_BUILD, runStartupTests()); } /** @@ -1669,5 +1671,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 0000000000..89e5664345 --- /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/Marlin/src/tests/marlin_tests.h b/Marlin/src/tests/marlin_tests.h new file mode 100644 index 0000000000..6afce1ef37 --- /dev/null +++ b/Marlin/src/tests/marlin_tests.h @@ -0,0 +1,25 @@ +/** + * 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 . + * + */ +#pragma once + +void runStartupTests(); +void runPeriodicTests(); diff --git a/ini/features.ini b/ini/features.ini index ee065cb9b9..b6a07c76df 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 b2f178ec0f..4f5598f6af 100644 --- a/platformio.ini +++ b/platformio.ini @@ -51,7 +51,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 = + - - + - - - - - - - - - - - - -