From 99bcdf7979da1c232c61661c466ba874622f6fd8 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Mon, 24 Oct 2022 00:15:32 +0200 Subject: [PATCH] qa: introducing headless regression test suite for the P&S. Works by playing out pre-recorded events and comparing the resulting geometry against a human-approved reference. Other changes: - store all router settings (ROUTING_SETTINGS) in the debug dump in a separate JSON file - store router mode (single/diff/tune) in the event log file - factor out the regression test player and the graphical log/debug tool into separate main files - bring CONSOLE_LOG and CONSOLE_MSG_REPORTER to the common test headers --- qa/tools/pns/CMakeLists.txt | 57 +- qa/tools/pns/label_manager.cpp | 23 + qa/tools/pns/label_manager.h | 26 +- .../pns/{main.cpp => pns_debug_tool_main.cpp} | 40 +- qa/tools/pns/pns_log_file.cpp | 251 +++++- qa/tools/pns/pns_log_file.h | 27 +- qa/tools/pns/pns_log_player.cpp | 82 +- qa/tools/pns/pns_log_player.h | 13 +- qa/tools/pns/pns_log_viewer.cpp | 798 ------------------ qa/tools/pns/pns_log_viewer_frame.cpp | 11 +- qa/tools/pns/qa_pns_regressions_main.cpp | 185 ++++ 11 files changed, 661 insertions(+), 852 deletions(-) rename qa/tools/pns/{main.cpp => pns_debug_tool_main.cpp} (61%) delete mode 100644 qa/tools/pns/pns_log_viewer.cpp create mode 100644 qa/tools/pns/qa_pns_regressions_main.cpp diff --git a/qa/tools/pns/CMakeLists.txt b/qa/tools/pns/CMakeLists.txt index 04699c7d6b..09eeecf3dd 100644 --- a/qa/tools/pns/CMakeLists.txt +++ b/qa/tools/pns/CMakeLists.txt @@ -25,10 +25,10 @@ find_package(Boost COMPONENTS unit_test_framework REQUIRED) find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml stc REQUIRED ) -add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW -DTEST_APP_GUI) +add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW) -add_executable( test_pns +set( COMMON_SRCS ../../../pcbnew/drc/drc_rule.cpp ../../../pcbnew/drc/drc_rule_condition.cpp ../../../pcbnew/drc/drc_rule_parser.cpp @@ -54,6 +54,10 @@ add_executable( test_pns pns_log_file.cpp pns_log_player.cpp pns_test_debug_decorator.cpp +) + +add_executable( pns_debug_tool + ${COMMON_SRCS} pns_log_viewer_frame.cpp pns_log_viewer_frame_base.cpp label_manager.cpp @@ -63,21 +67,58 @@ add_executable( test_pns ../../qa_utils/mocks.cpp playground.cpp - main.cpp + pns_debug_tool_main.cpp ) -# Pcbnew tests, so pretend to be pcbnew (for units, etc) -target_compile_definitions( test_pns - PRIVATE PCBNEW +add_executable( qa_pns_regressions + ${COMMON_SRCS} + ../../qa_utils/pcb_test_frame.cpp + ../../qa_utils/test_app_main.cpp + ../../qa_utils/utility_program.cpp + ../../qa_utils/mocks.cpp + qa_pns_regressions_main.cpp ) + +# Pcbnew tests, so pretend to be pcbnew (for units, etc) +target_compile_definitions( pns_debug_tool + PRIVATE PCBNEW +) +target_compile_definitions( qa_pns_regressions + PRIVATE PCBNEW TEST_APP_NO_MAIN +) # Anytime we link to the kiface_objects, we have to add a dependency on the last object # to ensure that the generated lexer files are finished being used before the qa runs in a # multi-threaded build -add_dependencies( test_pns pcbnew ) +add_dependencies( pns_debug_tool pcbnew ) +add_dependencies( qa_pns_regressions pcbnew ) -target_link_libraries( test_pns +target_link_libraries( pns_debug_tool + qa_pcbnew_utils + connectivity + pcbcommon + pnsrouter + gal + common + gal + qa_utils + dxflib_qcad + tinyspline_lib + nanosvg + idf3 + pcbcommon + 3d-viewer + ${PCBNEW_IO_LIBRARIES} + ${wxWidgets_LIBRARIES} + ${GDI_PLUS_LIBRARIES} + ${PYTHON_LIBRARIES} + ${Boost_LIBRARIES} + ${PCBNEW_EXTRA_LIBS} # -lrt must follow Boost +) + + +target_link_libraries( qa_pns_regressions qa_pcbnew_utils connectivity pcbcommon diff --git a/qa/tools/pns/label_manager.cpp b/qa/tools/pns/label_manager.cpp index eae0c9431f..d4744d65ab 100644 --- a/qa/tools/pns/label_manager.cpp +++ b/qa/tools/pns/label_manager.cpp @@ -1,3 +1,26 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2020-2022 KiCad Developers. + * + * 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 2 + * 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, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + #include #include #include diff --git a/qa/tools/pns/label_manager.h b/qa/tools/pns/label_manager.h index 0756035b13..fd642fcb9f 100644 --- a/qa/tools/pns/label_manager.h +++ b/qa/tools/pns/label_manager.h @@ -1,3 +1,27 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2020-2022 KiCad Developers. + * + * 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 2 + * 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, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + + #ifndef __LABEL_MANAGER_H #define __LABEL_MANAGER_H @@ -38,4 +62,4 @@ private: std::vector