← Back to team overview

kicad-developers team mailing list archive

[PATCH] Pcbnew unit test framework

 

Hi,

I have worked out how to do unit tests of the Pcbnew code.

The first example test is a pretty unexciting one about the import
plugin manager (which is what I was doing at the time).

This is followed by a fix for a minor 5.1 bug with a unit test on the
logic (numbered NPTH pads in arrays)

Also a small bunch of small Boost helpers which should allow to use
some nicer boost test code without causing breakage on older boosts.

After these patches, there will be 4 unit test executable run by "make test".

Cheers,

John
From 4bfc6d6cd613c88c848ceb8cd5bd53b08db69746 Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Thu, 20 Dec 2018 14:14:53 +0000
Subject: [PATCH 1/3] QA: Add some more Boost version guards

Some functions aren't defined on Boost < 1.59, which is
sadly inclusive of the Ubuntu LTSs.

Make some guards so you can still use these on the newer
Boosts with some useful fallback where possible.
---
 .../include/unit_test_utils/unit_test_utils.h | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h b/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h
index 8efcd46f2..9e54e0fbb 100644
--- a/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h
+++ b/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h
@@ -24,6 +24,9 @@
 #ifndef UNIT_TEST_UTILS__H
 #define UNIT_TEST_UTILS__H
 
+#include <boost/test/test_case_template.hpp>
+#include <boost/test/unit_test.hpp>
+
 #include <functional>
 
 /**
@@ -50,4 +53,40 @@
  */
 #undef BOOST_TEST
 
+
+#if BOOST_VERSION < 105900
+
+/*
+ * BOOST_TEST_INFO is not available before 1.59. It's not critical for
+ * test pass/fail, it's just info, so just pass along to a logging
+ * function.
+ *
+ * This can be removed when our minimum boost version is 1.59 or higher.
+ */
+#define BOOST_TEST_INFO( A ) BOOST_TEST_MESSAGE( A )
+
+/*
+ *
+ * BOOST_TEST_CONTEXT provides scoped info, but again, only after 1.59.
+ * Replacing with a call to BOOST_TEST_MESSAGE will work, and the
+ * scoping will still work for newer boosts.
+ *
+ * This can be removed when our minimum boost version is 1.59 or higher.
+ */
+#define BOOST_TEST_CONTEXT( A ) BOOST_TEST_MESSAGE( A );
+
+#endif
+
+/*
+ * Define a helper to make it easier to use the right namespace for
+ * defining the print helpers like this:
+ *
+ * template<>
+ * struct BOOST_PRINT::print_log_value< MY_TYPE >
+ */
+#if BOOST_VERSION < 105900
+namespace BOOST_PRINT = boost::test_tools;
+#else
+namespace BOOST_PRINT = boost::test_tools::tt_detail;
+#endif
 #endif // UNIT_TEST_UTILS__H
\ No newline at end of file
-- 
2.20.1

From d910eca31616c58806ac4fde302c664ea33d43a5 Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Tue, 18 Dec 2018 16:37:36 +0000
Subject: [PATCH 3/3] Pcbnew: Array tool should not number NPTHs

Devolve the logic as to whether a pad should be numbered or not
to a pad utility function. Add a very simplistic test for this
function (demonstrating how to test BOARD_ITEMs in general).

Fixes: lp:1804787
* https://bugs.launchpad.net/kicad/+bug/1804787
---
 pcbnew/CMakeLists.txt         |  1 +
 pcbnew/array_creator.cpp      |  4 +-
 pcbnew/pad_naming.cpp         | 37 ++++++++++++++
 pcbnew/pad_naming.h           | 50 +++++++++++++++++++
 qa/pcbnew/CMakeLists.txt      |  1 +
 qa/pcbnew/test_pad_naming.cpp | 90 +++++++++++++++++++++++++++++++++++
 6 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 pcbnew/pad_naming.cpp
 create mode 100644 pcbnew/pad_naming.h
 create mode 100644 qa/pcbnew/test_pad_naming.cpp

diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt
index 8c518d1bf..a52f4b35f 100644
--- a/pcbnew/CMakeLists.txt
+++ b/pcbnew/CMakeLists.txt
@@ -280,6 +280,7 @@ set( PCBNEW_CLASS_SRCS
     onleftclick.cpp
     onrightclick.cpp
     pad_edit_functions.cpp
+    pad_naming.cpp
     pcb_base_edit_frame.cpp
     pcb_footprint_edit_utils.cpp
     pcb_layer_box_selector.cpp
diff --git a/pcbnew/array_creator.cpp b/pcbnew/array_creator.cpp
index 94c9979ef..169a60e8b 100644
--- a/pcbnew/array_creator.cpp
+++ b/pcbnew/array_creator.cpp
@@ -27,7 +27,9 @@
  */
 
 #include "array_creator.h"
+
 #include <board_commit.h>
+#include <pad_naming.h>
 
 #include <dialogs/dialog_create_array.h>
 
@@ -108,7 +110,7 @@ void ARRAY_CREATOR::Invoke()
                 {
                     D_PAD* pad = static_cast<D_PAD*>( new_item );
 
-                    if( !pad->IsAperturePad() )
+                    if( PAD_NAMING::PadCanHaveName( *pad ) )
                         pad->SetName( array_opts->GetItemNumber( ptN ) );
                 }
             }
