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}/CalamaresConfig.cmake"
"${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake" "${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/CalamaresUse.cmake" "${PROJECT_BINARY_DIR}/CalamaresUse.cmake"
"CMakeModules/CalamaresAddPlugin.cmake"
"CMakeModules/CalamaresAddModuleSubdirectory.cmake"
"CMakeModules/CalamaresAddLibrary.cmake"
"CMakeModules/CalamaresAddBrandingSubdirectory.cmake" "CMakeModules/CalamaresAddBrandingSubdirectory.cmake"
"CMakeModules/CalamaresAddLibrary.cmake"
"CMakeModules/CalamaresAddModuleSubdirectory.cmake"
"CMakeModules/CalamaresAddPlugin.cmake"
"CMakeModules/CalamaresAddTest.cmake"
"CMakeModules/CalamaresAddTranslations.cmake" "CMakeModules/CalamaresAddTranslations.cmake"
"CMakeModules/CalamaresAutomoc.cmake" "CMakeModules/CalamaresAutomoc.cmake"
"CMakeModules/CMakeColors.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

@ -1,9 +1,11 @@
# Locate yaml-cpp # Locate yaml-cpp
# #
# This module defines # This module defines
# YAMLCPP_FOUND, if false, do not try to link to yaml-cpp # YAMLCPP_FOUND, if false, do not try to link to yaml-cpp
# YAMLCPP_LIBRARY, where to find yaml-cpp # YAMLCPP_LIBRARY, where to find yaml-cpp
# YAMLCPP_INCLUDE_DIR, where to find yaml.h # 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, # 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 ...). # 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) include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY) FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
mark_as_advanced(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( CalamaresAddModuleSubdirectory )
include( CalamaresAddLibrary ) include( CalamaresAddLibrary )
include( CalamaresAddBrandingSubdirectory ) include( CalamaresAddBrandingSubdirectory )
include( CalamaresAddTest )
# library # library
add_subdirectory( libcalamares ) add_subdirectory( libcalamares )

View File

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

View File

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

View File

@ -21,6 +21,10 @@
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
/*
* Mark symbols exported from Calamares libraries with DLLEXPORT.
* These are the public API of the libraries.
*/
#ifndef DLLEXPORT #ifndef DLLEXPORT
#if defined( DLLEXPORT_PRO ) #if defined( DLLEXPORT_PRO )
#define DLLEXPORT Q_DECL_EXPORT #define DLLEXPORT Q_DECL_EXPORT
@ -29,4 +33,30 @@
#endif #endif
#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 #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 #ifndef BRANDING_H
#define BRANDING_H #define BRANDING_H
#include "UiDllMacro.h" #include "DllMacro.h"
#include "utils/NamedSuffix.h" #include "utils/NamedSuffix.h"
@ -40,7 +40,7 @@ namespace Calamares
class GlobalStorage; class GlobalStorage;
class UIDLLEXPORT Branding : public QObject class DLLEXPORT Branding : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -66,7 +66,7 @@ endif()
calamares_add_library( calamaresui calamares_add_library( calamaresui
SOURCES ${calamaresui_SOURCES} SOURCES ${calamaresui_SOURCES}
EXPORT_MACRO UIDLLEXPORT_PRO EXPORT_MACRO DLLEXPORT_PRO
LINK_PRIVATE_LIBRARIES LINK_PRIVATE_LIBRARIES
${OPTIONAL_PYTHON_LIBRARIES} ${OPTIONAL_PYTHON_LIBRARIES}
LINK_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 #ifndef VIEWMANAGER_H
#define VIEWMANAGER_H #define VIEWMANAGER_H
#include "UiDllMacro.h" #include "DllMacro.h"
#include "viewpages/ViewStep.h" #include "viewpages/ViewStep.h"
#include <QList> #include <QList>
@ -33,7 +33,7 @@ namespace Calamares
* @brief The ViewManager class handles progression through view pages. * @brief The ViewManager class handles progression through view pages.
* @note Singleton object, only use through ViewManager::instance(). * @note Singleton object, only use through ViewManager::instance().
*/ */
class UIDLLEXPORT ViewManager : public QObject class DLLEXPORT ViewManager : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@ include_directories(
if( BUILD_TESTING ) if( BUILD_TESTING )
add_executable( test_conf test_conf.cpp ) 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} ) target_include_directories( test_conf PUBLIC ${YAMLCPP_INCLUDE_DIR} )
endif() endif()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,7 +27,7 @@
#include "partition/PartitionSize.h" #include "partition/PartitionSize.h"
#include "utils/PluginFactory.h" #include "utils/PluginFactory.h"
#include <PluginDllMacro.h> #include <DllMacro.h>
class CoreBackend; // From KPMCore class CoreBackend; // From KPMCore
class Device; // 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 ) target_compile_definitions( calamares_job_hostinfo PRIVATE WITH_KOSRelease )
endif() endif()
if( ECM_FOUND AND BUILD_TESTING ) calamares_add_test(
ecm_add_test( hostinfotest
Tests.cpp SOURCES
HostInfoJob.cpp # Builds it a second time Tests.cpp
TEST_NAME HostInfoJob.cpp
hostinfotest LIBRARIES
LINK_LIBRARIES yamlcpp
${CALAMARES_LIBRARIES} )
calamaresui
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
)
calamares_automoc( hostinfotest )
endif()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,6 +27,34 @@
#include <QFile> #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 namespace MachineId
{ {
@ -59,33 +87,6 @@ copyFile( const QString& rootMountPoint, const QString& fileName )
return Calamares::JobResult::ok(); 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 Calamares::JobResult
createNewEntropy( int poolSize, const QString& rootMountPoint, const QString& fileName ) createNewEntropy( int poolSize, const QString& rootMountPoint, const QString& fileName )
{ {

View File

@ -48,9 +48,6 @@ enum class EntropyGeneration
CopyFromHost 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 /// @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 ); 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 calamares_add_plugin( netinstall
TYPE viewmodule TYPE viewmodule
EXPORT_MACRO PLUGINDLLEXPORT_PRO EXPORT_MACRO PLUGINDLLEXPORT_PRO
@ -15,6 +13,6 @@ calamares_add_plugin( netinstall
LINK_PRIVATE_LIBRARIES LINK_PRIVATE_LIBRARIES
calamaresui calamaresui
Qt5::Network Qt5::Network
${YAMLCPP_LIBRARY} yamlcpp
SHARED_LIB SHARED_LIB
) )

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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