Merge branch 'crush-dllmacros'

Tidy a bunch of includes, make it easier to add tests.
This commit is contained in:
Adriaan de Groot 2020-02-17 15:06:31 +01:00
commit 0238a7338a
65 changed files with 326 additions and 397 deletions

View File

@ -549,10 +549,11 @@ install(
"${PROJECT_BINARY_DIR}/CalamaresConfig.cmake"
"${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/CalamaresUse.cmake"
"CMakeModules/CalamaresAddPlugin.cmake"
"CMakeModules/CalamaresAddModuleSubdirectory.cmake"
"CMakeModules/CalamaresAddLibrary.cmake"
"CMakeModules/CalamaresAddBrandingSubdirectory.cmake"
"CMakeModules/CalamaresAddLibrary.cmake"
"CMakeModules/CalamaresAddModuleSubdirectory.cmake"
"CMakeModules/CalamaresAddPlugin.cmake"
"CMakeModules/CalamaresAddTest.cmake"
"CMakeModules/CalamaresAddTranslations.cmake"
"CMakeModules/CalamaresAutomoc.cmake"
"CMakeModules/CMakeColors.cmake"

View File

@ -0,0 +1,58 @@
# === This file is part of Calamares - <https://github.com/calamares> ===
#
# Calamares 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.
#
# Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0+
# License-Filename: LICENSE
#
###
#
# Support functions for building Calamares tests.
# This extends KDE's ECM tests with some custom patterns.
#
# calamares_add_test(
# <NAME>
# [GUI]
# SOURCES <FILE..>
# )
include( CMakeParseArguments )
include( CalamaresAutomoc )
function( calamares_add_test )
# parse arguments (name needs to be saved before passing ARGN into the macro)
set( NAME ${ARGV0} )
set( options GUI )
set( multiValueArgs SOURCES LIBRARIES )
cmake_parse_arguments( TEST "${options}" "" "${multiValueArgs}" ${ARGN} )
set( TEST_NAME ${NAME} )
if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
${TEST_SOURCES}
TEST_NAME
${TEST_NAME}
LINK_LIBRARIES
calamares
${TEST_LIBRARIES}
Qt5::Core
Qt5::Test
)
calamares_automoc( ${TEST_NAME} )
target_compile_definitions( ${TEST_NAME} PRIVATE -DBUILD_AS_TEST )
if( TEST_GUI )
target_link_libraries( ${TEST_NAME} calamaresui Qt5::Gui )
endif()
endif()
endfunction()

View File