diff --git a/pcbnew/pad_naming.cpp b/pcbnew/pad_naming.cpp
new file mode 100644
index 000000000..8be04d419
--- /dev/null
+++ b/pcbnew/pad_naming.cpp
@@ -0,0 +1,37 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
+ *
+ * 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 "pad_naming.h"
+
+bool PAD_NAMING::PadCanHaveName( const D_PAD& aPad )
+{
+    // Aperture pads don't get a number
+    if( aPad.IsAperturePad() )
+        return false;
+
+    // NPTH pads don't get numbers
+    if( aPad.GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
+        return false;
+
+    return true;
+}
\ No newline at end of file
diff --git a/pcbnew/pad_naming.h b/pcbnew/pad_naming.h
new file mode 100644
index 000000000..de704aa1b
--- /dev/null
+++ b/pcbnew/pad_naming.h
@@ -0,0 +1,50 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
+ * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
+ *
+ * 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 PAD_NAMING_H
+#define PAD_NAMING_H
+
+#include <class_pad.h>
+
+/**
+ * The PAD_NAMING namespace contains helper functions for common operations
+ * to do with naming of #D_PAD objects.
+ */
+namespace PAD_NAMING
+{
+
+/**
+ * Check if a pad should be named.
+ *
+ * For example, NPTH or paste apertures normally do not have names, as they
+ * cannot be assigned to a netlist.
+ *
+ * @param  aPad the pad to check
+ * @return      true if the pad gets a name
+ */
+bool PadCanHaveName( const D_PAD& aPad );
+
+} // namespace PAD_NAMING
+
+#endif // PAD_NAMING_H
\ No newline at end of file
diff --git a/qa/pcbnew/CMakeLists.txt b/qa/pcbnew/CMakeLists.txt
index eecdb1767..6402eea24 100644
--- a/qa/pcbnew/CMakeLists.txt
+++ b/qa/pcbnew/CMakeLists.txt
@@ -35,6 +35,7 @@ add_executable( qa_pcbnew
     ../../common/observable.cpp
 
     test_graphics_import_mgr.cpp
+    test_pad_naming.cpp
 )
 
 if( BUILD_GITHUB_PLUGIN )
diff --git a/qa/pcbnew/test_pad_naming.cpp b/qa/pcbnew/test_pad_naming.cpp
new file mode 100644
index 000000000..d49f8873e
--- /dev/null
+++ b/qa/pcbnew/test_pad_naming.cpp
@@ -0,0 +1,90 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
+ *
+ * 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 <boost/test/test_case_template.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <class_board.h>
+#include <class_module.h>
+#include <pad_naming.h>
+
+struct PAD_FIXTURE
+{
+    PAD_FIXTURE() : m_board(), m_module( &m_board )
+    {
+    }
+
+    D_PAD MakeNPTH()
+    {
+        D_PAD pad( &m_module );
+
+        pad.SetAttribute( PAD_ATTRIB_HOLE_NOT_PLATED );
+        pad.SetLayerSet( D_PAD::UnplatedHoleMask() );
+
+        return pad;
+    }
+
+    D_PAD MakeAperture()
+    {
+        D_PAD pad( &m_module );
+
+        pad.SetAttribute( PAD_ATTRIB_STANDARD );
+        pad.SetLayerSet( D_PAD::ApertureMask() );
+
+        return pad;
+    }
+
+    D_PAD MakeSmd()
+    {
+        D_PAD pad( &m_module );
+
+        pad.SetAttribute( PAD_ATTRIB_SMD );
+        pad.SetLayerSet( D_PAD::SMDMask() );
+
+        return pad;
+    }
+
+    BOARD  m_board;
+    MODULE m_module;
+};
+
+
+BOOST_FIXTURE_TEST_SUITE( PadNaming, PAD_FIXTURE )
+
+/**
+ * Check what gets names and what doesn't
+ */
+BOOST_AUTO_TEST_CASE( CanName )
+{
+    auto npth = MakeNPTH();
+    BOOST_CHECK_EQUAL( false, PAD_NAMING::PadCanHaveName( npth ) );
+
+    auto aperture = MakeAperture();
+    BOOST_CHECK_EQUAL( false, PAD_NAMING::PadCanHaveName( aperture ) );
+
+    auto smd = MakeSmd();
+    BOOST_CHECK_EQUAL( true, PAD_NAMING::PadCanHaveName( smd ) );
+}
+
+
+BOOST_AUTO_TEST_SUITE_END()
-- 
2.20.1

From 28a6f2965def77918e2b5e657ed76292b067f6f2 Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Wed, 12 Dec 2018 16:49:17 +0000
Subject: [PATCH 2/3] QA: Add unit tests on the Pcbnew library

This now allows code under /pcbnew to be tested.

A first test of the GRAPHICS_IMPORT_MGR is added.
---
 qa/CMakeLists.txt                      |   1 +
 qa/pcbnew/CMakeLists.txt               |  92 +++++++++++++++++++
 qa/pcbnew/test_graphics_import_mgr.cpp | 120 +++++++++++++++++++++++++
 qa/pcbnew/test_module.cpp              |  48 ++++++++++
 4 files changed, 261 insertions(+)
 create mode 100644 qa/pcbnew/CMakeLists.txt
 create mode 100644 qa/pcbnew/test_graphics_import_mgr.cpp
 create mode 100644 qa/pcbnew/test_module.cpp

diff --git a/qa/CMakeLists.txt b/qa/CMakeLists.txt
index 086bf144d..5f0e14083 100644
--- a/qa/CMakeLists.txt
+++ b/qa/CMakeLists.txt
@@ -19,6 +19,7 @@ add_subdirectory( unit_test_utils )
 add_subdirectory( common )
 add_subdirectory( shape_poly_set_refactor )
 add_subdirectory( pcb_parse_input )
+add_subdirectory( pcbnew )
 # add_subdirectory( pcb_test_window )
 # add_subdirectory( polygon_triangulation )
 # add_subdirectory( polygon_generator )
\ No newline at end of file
diff --git a/qa/pcbnew/CMakeLists.txt b/qa/pcbnew/CMakeLists.txt
new file mode 100644
index 000000000..eecdb1767
--- /dev/null
+++ b/qa/pcbnew/CMakeLists.txt
@@ -0,0 +1,92 @@
+# This program source code file is part of KiCad, a free EDA CAD application.
+#
+# Copyright (C) 2018 KiCad Developers, see CHANGELOG.TXT for contributors.
+#
+# 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
+
+
+add_executable( qa_pcbnew
+    # A single top to load the pcnew kiface
+    # ../../common/single_top.cpp
+
+    # The main test entry points
+    test_module.cpp
+
+    # stuff from common due to...units?
+    ../../common/eda_text.cpp
+
+    # stuff from common which is needed...why?
+    ../../common/colors.cpp
+    ../../common/observable.cpp
+
+    test_graphics_import_mgr.cpp
+)
+
+if( BUILD_GITHUB_PLUGIN )
+    set( GITHUB_PLUGIN_LIBRARIES github_plugin )
+endif()
+
+set_source_files_properties( ../common/single_top.cpp pcbnew.cpp PROPERTIES
+    COMPILE_DEFINITIONS "TOP_FRAME=FRAME_PCB;PGM_DATA_FILE_EXT=\"kicad_pcb\";BUILD_KIWAY_DLL"
+)
+
+include_directories( BEFORE ${INC_BEFORE} )
+include_directories(
+    ${CMAKE_SOURCE_DIR}
+    ${CMAKE_SOURCE_DIR}/include
+    ${CMAKE_SOURCE_DIR}/polygon
+    ${CMAKE_SOURCE_DIR}/pcbnew
+    ${CMAKE_SOURCE_DIR}/common
+    ${CMAKE_SOURCE_DIR}/pcbnew/router
+    ${CMAKE_SOURCE_DIR}/pcbnew/tools
+    ${CMAKE_SOURCE_DIR}/pcbnew/dialogs
+    ${INC_AFTER}
+)
+
+target_link_libraries( qa_pcbnew
+    3d-viewer
+    connectivity
+    pcbcommon
+    pnsrouter
+    pcad2kicadpcb
+    common
+    legacy_wx
+    polygon
+    bitmaps
+    gal
+    qa_utils
+    lib_dxf
+    idf3
+    pcbnew_kiface_objects
+    unit_test_utils
+    ${wxWidgets_LIBRARIES}
+    ${GITHUB_PLUGIN_LIBRARIES}
+    ${GDI_PLUS_LIBRARIES}
+    ${PYTHON_LIBRARIES}
+    ${Boost_LIBRARIES}      # must follow GITHUB
+    ${PCBNEW_EXTRA_LIBS}    # -lrt must follow Boost
+)
+
+# we need to pretend to be something to appease the units code
+target_compile_definitions( qa_pcbnew
+    PRIVATE PCBNEW
+)
+
+add_test( NAME pcbnew
+    COMMAND qa_pcbnew
+)
\ No newline at end of file
diff --git a/qa/pcbnew/test_graphics_import_mgr.cpp b/qa/pcbnew/test_graphics_import_mgr.cpp
new file mode 100644
index 000000000..ac6891cae
--- /dev/null
+++ b/qa/pcbnew/test_graphics_import_mgr.cpp
@@ -0,0 +1,120 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2018 KiCad Developers, see CHANGELOG.TXT for contributors.
+ *
+ * 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 <boost/test/test_case_template.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <unit_test_utils/unit_test_utils.h>
+
+#include <import_gfx/graphics_import_mgr.h>
+#include <import_gfx/graphics_import_plugin.h>
+
+/**
+ * Declares a struct as the Boost test fixture.
+ */
+BOOST_AUTO_TEST_SUITE( GraphicsImportMgr )
+
+static bool pluginHandlesExt( const GRAPHICS_IMPORT_PLUGIN& aPlugin, const std::string& aExt )
+{
+    const auto exts = aPlugin.GetFileExtensions();
+
+    return std::find( exts.begin(), exts.end(), wxString( aExt ) ) != exts.end();
+}
+
+struct TYPE_TO_EXTS
+{
+    // The type of the plugin
+    GRAPHICS_IMPORT_MGR::GFX_FILE_T m_type;
+
+    /// The list of extensions we expect this plugin to handle
+    std::vector<std::string> m_exts;
+
+    /// The name of the plugin
+    std::string m_name;
+};
+
+const static std::vector<TYPE_TO_EXTS> type_to_ext_cases = {
+    {
+            GRAPHICS_IMPORT_MGR::GFX_FILE_T::DXF,
+            { "dxf" },
+            "AutoCAD DXF",
+    },
+    {
+            GRAPHICS_IMPORT_MGR::GFX_FILE_T::SVG,
+            { "svg" },
+            "Scalable Vector Graphics",
+    },
+};
+
+/**
+ * Check we can look a plugin up by type and get the right one
+ */
+BOOST_AUTO_TEST_CASE( SelectByType )
+{
+    GRAPHICS_IMPORT_MGR mgr( {} );
+
+    for( const auto& c : type_to_ext_cases )
+    {
+        auto plugin = mgr.GetPlugin( c.m_type );
+
+        BOOST_CHECK( !!plugin );
+
+        if( plugin )
+        {
+            for( const auto& ext : c.m_exts )
+            {
+                BOOST_CHECK_MESSAGE( pluginHandlesExt( *plugin, ext ),
+                        "Plugin '" << plugin->GetName() << "' handles extension: " << ext );
+            }
+        }
+    }
+}
+
+/**
+ * Check we can look a plugin up by ext and get the right one
+ */
+BOOST_AUTO_TEST_CASE( SelectByExt )
+{
+    GRAPHICS_IMPORT_MGR mgr( {} );
+
+    for( const auto& c : type_to_ext_cases )
+    {
+        for( const auto& ext : c.m_exts )
+        {
+            auto plugin = mgr.GetPluginByExt( wxString( ext ) );
+
+            BOOST_CHECK( !!plugin );
+
+            if( plugin )
+            {
+                // This is an ugly way to check the right plugin,
+                // as we have to keep a list of expected strings (the plugins
+                // don't report any kind of other unique identifier).
+                // But it's quick and dirty and it's good enough!
+                BOOST_CHECK_EQUAL( c.m_name, plugin->GetName() );
+            }
+        }
+    }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/qa/pcbnew/test_module.cpp b/qa/pcbnew/test_module.cpp
new file mode 100644
index 000000000..5f593f6b2
--- /dev/null
+++ b/qa/pcbnew/test_module.cpp
@@ -0,0 +1,48 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2018 KiCad Developers, see CHANGELOG.TXT for contributors.
+ *
+ * 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
+ */
+
+/**
+ * Main file for the pcbnew tests to be compiled
+ */
+#include <boost/test/unit_test.hpp>
+
+#include <wx/init.h>
+
+
+bool init_unit_test()
+{
+    boost::unit_test::framework::master_test_suite().p_name.value = "Common Pcbnew module tests";
+    return wxInitialize();
+}
+
+
+int main( int argc, char* argv[] )
+{
+    int ret = boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
+
+    // This causes some glib warnings on GTK3 (http://trac.wxwidgets.org/ticket/18274)
+    // but without it, Valgrind notices a lot of leaks from WX
+    wxUninitialize();
+
+    return ret;
+}
\ No newline at end of file
-- 
2.20.1


Follow ups