@ -4,6 +4,8 @@
# YAMLCPP_FOUND, if false, do not try to link to yaml-cpp
# YAMLCPP_LIBRARY, where to find yaml-cpp
# YAMLCPP_INCLUDE_DIR, where to find yaml.h
# There is also one IMPORTED library target,
# yamlcpp
#
# By default, the dynamic libraries of yaml-cpp will be found. To find the static ones instead,
# you must set the YAMLCPP_STATIC_LIBRARY variable to TRUE before calling find_package(YamlCpp ...).
@ -48,3 +50,12 @@ find_library(YAMLCPP_LIBRARY
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
# Add an imported target
if( YAMLCPP_LIBRARY )
add_library( yamlcpp UNKNOWN IMPORTED )
set_property( TARGET yamlcpp PROPERTY IMPORTED_LOCATION ${YAMLCPP_LIBRARY} )
if ( YAMLCPP_INCLUDE_DIR )
set_property( TARGET yamlcpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${YAMLCPP_INCLUDE_DIR} )
endif()
endif()

View File

@ -2,6 +2,7 @@ include( CalamaresAddPlugin )
include( CalamaresAddModuleSubdirectory )
include( CalamaresAddLibrary )
include( CalamaresAddBrandingSubdirectory )
include( CalamaresAddTest )
# library
add_subdirectory( libcalamares )

View File

@ -1,5 +1,3 @@
add_definitions( -DUIDLLEXPORT_PRO )
set( calamaresSources
main.cpp
CalamaresApplication.cpp

View File

@ -74,7 +74,6 @@ mark_thirdparty_code( ${kdsagSources} )
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${YAMLCPP_INCLUDE_DIR}
)
### OPTIONAL Python support
@ -126,7 +125,7 @@ target_link_libraries( calamares
LINK_PRIVATE
${OPTIONAL_PRIVATE_LIBRARIES}
LINK_PUBLIC
${YAMLCPP_LIBRARY}
yamlcpp
Qt5::Core
KF5::CoreAddons
${OPTIONAL_PUBLIC_LIBRARIES}
@ -159,85 +158,51 @@ install( FILES ${utilsHeaders} DESTINATION include/libcalam
### TESTING
#
#
if ( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
utils/Tests.cpp
TEST_NAME
calamares_add_test(
libcalamarestest
LINK_LIBRARIES
calamares
Qt5::Core
Qt5::Test
SOURCES
utils/Tests.cpp
)
calamares_automoc( libcalamarestest )
ecm_add_test(
utils/TestPaths.cpp
TEST_NAME
calamares_add_test(
libcalamarestestpaths
LINK_LIBRARIES
calamares
Qt5::Core
Qt5::Test
SOURCES
utils/TestPaths.cpp
)
calamares_automoc( libcalamarestestpaths )
ecm_add_test(
calamares_add_test(
geoiptest
SOURCES
geoip/GeoIPTests.cpp
${geoip_src}
TEST_NAME
geoiptest
LINK_LIBRARIES
calamares
Qt5::Test
${YAMLCPP_LIBRARY}
)
calamares_automoc( geoiptest )
ecm_add_test(
partition/Tests.cpp
TEST_NAME
calamares_add_test(
libcalamarespartitiontest
LINK_LIBRARIES
calamares
Qt5::Test
SOURCES
partition/Tests.cpp
)
calamares_automoc( libcalamarespartitiontest )
ecm_add_test(
locale/Tests.cpp
TEST_NAME
calamares_add_test(
libcalamareslocaletest
LINK_LIBRARIES
calamares
Qt5::Test
SOURCES
locale/Tests.cpp
)
calamares_automoc( libcalamareslocaletest )
ecm_add_test(
network/Tests.cpp
TEST_NAME
calamares_add_test(
libcalamaresnetworktest
LINK_LIBRARIES
calamares
Qt5::Test
SOURCES
network/Tests.cpp
)
calamares_automoc( libcalamaresnetworktest )
ecm_add_test(
modulesystem/Tests.cpp
TEST_NAME
calamares_add_test(
libcalamaresmodulesystemtest
LINK_LIBRARIES
calamares
Qt5::Test
SOURCES
modulesystem/Tests.cpp
)
calamares_automoc( libcalamaresmodulesystemtest )
endif()
if( BUILD_TESTING )
add_executable( test_geoip geoip/test_geoip.cpp ${geoip_src} )
target_link_libraries( test_geoip calamares Qt5::Network ${YAMLCPP_LIBRARY} )
target_link_libraries( test_geoip calamares Qt5::Network yamlcpp )
calamares_automoc( test_geoip )
endif()

View File

@ -21,6 +21,10 @@
#include <QtCore/qglobal.h>
/*
* Mark symbols exported from Calamares libraries with DLLEXPORT.
* These are the public API of the libraries.
*/
#ifndef DLLEXPORT
#if defined( DLLEXPORT_PRO )
#define DLLEXPORT Q_DECL_EXPORT
@ -29,4 +33,30 @@
#endif
#endif
/*
* Mark symbols exported from Calamares C++ plugins with PLUGINDLLEXPORT.
* These are the public API of the libraries (generally, the plugin
* entry point)
*/
#ifndef PLUGINDLLEXPORT
#if defined( PLUGINDLLEXPORT_PRO )
#define PLUGINDLLEXPORT Q_DECL_EXPORT
#else
#define PLUGINDLLEXPORT Q_DECL_IMPORT
#endif
#endif
/*
* For functions that should be static in production but also need to
* be tested, use STATICTEST as linkage specifier. When built as part
* of a test, the function will be given normal linkage.
*/
#ifndef STATICTEST
#if defined( BUILD_AS_TEST )
#define STATICTEST
#else
#define STATICTEST static
#endif
#endif
#endif

View File

@ -1,32 +0,0 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLUGINDLLMACRO_H
#define PLUGINDLLMACRO_H
#include <QtCore/qglobal.h>
#ifndef PLUGINDLLEXPORT
#if defined( PLUGINDLLEXPORT_PRO )
#define PLUGINDLLEXPORT Q_DECL_EXPORT
#else
#define PLUGINDLLEXPORT Q_DECL_IMPORT
#endif
#endif
#endif

View File

@ -22,7 +22,7 @@
#ifndef BRANDING_H
#define BRANDING_H
#include "UiDllMacro.h"
#include "DllMacro.h"
#include "utils/NamedSuffix.h"
@ -40,7 +40,7 @@ namespace Calamares
class GlobalStorage;
class UIDLLEXPORT Branding : public QObject
class DLLEXPORT Branding : public QObject
{
Q_OBJECT
public:

View File

@ -66,7 +66,7 @@ endif()
calamares_add_library( calamaresui
SOURCES ${calamaresui_SOURCES}
EXPORT_MACRO UIDLLEXPORT_PRO
EXPORT_MACRO DLLEXPORT_PRO
LINK_PRIVATE_LIBRARIES
${OPTIONAL_PYTHON_LIBRARIES}
LINK_LIBRARIES

View File

@ -1,32 +0,0 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UIDLLMACRO_H
#define UIDLLMACRO_H
#include <QtCore/qglobal.h>
#ifndef UIDLLEXPORT
#if defined( UIDLLEXPORT_PRO )
#define UIDLLEXPORT Q_DECL_EXPORT
#else
#define UIDLLEXPORT Q_DECL_IMPORT
#endif
#endif
#endif

View File

@ -20,7 +20,7 @@
#ifndef VIEWMANAGER_H
#define VIEWMANAGER_H
#include "UiDllMacro.h"
#include "DllMacro.h"
#include "viewpages/ViewStep.h"
#include <QList>
@ -33,7 +33,7 @@ namespace Calamares
* @brief The ViewManager class handles progression through view pages.
* @note Singleton object, only use through ViewManager::instance().
*/
class UIDLLEXPORT ViewManager : public QObject
class DLLEXPORT ViewManager : public QObject
{
Q_OBJECT
public:

View File

@ -22,14 +22,14 @@
#define CALAMARES_CPPJOBMODULE_H
#include "Module.h"
#include "UiDllMacro.h"
#include "DllMacro.h"
class QPluginLoader;
namespace Calamares
{
class UIDLLEXPORT CppJobModule : public Module
class DLLEXPORT CppJobModule : public Module
{
public:
Type type() const override;

View File

@ -22,7 +22,7 @@
#include "Job.h"
#include "Requirement.h"
#include "UiDllMacro.h"
#include "DllMacro.h"
#include "modulesystem/Descriptor.h"
#include "modulesystem/InstanceKey.h"
@ -40,7 +40,7 @@ namespace Calamares
* takes care of creating an object of the correct type starting from a module
* descriptor structure.
*/
class UIDLLEXPORT Module
class DLLEXPORT Module
{
public:
/**

View File

@ -22,14 +22,14 @@
#include "Module.h"
#include "UiDllMacro.h"
#include "DllMacro.h"
#include <chrono>
namespace Calamares
{
class UIDLLEXPORT ProcessJobModule : public Module
class DLLEXPORT ProcessJobModule : public Module
{
public:
Type type() const override;

View File

@ -21,12 +21,12 @@
#include "Module.h"
#include "UiDllMacro.h"
#include "DllMacro.h"
namespace Calamares
{
class UIDLLEXPORT PythonJobModule : public Module
class DLLEXPORT PythonJobModule : public Module
{
public:
Type type() const override;

View File

@ -20,14 +20,14 @@
#define CALAMARES_PYTHONQTVIEWMODULE_H
#include "Module.h"
#include "UiDllMacro.h"
#include "DllMacro.h"
namespace Calamares
{
class ViewStep;
class UIDLLEXPORT PythonQtViewModule : public Module
class DLLEXPORT PythonQtViewModule : public Module
{
public:
Type type() const override;

View File

@ -21,7 +21,7 @@
#define CALAMARES_VIEWMODULE_H
#include "Module.h"
#include "UiDllMacro.h"
#include "DllMacro.h"
class QPluginLoader;
@ -30,7 +30,7 @@ namespace Calamares
class ViewStep;
class UIDLLEXPORT ViewModule : public Module
class DLLEXPORT ViewModule : public Module
{
public:
Type type() const override;

View File

@ -20,7 +20,7 @@
#ifndef CALAMARESUTILSGUI_H
#define CALAMARESUTILSGUI_H
#include "UiDllMacro.h"
#include "DllMacro.h"
#include <QObject>
#include <QPixmap>
@ -83,7 +83,7 @@ enum ImageMode
* @param size the target pixmap size (default: original SVG size).
* @return the new pixmap.
*/
UIDLLEXPORT QPixmap defaultPixmap( ImageType type,
DLLEXPORT QPixmap defaultPixmap( ImageType type,
ImageMode mode = CalamaresUtils::Original,
const QSize& size = QSize( 0, 0 ) );
@ -95,27 +95,27 @@ UIDLLEXPORT QPixmap defaultPixmap( ImageType type,
* @return the transformed pixmap.
* This one is currently unused.
*/
UIDLLEXPORT QPixmap createRoundedImage( const QPixmap& avatar, const QSize& size, float frameWidthPct = 0.20f );
DLLEXPORT QPixmap createRoundedImage( const QPixmap& avatar, const QSize& size, float frameWidthPct = 0.20f );
/**
* @brief unmarginLayout recursively walks the QLayout tree and removes all margins.
* @param layout the layout to unmargin.
*/
UIDLLEXPORT void unmarginLayout( QLayout* layout );
DLLEXPORT void unmarginLayout( QLayout* layout );
/**
* @brief clearLayout recursively walks the QLayout tree and deletes all the child
* widgets and layouts.
* @param layout the layout to clear.
*/
UIDLLEXPORT void clearLayout( QLayout* layout );
DLLEXPORT void clearLayout( QLayout* layout );
UIDLLEXPORT void setDefaultFontSize( int points );
UIDLLEXPORT int defaultFontSize(); // in points
UIDLLEXPORT int defaultFontHeight(); // in pixels, DPI-specific
UIDLLEXPORT QFont defaultFont();
UIDLLEXPORT QFont largeFont();
UIDLLEXPORT QSize defaultIconSize();
DLLEXPORT void setDefaultFontSize( int points );
DLLEXPORT int defaultFontSize(); // in points
DLLEXPORT int defaultFontHeight(); // in pixels, DPI-specific
DLLEXPORT QFont defaultFont();
DLLEXPORT QFont largeFont();
DLLEXPORT QSize defaultIconSize();
/**
* @brief Size constants for the main Calamares window.

View File

@ -28,10 +28,10 @@
#include <QPixmap>
#include "UiDllMacro.h"
#include "DllMacro.h"
#include "utils/CalamaresUtilsGui.h"
class UIDLLEXPORT ImageRegistry
class DLLEXPORT ImageRegistry
{
public:
static ImageRegistry* instance();

View File

@ -21,7 +21,7 @@
#define VIEWSTEP_H
#include "Job.h"
#include "UiDllMacro.h"
#include "DllMacro.h"
#include "modulesystem/InstanceKey.h"
#include "modulesystem/Requirement.h"
@ -45,7 +45,7 @@ namespace Calamares
* (which shows all of the things which have been collected to be done in the
* next exec-step) through prettyStatus() and createSummaryWidget().
*/
class UIDLLEXPORT ViewStep : public QObject
class DLLEXPORT ViewStep : public QObject
{
Q_OBJECT
public:

View File

@ -12,7 +12,7 @@ include_directories(
if( BUILD_TESTING )
add_executable( test_conf test_conf.cpp )
target_link_libraries( test_conf ${YAMLCPP_LIBRARY} Qt5::Core )
target_link_libraries( test_conf yamlcpp Qt5::Core )
target_include_directories( test_conf PUBLIC ${YAMLCPP_INCLUDE_DIR} )
endif()

View File

@ -8,18 +8,11 @@ calamares_add_plugin( contextualprocess
SHARED_LIB
)
if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
calamares_add_test(
contextualprocesstest
SOURCES
Tests.cpp
ContextualProcessJob.cpp # Builds it a second time
TEST_NAME
contextualprocesstest
LINK_LIBRARIES
${CALAMARES_LIBRARIES}
calamaresui
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
LIBRARIES
yamlcpp
)
calamares_automoc( contextualprocesstest )
endif()

View File

@ -23,7 +23,7 @@
#include <QVariantMap>
#include "CppJob.h"
#include "PluginDllMacro.h"
#include "DllMacro.h"
#include "utils/PluginFactory.h"

View File

@ -27,7 +27,7 @@
#include <utils/PluginFactory.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
class PLUGINDLLEXPORT DracutLuksCfgJob : public Calamares::CppJob
{

View File

@ -27,7 +27,7 @@
#include <utils/PluginFactory.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
class PLUGINDLLEXPORT DummyCppJob : public Calamares::CppJob
{

View File

@ -25,7 +25,7 @@
#include "utils/PluginFactory.h"
#include "viewpages/ViewStep.h"
#include "PluginDllMacro.h"
#include "DllMacro.h"
class FinishedPage;

View File

@ -30,21 +30,15 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND
SHARED_LIB
)
if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
Tests.cpp
TEST_NAME
calamares_add_test(
fsresizertest
LINK_LIBRARIES
${CALAMARES_LIBRARIES}
calamares
SOURCES
Tests.cpp
LIBRARIES
calamares_job_fsresizer # From above
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
yamlcpp
)
set_target_properties( fsresizertest PROPERTIES AUTOMOC TRUE )
target_include_directories( fsresizertest PRIVATE /usr/local/include )
if( TARGET fsresizertest )
target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} )
endif()
else()

View File

@ -27,7 +27,7 @@
#include "partition/PartitionSize.h"
#include "utils/PluginFactory.h"
#include <PluginDllMacro.h>
#include <DllMacro.h>
class CoreBackend; // From KPMCore
class Device; // From KPMCore

View File

@ -32,18 +32,11 @@ if ( KF5CoreAddons_FOUND AND KF5CoreAddons_VERSION VERSION_GREATER_EQUAL 5.58 )
target_compile_definitions( calamares_job_hostinfo PRIVATE WITH_KOSRelease )
endif()
if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
Tests.cpp
HostInfoJob.cpp # Builds it a second time
TEST_NAME
calamares_add_test(
hostinfotest
LINK_LIBRARIES
${CALAMARES_LIBRARIES}
calamaresui
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
SOURCES
Tests.cpp
HostInfoJob.cpp
LIBRARIES
yamlcpp
)
calamares_automoc( hostinfotest )
endif()

View File

@ -20,7 +20,7 @@
#define HOSTINFOJOB_H
#include "CppJob.h"
#include "PluginDllMacro.h"
#include "DllMacro.h"
#include "utils/PluginFactory.h"
#include <QObject>

View File

@ -8,18 +8,11 @@ calamares_add_plugin( initcpio
SHARED_LIB
)
if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
Tests.cpp
TEST_NAME
calamares_add_test(
initcpiotest
LINK_LIBRARIES
${CALAMARES_LIBRARIES}
calamares
SOURCES
Tests.cpp
LIBRARIES
calamares_job_initcpio # From above
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
yamlcpp
)
calamares_automoc( initcpiotest )
endif()

View File

@ -20,7 +20,7 @@
#define INITCPIOJOB_H
#include "CppJob.h"
#include "PluginDllMacro.h"
#include "DllMacro.h"
#include "utils/PluginFactory.h"
#include <QObject>

View File

@ -8,18 +8,11 @@ calamares_add_plugin( initramfs
SHARED_LIB
)
if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
Tests.cpp
TEST_NAME
calamares_add_test(
initramfstest
LINK_LIBRARIES
${CALAMARES_LIBRARIES}
calamares
SOURCES
Tests.cpp
LIBRARIES
calamares_job_initramfs # From above
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
yamlcpp
)
calamares_automoc( initramfstest )
endif()

View File

@ -20,7 +20,7 @@
#define INITRAMFSJOB_H
#include "CppJob.h"
#include "PluginDllMacro.h"
#include "DllMacro.h"
#include "utils/PluginFactory.h"
#include <QObject>

View File

@ -25,7 +25,7 @@
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
class InteractiveTerminalPage;

View File

@ -25,7 +25,7 @@
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
class KeyboardPage;

View File

@ -20,7 +20,7 @@
#ifndef LICENSEPAGEPLUGIN_H
#define LICENSEPAGEPLUGIN_H
#include <PluginDllMacro.h>
#include <DllMacro.h>
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>

View File

@ -27,19 +27,13 @@ calamares_add_plugin( locale
calamaresui
Qt5::Network
${geoip_libs}
${YAMLCPP_LIBRARY}
yamlcpp
SHARED_LIB
)
if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
calamares_add_test(
localetest
SOURCES
Tests.cpp
LocaleConfiguration.cpp
TEST_NAME
localetest
LINK_LIBRARIES
calamares
Qt5::Test
)
calamares_automoc( localetest )
endif()

View File

@ -25,7 +25,7 @@
#include "utils/PluginFactory.h"
#include "viewpages/ViewStep.h"
#include "PluginDllMacro.h"
#include "DllMacro.h"
#include <QFutureWatcher>
#include <QObject>

View File

@ -20,7 +20,7 @@
#define LUKSBOOTKEYFILEJOB_H
#include "CppJob.h"
#include "PluginDllMacro.h"
#include "DllMacro.h"
#include "utils/PluginFactory.h"
#include <QObject>

View File

@ -9,17 +9,10 @@ calamares_add_plugin( machineid
SHARED_LIB
)
if ( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
calamares_add_test(
machineidtest
SOURCES
Tests.cpp
MachineIdJob.cpp
Workers.cpp
TEST_NAME
machineidtest
LINK_LIBRARIES
calamares
Qt5::Core
Qt5::Test
)
calamares_automoc( machineidtest )
endif()

View File

@ -26,7 +26,7 @@
#include <utils/PluginFactory.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
class PLUGINDLLEXPORT MachineIdJob : public Calamares::CppJob
{

View File

@ -28,6 +28,9 @@
#include <QFile>
#include <QtTest/QtTest>
// Internals of Workers.cpp
extern int getUrandomPoolSize();
class MachineIdTests : public QObject
{
Q_OBJECT
@ -93,10 +96,10 @@ MachineIdTests::testPoolSize()
{
#ifdef Q_OS_FREEBSD
// It hardly makes sense, but also the /proc entry is missing
QCOMPARE( MachineId::getUrandomPoolSize(), 512 );
QCOMPARE( getUrandomPoolSize(), 512 );
#else
// Based on a sample size of 1, Netrunner
QCOMPARE( MachineId::getUrandomPoolSize(), 4096 );
QCOMPARE( getUrandomPoolSize(), 4096 );
#endif
}

View File

@ -27,6 +27,34 @@
#include <QFile>
/// @brief Returns a recommended size for the entropy pool (in bytes)
STATICTEST int
getUrandomPoolSize()
{
QFile f( "/proc/sys/kernel/random/poolsize" );
constexpr const int minimumPoolSize = 512;
int poolSize = minimumPoolSize;
if ( f.exists() && f.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
QByteArray v = f.read( 16 );
if ( v.length() > 2 )
{
if ( v.endsWith( '\n' ) )
{
v.chop( 1 );
}
bool ok = false;
poolSize = v.toInt( &ok );
if ( !ok )
{
poolSize = minimumPoolSize;
}
}
}
return ( poolSize >= minimumPoolSize ) ? poolSize : minimumPoolSize;
}
namespace MachineId
{
@ -59,33 +87,6 @@ copyFile( const QString& rootMountPoint, const QString& fileName )
return Calamares::JobResult::ok();
}
int
getUrandomPoolSize()
{
QFile f( "/proc/sys/kernel/random/poolsize" );
constexpr const int minimumPoolSize = 512;
int poolSize = minimumPoolSize;
if ( f.exists() && f.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
QByteArray v = f.read( 16 );
if ( v.length() > 2 )
{
if ( v.endsWith( '\n' ) )
{
v.chop( 1 );
}
bool ok = false;
poolSize = v.toInt( &ok );
if ( !ok )
{
poolSize = minimumPoolSize;
}
}
}
return ( poolSize >= minimumPoolSize ) ? poolSize : minimumPoolSize;
}
Calamares::JobResult
createNewEntropy( int poolSize, const QString& rootMountPoint, const QString& fileName )
{

View File

@ -48,9 +48,6 @@ enum class EntropyGeneration
CopyFromHost
};
/// @brief Returns a recommended size for the entropy pool (in bytes)
int getUrandomPoolSize();
/// @brief Creates a new entropy file @p fileName in the target system at @p rootMountPoint
Calamares::JobResult createNewEntropy( int poolSize, const QString& rootMountPoint, const QString& fileName );

View File

@ -1,5 +1,3 @@
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )
calamares_add_plugin( netinstall
TYPE viewmodule
EXPORT_MACRO PLUGINDLLEXPORT_PRO
@ -15,6 +13,6 @@ calamares_add_plugin( netinstall
LINK_PRIVATE_LIBRARIES
calamaresui
Qt5::Network
${YAMLCPP_LIBRARY}
yamlcpp
SHARED_LIB
)

View File

@ -23,7 +23,7 @@
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
#include <QVariant>

View File

@ -20,7 +20,7 @@
#ifndef NOTESQMLVIEWSTEP_H
#define NOTESQMLVIEWSTEP_H
#include "PluginDllMacro.h"
#include "DllMacro.h"
#include "locale/TranslatableConfiguration.h"
#include "utils/CalamaresUtilsSystem.h"
#include "utils/Variant.h"

View File

@ -22,7 +22,7 @@
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
#include <QVariantMap>

View File

@ -53,18 +53,12 @@ calamares_add_plugin( packagechooser
SHARED_LIB
)
if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
Tests.cpp
TEST_NAME
calamares_add_test(
packagechoosertest
LINK_LIBRARIES
${CALAMARES_LIBRARIES}
GUI
SOURCES
Tests.cpp
LIBRARIES
calamares_viewmodule_packagechooser
Qt5::Core
Qt5::Test
Qt5::Gui
${_extra_libraries}
)
calamares_automoc( packagechoosertest)
endif()

View File

@ -19,7 +19,7 @@
#ifndef PACKAGECHOOSERVIEWSTEP_H
#define PACKAGECHOOSERVIEWSTEP_H
#include "PluginDllMacro.h"
#include "DllMacro.h"
#include "locale/TranslatableConfiguration.h"
#include "utils/PluginFactory.h"
#include "viewpages/ViewStep.h"

View File

@ -24,7 +24,7 @@
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
#include "core/PartitionActions.h"

View File

@ -21,16 +21,12 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}
)
if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test( ${partitionjobtests_SRCS}
TEST_NAME partitionjobtests
LINK_LIBRARIES
${CALAMARES_LIBRARIES}
calamares_add_test(
partitionjobtests
SOURCES ${partitionjobtests_SRCS}
LIBRARIES
kpmcore
Qt5::Core
Qt5::Test
)
set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE )
if( TARGET partitionjobtests )
target_compile_definitions( partitionjobtests PRIVATE ${_partition_defs} )
endif()

View File

@ -21,7 +21,7 @@
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
#include <QObject>
#include <QUrl>

View File

@ -24,7 +24,7 @@
#include <QVariantMap>
#include "CppJob.h"
#include "PluginDllMacro.h"
#include "DllMacro.h"
#include "utils/PluginFactory.h"

View File

@ -8,17 +8,10 @@ calamares_add_plugin( shellprocess
SHARED_LIB
)
if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
Tests.cpp
TEST_NAME
calamares_add_test(
shellprocesstest
LINK_LIBRARIES
${CALAMARES_LIBRARIES}
calamaresui
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
SOURCES
Tests.cpp
LIBRARIES
yamlcpp
)
calamares_automoc( shellprocesstest )
endif()

View File

@ -20,7 +20,7 @@
#define SHELLPROCESSJOB_H
#include "CppJob.h"
#include "PluginDllMacro.h"
#include "DllMacro.h"
#include "utils/CommandList.h"
#include "utils/PluginFactory.h"

View File

@ -24,7 +24,7 @@
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
class SummaryPage;

View File

@ -21,7 +21,7 @@
#include "TrackingType.h"
#include <PluginDllMacro.h>
#include <DllMacro.h>
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>

View File

@ -39,17 +39,11 @@ calamares_add_plugin( users
SHARED_LIB
)
if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test(
calamares_add_test(
passwordtest
SOURCES
PasswordTests.cpp
SetPasswordJob.cpp
TEST_NAME
passwordtest
LINK_LIBRARIES
${CALAMARES_LIBRARIES}
Qt5::Core
Qt5::Test
LIBRARIES
${CRYPT_LIBRARIES}
)
calamares_automoc( passwordtest )
endif()

View File

@ -25,7 +25,7 @@
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
#include <QVariant>

View File

@ -26,7 +26,7 @@
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
#include <QVariantMap>

View File

@ -25,7 +25,7 @@
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <DllMacro.h>
#include <QVariantMap>

View File

@ -25,7 +25,7 @@
#include "utils/PluginFactory.h"
#include "viewpages/ViewStep.h"
#include <PluginDllMacro.h>
#include <DllMacro.h>
#include <QObject>
#include <QVariantMap>