Merge branch 'clang-warnings'
This commit is contained in:
commit
63507801b7
@ -193,6 +193,7 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||
)
|
||||
string( APPEND CMAKE_CXX_FLAGS " ${CLANG_WARNINGS}" )
|
||||
endforeach()
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTREACHED='//'" )
|
||||
|
||||
# Third-party code where we don't care so much about compiler warnings
|
||||
# (because it's uncomfortable to patch) get different flags; use
|
||||
@ -211,12 +212,15 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )
|
||||
|
||||
set( CALAMARES_AUTOMOC_OPTIONS "-butils/moc-warnings.h" )
|
||||
set( CALAMARES_AUTOUIC_OPTIONS --include utils/moc-warnings.h )
|
||||
else()
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined" )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--fatal-warnings -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type" )
|
||||
|
||||
set( SUPPRESS_3RDPARTY_WARNINGS "" )
|
||||
set( SUPPRESS_BOOST_WARNINGS "" )
|
||||
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTREACHED='__builtin_unreachable();'" )
|
||||
endif()
|
||||
|
||||
# Use mark_thirdparty_code() to reduce warnings from the compiler
|
||||
|
@ -61,11 +61,6 @@ function(calamares_add_library)
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR})
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
if(LIBRARY_UI)
|
||||
qt5_wrap_ui(LIBRARY_UI_SOURCES ${LIBRARY_UI})
|
||||
list(APPEND LIBRARY_SOURCES ${LIBRARY_UI_SOURCES})
|
||||
endif()
|
||||
|
||||
# add resources from current dir
|
||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${LIBRARY_RESOURCES}")
|
||||
qt5_add_resources(LIBRARY_RC_SOURCES "${LIBRARY_RESOURCES}")
|
||||
@ -83,7 +78,10 @@ function(calamares_add_library)
|
||||
endif()
|
||||
|
||||
calamares_automoc(${target})
|
||||
|
||||
if(LIBRARY_UI)
|
||||
calamares_autouic(${target} ${LIBRARY_UI})
|
||||
endif()
|
||||
|
||||
if(LIBRARY_EXPORT_MACRO)
|
||||
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_EXPORT_MACRO})
|
||||
endif()
|
||||
|
@ -18,7 +18,7 @@
|
||||
#
|
||||
###
|
||||
#
|
||||
# Helper function for doing automoc on a target.
|
||||
# Helper function for doing automoc on a target, and autoui on a .ui file.
|
||||
#
|
||||
# Sets AUTOMOC TRUE for a target.
|
||||
#
|
||||
@ -27,6 +27,8 @@
|
||||
# libcalamares/utils/moc-warnings.h file to the moc, which in turn
|
||||
# reduces compiler warnings in generated MOC code.
|
||||
#
|
||||
# If the global variable CALAMARES_AUTOUIC_OPTIONS is set, adds that
|
||||
# to the options passed to uic.
|
||||
|
||||
function(calamares_automoc TARGET)
|
||||
set_target_properties( ${TARGET} PROPERTIES AUTOMOC TRUE )
|
||||
@ -34,3 +36,12 @@ function(calamares_automoc TARGET)
|
||||
set_target_properties( ${TARGET} PROPERTIES AUTOMOC_MOC_OPTIONS "${CALAMARES_AUTOMOC_OPTIONS}" )
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(calamares_autouic TARGET)
|
||||
set_target_properties( ${TARGET} PROPERTIES AUTOUIC TRUE )
|
||||
if ( CALAMARES_AUTOUIC_OPTIONS )
|
||||
foreach(S ${ARGN})
|
||||
set_property(SOURCE ${S} PROPERTY AUTOUIC_OPTIONS "${CALAMARES_AUTOUIC_OPTIONS}")
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -41,8 +41,8 @@ BUILDDIR=$(mktemp -d --suffix=-build --tmpdir=.)
|
||||
if test "x$BUILD_DEFAULT" = "xtrue" ; then
|
||||
rm -rf "$BUILDDIR"
|
||||
mkdir "$BUILDDIR" || { echo "Could not create build directory." ; exit 1 ; }
|
||||
( cd "$BUILDDIR" && cmake .. && make -j4 ) || { echo "Could not perform test-build." ; exit 1 ; }
|
||||
( cd "$BUILDDIR" && make test ) || { echo "Tests failed." ; exit 1 ; }
|
||||
( cd "$BUILDDIR" && cmake .. && make -j4 ) || { echo "Could not perform test-build in $BUILDDIR." ; exit 1 ; }
|
||||
( cd "$BUILDDIR" && make test ) || { echo "Tests failed in $BUILDDIR." ; exit 1 ; }
|
||||
fi
|
||||
|
||||
### Build with clang
|
||||
@ -53,13 +53,13 @@ if test "x$BUILD_CLANG" = "xtrue" ; then
|
||||
# Do build again with clang
|
||||
rm -rf "$BUILDDIR"
|
||||
mkdir "$BUILDDIR" || { echo "Could not create build directory." ; exit 1 ; }
|
||||
( cd "$BUILDDIR" && CC=clang CXX=clang++ cmake .. && make -j4 ) || { echo "Could not perform test-build." ; exit 1 ; }
|
||||
( cd "$BUILDDIR" && make test ) || { echo "Tests failed." ; exit 1 ; }
|
||||
( cd "$BUILDDIR" && CC=clang CXX=clang++ cmake .. && make -j4 ) || { echo "Could not perform test-build in $BUILDDIR." ; exit 1 ; }
|
||||
( cd "$BUILDDIR" && make test ) || { echo "Tests failed in $BUILDDIR." ; exit 1 ; }
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$BUILD_ONLY" = "xtrue" ; then
|
||||
echo "Builds completed, release stopped."
|
||||
echo "Builds completed, release stopped. Build remains in $BUILDDIR."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -167,6 +167,16 @@ if ( ECM_FOUND AND BUILD_TESTING )
|
||||
${YAMLCPP_LIBRARY}
|
||||
)
|
||||
calamares_automoc( geoiptest )
|
||||
|
||||
ecm_add_test(
|
||||
partition/Tests.cpp
|
||||
TEST_NAME
|
||||
libcalamarespartitiontest
|
||||
LINK_LIBRARIES
|
||||
calamares
|
||||
Qt5::Test
|
||||
)
|
||||
calamares_automoc( libcalamarespartitiontest )
|
||||
endif()
|
||||
|
||||
if( BUILD_TESTING )
|
||||
|
@ -25,7 +25,9 @@
|
||||
|
||||
#include <QByteArray>
|
||||
|
||||
namespace CalamaresUtils::GeoIP
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace GeoIP
|
||||
{
|
||||
|
||||
GeoIPJSON::GeoIPJSON(const QString& attribute)
|
||||
@ -88,6 +90,5 @@ GeoIPJSON::processReply( const QByteArray& data )
|
||||
return splitTZString( rawReply( data ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
@ -21,7 +21,9 @@
|
||||
|
||||
#include "Interface.h"
|
||||
|
||||
namespace CalamaresUtils::GeoIP
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace GeoIP
|
||||
{
|
||||
/** @brief GeoIP lookup for services that return JSON.
|
||||
*
|
||||
@ -46,5 +48,6 @@ public:
|
||||
virtual QString rawReply(const QByteArray & ) override;
|
||||
} ;
|
||||
|
||||
}
|
||||
} // namespace
|
||||
#endif
|
||||
|
@ -23,7 +23,9 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QtXml/QDomDocument>
|
||||
|
||||
namespace CalamaresUtils::GeoIP
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace GeoIP
|
||||
{
|
||||
|
||||
GeoIPXML::GeoIPXML( const QString& element )
|
||||
@ -87,4 +89,5 @@ GeoIPXML::processReply( const QByteArray& data )
|
||||
return RegionZonePair();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
@ -21,7 +21,9 @@
|
||||
|
||||
#include "Interface.h"
|
||||
|
||||
namespace CalamaresUtils::GeoIP
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace GeoIP
|
||||
{
|
||||
/** @brief GeoIP lookup with XML data
|
||||
*
|
||||
@ -46,5 +48,6 @@ public:
|
||||
virtual QString rawReply(const QByteArray & ) override;
|
||||
} ;
|
||||
|
||||
}
|
||||
} // namespace
|
||||
#endif
|
||||
|
@ -47,7 +47,9 @@ handlerTypes()
|
||||
return names;
|
||||
}
|
||||
|
||||
namespace CalamaresUtils::GeoIP
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace GeoIP
|
||||
{
|
||||
|
||||
Handler::Handler()
|
||||
@ -110,9 +112,8 @@ create_interface( Handler::Type t, const QString& selector )
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
default: // there are no others
|
||||
return nullptr;
|
||||
}
|
||||
NOTREACHED return nullptr;
|
||||
}
|
||||
|
||||
static RegionZonePair
|
||||
@ -179,5 +180,5 @@ Handler::queryRaw() const
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
@ -25,8 +25,9 @@
|
||||
#include <QString>
|
||||
#include <QVariantMap>
|
||||
|
||||
namespace CalamaresUtils {}
|
||||
namespace CalamaresUtils::GeoIP
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace GeoIP
|
||||
{
|
||||
|
||||
/** @brief Handle one complete GeoIP lookup.
|
||||
@ -86,6 +87,7 @@ private:
|
||||
const QString m_selector;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
|
@ -20,7 +20,9 @@
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
namespace CalamaresUtils::GeoIP
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace GeoIP
|
||||
{
|
||||
|
||||
Interface::Interface(const QString& e)
|
||||
@ -51,4 +53,5 @@ splitTZString( const QString& tz )
|
||||
return RegionZonePair( QString(), QString() );
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
@ -27,8 +27,9 @@
|
||||
|
||||
class QByteArray;
|
||||
|
||||
namespace CalamaresUtils {}
|
||||
namespace CalamaresUtils::GeoIP
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace GeoIP
|
||||
{
|
||||
/** @brief A Region, Zone pair of strings
|
||||
*
|
||||
@ -94,5 +95,6 @@ protected:
|
||||
QString m_element; // string for selecting from data
|
||||
} ;
|
||||
|
||||
}
|
||||
} // namespace
|
||||
#endif
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
#include "Label.h"
|
||||
|
||||
namespace CalamaresUtils::Locale
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace Locale
|
||||
{
|
||||
|
||||
Label::Label()
|
||||
@ -70,4 +72,5 @@ QLocale Label::getLocale( const QString& localeName )
|
||||
return QLocale( localeName );
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
@ -23,8 +23,9 @@
|
||||
#include <QLocale>
|
||||
#include <QString>
|
||||
|
||||
namespace CalamaresUtils {}
|
||||
namespace CalamaresUtils::Locale
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace Locale
|
||||
{
|
||||
|
||||
/**
|
||||
@ -120,7 +121,7 @@ protected:
|
||||
QString m_englishLabel;
|
||||
} ;
|
||||
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
@ -22,7 +22,9 @@
|
||||
|
||||
#include "CalamaresVersion.h" // For the list of translations
|
||||
|
||||
namespace CalamaresUtils::Locale
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace Locale
|
||||
{
|
||||
|
||||
LabelModel::LabelModel( const QStringList& locales, QObject* parent )
|
||||
@ -121,10 +123,11 @@ LabelModel::find( const QString& countryCode ) const
|
||||
return find( [&]( const Label& l ){ return l.language() == c_l.second; } );
|
||||
}
|
||||
|
||||
LabelModel* const availableTranslations()
|
||||
LabelModel* availableTranslations()
|
||||
{
|
||||
static LabelModel model( QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') );
|
||||
return &model;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
@ -26,8 +26,9 @@
|
||||
#include <QVector>
|
||||
|
||||
|
||||
namespace CalamaresUtils {}
|
||||
namespace CalamaresUtils::Locale
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace Locale
|
||||
{
|
||||
|
||||
class DLLEXPORT LabelModel : public QAbstractListModel
|
||||
@ -78,7 +79,7 @@ private:
|
||||
*
|
||||
* NOTE: While the model is not typed const, it should be. Do not modify.
|
||||
*/
|
||||
DLLEXPORT LabelModel* const availableTranslations();
|
||||
|
||||
DLLEXPORT LabelModel* availableTranslations();
|
||||
}
|
||||
} // namespace
|
||||
#endif
|
||||
|
@ -20,7 +20,9 @@
|
||||
|
||||
#include "CountryData_p.cpp"
|
||||
|
||||
namespace CalamaresUtils::Locale
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace Locale
|
||||
{
|
||||
|
||||
struct TwoChar
|
||||
@ -87,4 +89,5 @@ QLocale::Language languageForCountry(QLocale::Country country)
|
||||
return p->l;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
@ -24,8 +24,9 @@
|
||||
#include <QLocale>
|
||||
#include <QPair>
|
||||
|
||||
namespace CalamaresUtils {}
|
||||
namespace CalamaresUtils::Locale
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
namespace Locale
|
||||
{
|
||||
/* All the functions in this file do lookups of locale data
|
||||
* based on CLDR tables; these are lookups that you can't (easily)
|
||||
@ -48,6 +49,7 @@ namespace CalamaresUtils::Locale
|
||||
DLLEXPORT QPair< QLocale::Country, QLocale::Language > countryData( const QString& code );
|
||||
/// @brief Get a likely locale for a 2-letter country code
|
||||
DLLEXPORT QLocale countryLocale( const QString& code );
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
|
||||
* Copyright 2019, Adriaan de Groot <groot@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
|
||||
@ -42,23 +43,23 @@ unitSuffixes()
|
||||
PartitionSize::PartitionSize( const QString& s )
|
||||
: NamedSuffix( unitSuffixes(), s )
|
||||
{
|
||||
if ( ( unit() == unit_t::Percent ) && ( value() > 100 || value() < 0 ) )
|
||||
if ( ( unit() == SizeUnit::Percent ) && ( value() > 100 || value() < 0 ) )
|
||||
{
|
||||
cDebug() << "Percent value" << value() << "is not valid.";
|
||||
m_value = 0;
|
||||
}
|
||||
|
||||
if ( m_unit == unit_t::None )
|
||||
if ( m_unit == SizeUnit::None )
|
||||
{
|
||||
m_value = s.toInt();
|
||||
if ( m_value > 0 )
|
||||
m_unit = unit_t::Byte;
|
||||
m_unit = SizeUnit::Byte;
|
||||
}
|
||||
|
||||
if ( m_value <= 0 )
|
||||
{
|
||||
m_value = 0;
|
||||
m_unit = unit_t::None;
|
||||
m_unit = SizeUnit::None;
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,17 +73,17 @@ PartitionSize::toSectors( qint64 totalSectors, qint64 sectorSize ) const
|
||||
|
||||
switch ( m_unit )
|
||||
{
|
||||
case unit_t::None:
|
||||
case SizeUnit::None:
|
||||
return -1;
|
||||
case unit_t::Percent:
|
||||
case SizeUnit::Percent:
|
||||
if ( value() == 100 )
|
||||
return totalSectors; // Common-case, avoid futzing around
|
||||
else
|
||||
return totalSectors * value() / 100;
|
||||
case unit_t::Byte:
|
||||
case unit_t::KiB:
|
||||
case unit_t::MiB:
|
||||
case unit_t::GiB:
|
||||
case SizeUnit::Byte:
|
||||
case SizeUnit::KiB:
|
||||
case SizeUnit::MiB:
|
||||
case SizeUnit::GiB:
|
||||
return CalamaresUtils::bytesToSectors ( toBytes(), sectorSize );
|
||||
}
|
||||
|
||||
@ -97,19 +98,19 @@ PartitionSize::toBytes( qint64 totalSectors, qint64 sectorSize ) const
|
||||
|
||||
switch ( m_unit )
|
||||
{
|
||||
case unit_t::None:
|
||||
case SizeUnit::None:
|
||||
return -1;
|
||||
case unit_t::Percent:
|
||||
case SizeUnit::Percent:
|
||||
if ( totalSectors < 1 || sectorSize < 1 )
|
||||
return -1;
|
||||
if ( value() == 100 )
|
||||
return totalSectors * sectorSize; // Common-case, avoid futzing around
|
||||
else
|
||||
return totalSectors * value() / 100;
|
||||
case unit_t::Byte:
|
||||
case unit_t::KiB:
|
||||
case unit_t::MiB:
|
||||
case unit_t::GiB:
|
||||
case SizeUnit::Byte:
|
||||
case SizeUnit::KiB:
|
||||
case SizeUnit::MiB:
|
||||
case SizeUnit::GiB:
|
||||
return toBytes();
|
||||
}
|
||||
|
||||
@ -125,19 +126,19 @@ PartitionSize::toBytes( qint64 totalBytes ) const
|
||||
|
||||
switch ( m_unit )
|
||||
{
|
||||
case unit_t::None:
|
||||
case SizeUnit::None:
|
||||
return -1;
|
||||
case unit_t::Percent:
|
||||
case SizeUnit::Percent:
|
||||
if ( totalBytes < 1 )
|
||||
return -1;
|
||||
if ( value() == 100 )
|
||||
return totalBytes; // Common-case, avoid futzing around
|
||||
else
|
||||
return totalBytes * value() / 100;
|
||||
case unit_t::Byte:
|
||||
case unit_t::KiB:
|
||||
case unit_t::MiB:
|
||||
case unit_t::GiB:
|
||||
case SizeUnit::Byte:
|
||||
case SizeUnit::KiB:
|
||||
case SizeUnit::MiB:
|
||||
case SizeUnit::GiB:
|
||||
return toBytes();
|
||||
}
|
||||
|
||||
@ -153,86 +154,82 @@ PartitionSize::toBytes() const
|
||||
|
||||
switch ( m_unit )
|
||||
{
|
||||
case unit_t::Byte:
|
||||
case SizeUnit::None:
|
||||
case SizeUnit::Percent:
|
||||
return -1;
|
||||
case SizeUnit::Byte:
|
||||
return value();
|
||||
case unit_t::KiB:
|
||||
case SizeUnit::KiB:
|
||||
return CalamaresUtils::KiBtoBytes( static_cast<unsigned long long>( value() ) );
|
||||
case unit_t::MiB:
|
||||
case SizeUnit::MiB:
|
||||
return CalamaresUtils::MiBtoBytes( static_cast<unsigned long long>( value() ) );
|
||||
case unit_t::GiB:
|
||||
case SizeUnit::GiB:
|
||||
return CalamaresUtils::GiBtoBytes( static_cast<unsigned long long>( value() ) );
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Reached only when unit is Percent or None
|
||||
return -1;
|
||||
NOTREACHED return -1;
|
||||
}
|
||||
|
||||
bool
|
||||
PartitionSize::operator< ( const PartitionSize& other ) const
|
||||
{
|
||||
if ( ( m_unit == unit_t::None || other.m_unit == unit_t::None ) ||
|
||||
( m_unit == unit_t::Percent && other.m_unit != unit_t::Percent ) ||
|
||||
( m_unit != unit_t::Percent && other.m_unit == unit_t::Percent ) )
|
||||
if ( !unitsComparable( m_unit, other.m_unit ) )
|
||||
return false;
|
||||
|
||||
switch ( m_unit )
|
||||
{
|
||||
case unit_t::Percent:
|
||||
case SizeUnit::None:
|
||||
return false;
|
||||
case SizeUnit::Percent:
|
||||
return ( m_value < other.m_value );
|
||||
case unit_t::Byte:
|
||||
case unit_t::KiB:
|
||||
case unit_t::MiB:
|
||||
case unit_t::GiB:
|
||||
case SizeUnit::Byte:
|
||||
case SizeUnit::KiB:
|
||||
case SizeUnit::MiB:
|
||||
case SizeUnit::GiB:
|
||||
return ( toBytes() < other.toBytes () );
|
||||
}
|
||||
|
||||
return false;
|
||||
NOTREACHED return false;
|
||||
}
|
||||
|
||||
bool
|
||||
PartitionSize::operator> ( const PartitionSize& other ) const
|
||||
{
|
||||
if ( ( m_unit == unit_t::None || other.m_unit == unit_t::None ) ||
|
||||
( m_unit == unit_t::Percent && other.m_unit != unit_t::Percent ) ||
|
||||
( m_unit != unit_t::Percent && other.m_unit == unit_t::Percent ) )
|
||||
if ( !unitsComparable( m_unit, other.m_unit ) )
|
||||
return false;
|
||||
|
||||
switch ( m_unit )
|
||||
{
|
||||
case unit_t::Percent:
|
||||
case SizeUnit::None:
|
||||
return false;
|
||||
case SizeUnit::Percent:
|
||||
return ( m_value > other.m_value );
|
||||
case unit_t::Byte:
|
||||
case unit_t::KiB:
|
||||
case unit_t::MiB:
|
||||
case unit_t::GiB:
|
||||
case SizeUnit::Byte:
|
||||
case SizeUnit::KiB:
|
||||
case SizeUnit::MiB:
|
||||
case SizeUnit::GiB:
|
||||
return ( toBytes() > other.toBytes () );
|
||||
}
|
||||
|
||||
return false;
|
||||
NOTREACHED return false;
|
||||
}
|
||||
|
||||
bool
|
||||
PartitionSize::operator== ( const PartitionSize& other ) const
|
||||
{
|
||||
if ( ( m_unit == unit_t::None || other.m_unit == unit_t::None ) ||
|
||||
( m_unit == unit_t::Percent && other.m_unit != unit_t::Percent ) ||
|
||||
( m_unit != unit_t::Percent && other.m_unit == unit_t::Percent ) )
|
||||
if ( !unitsComparable( m_unit, other.m_unit ) )
|
||||
return false;
|
||||
|
||||
switch ( m_unit )
|
||||
{
|
||||
case unit_t::Percent:
|
||||
case SizeUnit::None:
|
||||
return false;
|
||||
case SizeUnit::Percent:
|
||||
return ( m_value == other.m_value );
|
||||
case unit_t::Byte:
|
||||
case unit_t::KiB:
|
||||
case unit_t::MiB:
|
||||
case unit_t::GiB:
|
||||
case SizeUnit::Byte:
|
||||
case SizeUnit::KiB:
|
||||
case SizeUnit::MiB:
|
||||
case SizeUnit::GiB:
|
||||
return ( toBytes() == other.toBytes () );
|
||||
}
|
||||
|
||||
return false;
|
||||
NOTREACHED return false;
|
||||
}
|
||||
|
||||
} // namespace Calamares
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
|
||||
* Copyright 2019, Adriaan de Groot <groot@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
|
||||
@ -48,7 +49,7 @@ class PartitionSize : public NamedSuffix<SizeUnit, SizeUnit::None>
|
||||
{
|
||||
public:
|
||||
PartitionSize() : NamedSuffix() { }
|
||||
PartitionSize( int v, unit_t u ) : NamedSuffix( v, u ) { }
|
||||
PartitionSize( int v, SizeUnit u ) : NamedSuffix( v, u ) { }
|
||||
PartitionSize( const QString& );
|
||||
|
||||
bool isValid() const
|
||||
@ -91,11 +92,26 @@ public:
|
||||
/** @brief Convert the size to bytes.
|
||||
*
|
||||
* This method is only valid for sizes in Bytes, KiB, MiB or GiB.
|
||||
* It will return -1 in any other case.
|
||||
* It will return -1 in any other case. Note that 0KiB and 0MiB and
|
||||
* 0GiB are considered **invalid** sizes and return -1.
|
||||
*
|
||||
* @return the size in bytes, or -1 if it cannot be calculated.
|
||||
*/
|
||||
qint64 toBytes() const;
|
||||
|
||||
/** @brief Are the units comparable?
|
||||
*
|
||||
* None units cannot be compared with anything. Percentages can
|
||||
* be compared with each other, and all the explicit sizes (KiB, ...)
|
||||
* can be compared with each other.
|
||||
*/
|
||||
static constexpr bool unitsComparable( const SizeUnit u1, const SizeUnit u2 )
|
||||
{
|
||||
return !( ( u1 == SizeUnit::None || u2 == SizeUnit::None ) ||
|
||||
( u1 == SizeUnit::Percent && u2 != SizeUnit::Percent ) ||
|
||||
( u1 != SizeUnit::Percent && u2 == SizeUnit::Percent ) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace Calamares
|
||||
|
145
src/libcalamares/partition/Tests.cpp
Normal file
145
src/libcalamares/partition/Tests.cpp
Normal file
@ -0,0 +1,145 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2019, Adriaan de Groot <groot@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/>.
|
||||
*/
|
||||
|
||||
#include "Tests.h"
|
||||
|
||||
#include "PartitionSize.h"
|
||||
|
||||
Q_DECLARE_METATYPE( Calamares::SizeUnit )
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
QTEST_GUILESS_MAIN( PartitionSizeTests )
|
||||
|
||||
PartitionSizeTests::PartitionSizeTests()
|
||||
{
|
||||
}
|
||||
|
||||
PartitionSizeTests::~PartitionSizeTests()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
PartitionSizeTests::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
PartitionSizeTests::testUnitComparison_data()
|
||||
{
|
||||
QTest::addColumn<Calamares::SizeUnit>("u1");
|
||||
QTest::addColumn<Calamares::SizeUnit>("u2");
|
||||
QTest::addColumn<bool>("comparable");
|
||||
|
||||
using Calamares::SizeUnit;
|
||||
|
||||
QTest::newRow("nones") << SizeUnit::None << SizeUnit::None << false;
|
||||
QTest::newRow("none+%") << SizeUnit::None << SizeUnit::Percent<< false;
|
||||
QTest::newRow("%+none") << SizeUnit::Percent << SizeUnit::None << false;
|
||||
QTest::newRow("KiB+none") << SizeUnit::KiB << SizeUnit::None << false;
|
||||
QTest::newRow("none+MiB") << SizeUnit::None << SizeUnit::MiB << false;
|
||||
|
||||
QTest::newRow("KiB+KiB") << SizeUnit::KiB << SizeUnit::KiB << true;
|
||||
QTest::newRow("KiB+MiB") << SizeUnit::KiB << SizeUnit::MiB << true;
|
||||
QTest::newRow("KiB+GiB") << SizeUnit::KiB << SizeUnit::GiB << true;
|
||||
QTest::newRow("MiB+MiB") << SizeUnit::MiB << SizeUnit::MiB << true;
|
||||
QTest::newRow("MiB+GiB") << SizeUnit::MiB << SizeUnit::GiB << true;
|
||||
QTest::newRow("GiB+GiB") << SizeUnit::GiB << SizeUnit::GiB << true;
|
||||
|
||||
QTest::newRow("%+None") << SizeUnit::Percent << SizeUnit::None << false;
|
||||
QTest::newRow("%+%") << SizeUnit::Percent << SizeUnit::Percent << true;
|
||||
QTest::newRow("%+KiB") << SizeUnit::Percent << SizeUnit::KiB << false;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
original_compare( Calamares::SizeUnit m_unit, Calamares::SizeUnit other_m_unit )
|
||||
{
|
||||
if ( ( m_unit == Calamares::SizeUnit::None || other_m_unit == Calamares::SizeUnit::None ) ||
|
||||
( m_unit == Calamares::SizeUnit::Percent && other_m_unit != Calamares::SizeUnit::Percent ) ||
|
||||
( m_unit != Calamares::SizeUnit::Percent && other_m_unit == Calamares::SizeUnit::Percent ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
PartitionSizeTests::testUnitComparison()
|
||||
{
|
||||
QFETCH( Calamares::SizeUnit, u1 );
|
||||
QFETCH( Calamares::SizeUnit, u2 );
|
||||
QFETCH( bool, comparable );
|
||||
|
||||
if ( comparable )
|
||||
{
|
||||
QVERIFY( Calamares::PartitionSize::unitsComparable( u1, u2 ) );
|
||||
QVERIFY( Calamares::PartitionSize::unitsComparable( u2, u1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
QVERIFY( !Calamares::PartitionSize::unitsComparable( u1, u2 ) );
|
||||
QVERIFY( !Calamares::PartitionSize::unitsComparable( u2, u1 ) );
|
||||
}
|
||||
|
||||
QCOMPARE( original_compare( u1, u2 ), Calamares::PartitionSize::unitsComparable( u1, u2 ) );
|
||||
}
|
||||
|
||||
void
|
||||
PartitionSizeTests::testUnitNormalisation_data()
|
||||
{
|
||||
QTest::addColumn<Calamares::SizeUnit>("u1");
|
||||
QTest::addColumn<int>("v");
|
||||
QTest::addColumn<long>("bytes");
|
||||
|
||||
using Calamares::SizeUnit;
|
||||
|
||||
QTest::newRow("none") << SizeUnit::None << 16 << -1L;
|
||||
QTest::newRow("none") << SizeUnit::None << 0 << -1L;
|
||||
QTest::newRow("none") << SizeUnit::None << -2 << -1L;
|
||||
|
||||
QTest::newRow("percent") << SizeUnit::Percent << 0 << -1L;
|
||||
QTest::newRow("percent") << SizeUnit::Percent << 16 << -1L;
|
||||
QTest::newRow("percent") << SizeUnit::Percent << -2 << -1L;
|
||||
|
||||
QTest::newRow("KiB") << SizeUnit::KiB << 0 << -1L;
|
||||
QTest::newRow("KiB") << SizeUnit::KiB << 1 << 1024L;
|
||||
QTest::newRow("KiB") << SizeUnit::KiB << 1000 << 1024000L;
|
||||
QTest::newRow("KiB") << SizeUnit::KiB << 1024 << 1024 * 1024L;
|
||||
QTest::newRow("KiB") << SizeUnit::KiB << -2 << -1L;
|
||||
|
||||
QTest::newRow("MiB") << SizeUnit::MiB << 0 << -1L;
|
||||
QTest::newRow("MiB") << SizeUnit::MiB << 1 << 1024 * 1024L;
|
||||
QTest::newRow("MiB") << SizeUnit::MiB << 1000 << 1024 * 1024000L;
|
||||
QTest::newRow("MiB") << SizeUnit::MiB << 1024 << 1024 * 1024 * 1024L;
|
||||
QTest::newRow("MiB") << SizeUnit::MiB << -2 << -1L;
|
||||
|
||||
QTest::newRow("GiB") << SizeUnit::GiB << 0 << -1L;
|
||||
QTest::newRow("GiB") << SizeUnit::GiB << 1 << 1024 * 1024 * 1024L;
|
||||
QTest::newRow("GiB") << SizeUnit::GiB << 2 << 2048 * 1024 * 1024L;
|
||||
}
|
||||
|
||||
void
|
||||
PartitionSizeTests::testUnitNormalisation()
|
||||
{
|
||||
QFETCH( Calamares::SizeUnit, u1 );
|
||||
QFETCH( int, v );
|
||||
QFETCH( long, bytes );
|
||||
|
||||
QCOMPARE( Calamares::PartitionSize( v, u1 ).toBytes(), static_cast<qint64>( bytes ) );
|
||||
}
|
41
src/libcalamares/partition/Tests.h
Normal file
41
src/libcalamares/partition/Tests.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2019, Adriaan de Groot <groot@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 LIBCALAMARES_PARTITION_TESTS_H
|
||||
#define LIBCALAMARES_PARTITION_TESTS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class PartitionSizeTests : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PartitionSizeTests();
|
||||
~PartitionSizeTests() override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
|
||||
void testUnitComparison_data();
|
||||
void testUnitComparison();
|
||||
|
||||
void testUnitNormalisation_data();
|
||||
void testUnitNormalisation();
|
||||
};
|
||||
|
||||
#endif
|
@ -54,6 +54,21 @@ public:
|
||||
m_size.isValid();
|
||||
}
|
||||
|
||||
QString name() const
|
||||
{
|
||||
return m_fsname.isEmpty() ? m_devicename : m_fsname;
|
||||
}
|
||||
|
||||
Calamares::PartitionSize size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
Calamares::PartitionSize minimumSize() const
|
||||
{
|
||||
return m_atleast;
|
||||
}
|
||||
|
||||
private:
|
||||
Calamares::PartitionSize m_size;
|
||||
Calamares::PartitionSize m_atleast;
|
||||
|
@ -30,9 +30,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QStringList>
|
||||
|
||||
#define private public
|
||||
#include "ResizeFSJob.h"
|
||||
#undef private
|
||||
|
||||
QTEST_GUILESS_MAIN( FSResizerTests )
|
||||
|
||||
@ -55,10 +53,9 @@ void FSResizerTests::testConfigurationRobust()
|
||||
|
||||
// Empty config
|
||||
j.setConfigurationMap( QVariantMap() );
|
||||
QVERIFY( j.m_fsname.isEmpty() );
|
||||
QVERIFY( j.m_devicename.isEmpty() );
|
||||
QCOMPARE( j.m_size.unit(), Calamares::SizeUnit::None );
|
||||
QCOMPARE( j.m_atleast.unit(), Calamares::SizeUnit::None );
|
||||
QVERIFY( j.name().isEmpty() );
|
||||
QCOMPARE( j.size().unit(), Calamares::SizeUnit::None );
|
||||
QCOMPARE( j.minimumSize().unit(), Calamares::SizeUnit::None );
|
||||
|
||||
// Config is missing fs and dev, so it isn't valid
|
||||
YAML::Node doc0 = YAML::Load( R"(---
|
||||
@ -66,12 +63,11 @@ size: 100%
|
||||
atleast: 600MiB
|
||||
)" );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
|
||||
QVERIFY( j.m_fsname.isEmpty() );
|
||||
QVERIFY( j.m_devicename.isEmpty() );
|
||||
QCOMPARE( j.m_size.unit(), Calamares::SizeUnit::None );
|
||||
QCOMPARE( j.m_atleast.unit(), Calamares::SizeUnit::None );
|
||||
QCOMPARE( j.m_size.value(), 0 );
|
||||
QCOMPARE( j.m_atleast.value(), 0 );
|
||||
QVERIFY( j.name().isEmpty() );
|
||||
QCOMPARE( j.size().unit(), Calamares::SizeUnit::None );
|
||||
QCOMPARE( j.minimumSize().unit(), Calamares::SizeUnit::None );
|
||||
QCOMPARE( j.size().value(), 0 );
|
||||
QCOMPARE( j.minimumSize().value(), 0 );
|
||||
}
|
||||
|
||||
void FSResizerTests::testConfigurationValues()
|
||||
@ -85,12 +81,11 @@ size: 100%
|
||||
atleast: 600MiB
|
||||
)" );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
|
||||
QVERIFY( !j.m_fsname.isEmpty() );
|
||||
QVERIFY( j.m_devicename.isEmpty() );
|
||||
QCOMPARE( j.m_size.unit(), Calamares::SizeUnit::Percent );
|
||||
QCOMPARE( j.m_atleast.unit(), Calamares::SizeUnit::MiB );
|
||||
QCOMPARE( j.m_size.value(), 100 );
|
||||
QCOMPARE( j.m_atleast.value(), 600 );
|
||||
QVERIFY( j.name().isEmpty() );
|
||||
QCOMPARE( j.size().unit(), Calamares::SizeUnit::Percent );
|
||||
QCOMPARE( j.minimumSize().unit(), Calamares::SizeUnit::MiB );
|
||||
QCOMPARE( j.size().value(), 100 );
|
||||
QCOMPARE( j.minimumSize().value(), 600 );
|
||||
|
||||
// Silly config
|
||||
doc0 = YAML::Load( R"(---
|
||||
@ -100,12 +95,11 @@ size: 72 MiB
|
||||
atleast: 127 %
|
||||
)" );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
|
||||
QVERIFY( !j.m_fsname.isEmpty() );
|
||||
QVERIFY( !j.m_devicename.isEmpty() );
|
||||
QCOMPARE( j.m_size.unit(), Calamares::SizeUnit::MiB );
|
||||
QCOMPARE( j.m_atleast.unit(), Calamares::SizeUnit::None );
|
||||
QCOMPARE( j.m_size.value(), 72 );
|
||||
QCOMPARE( j.m_atleast.value(), 0 );
|
||||
QVERIFY( !j.name().isEmpty() );
|
||||
QCOMPARE( j.size().unit(), Calamares::SizeUnit::MiB );
|
||||
QCOMPARE( j.minimumSize().unit(), Calamares::SizeUnit::None );
|
||||
QCOMPARE( j.size().value(), 72 );
|
||||
QCOMPARE( j.minimumSize().value(), 0 );
|
||||
|
||||
// Silly config
|
||||
doc0 = YAML::Load( R"(---
|
||||
@ -115,10 +109,9 @@ size: 71MiB
|
||||
# atleast: 127%
|
||||
)" );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
|
||||
QVERIFY( !j.m_fsname.isEmpty() );
|
||||
QVERIFY( j.m_devicename.isEmpty() );
|
||||
QCOMPARE( j.m_size.unit(), Calamares::SizeUnit::MiB );
|
||||
QCOMPARE( j.m_atleast.unit(), Calamares::SizeUnit::None );
|
||||
QCOMPARE( j.m_size.value(), 71 );
|
||||
QCOMPARE( j.m_atleast.value(), 0 );
|
||||
QVERIFY( j.name().isEmpty() );
|
||||
QCOMPARE( j.size().unit(), Calamares::SizeUnit::MiB );
|
||||
QCOMPARE( j.minimumSize().unit(), Calamares::SizeUnit::None );
|
||||
QCOMPARE( j.size().value(), 71 );
|
||||
QCOMPARE( j.minimumSize().value(), 0 );
|
||||
}
|
||||
|
@ -43,9 +43,15 @@ public:
|
||||
)
|
||||
}
|
||||
|
||||
virtual ~OEMPage() override;
|
||||
|
||||
Ui_OEMPage* m_ui;
|
||||
} ;
|
||||
|
||||
OEMPage::~OEMPage()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
OEMViewStep::OEMViewStep(QObject* parent)
|
||||
: Calamares::ViewStep( parent )
|
||||
|
@ -150,7 +150,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
|
||||
const PartitionRole& role )
|
||||
{
|
||||
QList< Partition* > partList;
|
||||
qint64 size, minSize, maxSize, end;
|
||||
qint64 minSize, maxSize, end;
|
||||
qint64 totalSize = lastSector - firstSector + 1;
|
||||
qint64 availableSize = totalSize;
|
||||
|
||||
@ -161,6 +161,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
|
||||
{
|
||||
Partition *currentPartition = nullptr;
|
||||
|
||||
qint64 size = -1;
|
||||
// Calculate partition size
|
||||
if ( part.partSize.isValid() )
|
||||
{
|
||||
|
@ -564,7 +564,7 @@ PartitionPage::updateFromCurrentDevice()
|
||||
|
||||
QAbstractItemModel* oldModel = m_ui->partitionTreeView->model();
|
||||
if ( oldModel )
|
||||
disconnect( oldModel, 0, this, 0 );
|
||||
disconnect( oldModel, nullptr, this, nullptr );
|
||||
|
||||
PartitionModel* model = m_core->partitionModelForDevice( device );
|
||||
m_ui->partitionBarsView->setModel( model );
|
||||
|
@ -44,7 +44,7 @@ ResizeVolumeGroupDialog::ResizeVolumeGroupDialog( LvmDevice *device,
|
||||
for ( const Partition* p : availablePVs )
|
||||
pvList()->addItem( new ListPhysicalVolumeWidgetItem( p, false ) );
|
||||
|
||||
peSize()->setValue( device->peSize() / Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB) );
|
||||
peSize()->setValue( static_cast<int>( device->peSize() / Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB) ) );
|
||||
|
||||
vgName()->setEnabled( false );
|
||||
peSize()->setEnabled( false );
|
||||
|
@ -137,9 +137,9 @@ VolumeGroupBaseDialog::updateTotalSize()
|
||||
void
|
||||
VolumeGroupBaseDialog::updateTotalSectors()
|
||||
{
|
||||
qint32 totalSectors = 0;
|
||||
qint64 totalSectors = 0;
|
||||
|
||||
qint32 extentSize = ui->peSize->value() * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
qint64 extentSize = ui->peSize->value() * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||
|
||||
if ( extentSize > 0 )
|
||||
totalSectors = m_totalSizeValue / extentSize;
|
||||
|
@ -68,7 +68,7 @@ CreatePartitionTableJob::prettyStatusMessage() const
|
||||
|
||||
|
||||
static inline QDebug&
|
||||
operator <<( QDebug& s, PartitionIterator& it )
|
||||
operator <<( QDebug&& s, PartitionIterator& it )
|
||||
{
|
||||
s << ( ( *it ) ? ( *it )->deviceNode() : QString( "<null device>" ) );
|
||||
return s;
|
||||
@ -89,7 +89,7 @@ CreatePartitionTableJob::exec()
|
||||
{
|
||||
for ( auto it = PartitionIterator::begin( table );
|
||||
it != PartitionIterator::end( table ); ++it )
|
||||
cDebug() << *it;
|
||||
cDebug() << it;
|
||||
|
||||
QProcess lsblk;
|
||||
lsblk.setProgram( "lsblk" );
|
||||
|
@ -77,7 +77,7 @@ static QByteArray
|
||||
generateTestData( qint64 size )
|
||||
{
|
||||
QByteArray ba;
|
||||
ba.resize( size );
|
||||
ba.resize( static_cast<int>( size ) );
|
||||
// Fill the array explicitly to keep Valgrind happy
|
||||
for ( auto it = ba.data() ; it < ba.data() + size ; ++it )
|
||||
{
|
||||
@ -130,6 +130,11 @@ QueueRunner::QueueRunner( JobQueue* queue )
|
||||
connect( m_queue, &JobQueue::failed, this, &QueueRunner::onFailed );
|
||||
}
|
||||
|
||||
QueueRunner::~QueueRunner()
|
||||
{
|
||||
// Nothing to do. We don't own the queue, and disconnect happens automatically
|
||||
}
|
||||
|
||||
bool
|
||||
QueueRunner::run()
|
||||
{
|
||||
@ -167,7 +172,8 @@ PartitionJobTests::initTestCase()
|
||||
QString devicePath = qgetenv( "CALAMARES_TEST_DISK" );
|
||||
if ( devicePath.isEmpty() )
|
||||
{
|
||||
QSKIP( "Skipping test, CALAMARES_TEST_DISK is not set. It should point to a disk which can be safely formatted" );
|
||||
// The 0 is to keep the macro parameters happy
|
||||
QSKIP( "Skipping test, CALAMARES_TEST_DISK is not set. It should point to a disk which can be safely formatted", 0 );
|
||||
}
|
||||
|
||||
QVERIFY( KPMHelpers::initKPMcore() );
|
||||
@ -322,10 +328,10 @@ PartitionJobTests::testCreatePartitionExtended()
|
||||
void
|
||||
PartitionJobTests::testResizePartition_data()
|
||||
{
|
||||
QTest::addColumn< int >( "oldStartMiB" );
|
||||
QTest::addColumn< int >( "oldSizeMiB" );
|
||||
QTest::addColumn< int >( "newStartMiB" );
|
||||
QTest::addColumn< int >( "newSizeMiB" );
|
||||
QTest::addColumn< unsigned int >( "oldStartMiB" );
|
||||
QTest::addColumn< unsigned int >( "oldSizeMiB" );
|
||||
QTest::addColumn< unsigned int >( "newStartMiB" );
|
||||
QTest::addColumn< unsigned int >( "newSizeMiB" );
|
||||
|
||||
QTest::newRow("grow") << 10 << 50 << 10 << 70;
|
||||
QTest::newRow("shrink") << 10 << 70 << 10 << 50;
|
||||
@ -336,10 +342,10 @@ PartitionJobTests::testResizePartition_data()
|
||||
void
|
||||
PartitionJobTests::testResizePartition()
|
||||
{
|
||||
QFETCH( int, oldStartMiB );
|
||||
QFETCH( int, oldSizeMiB );
|
||||
QFETCH( int, newStartMiB );
|
||||
QFETCH( int, newSizeMiB );
|
||||
QFETCH( unsigned int, oldStartMiB );
|
||||
QFETCH( unsigned int, oldSizeMiB );
|
||||
QFETCH( unsigned int, newStartMiB );
|
||||
QFETCH( unsigned int, newSizeMiB );
|
||||
|
||||
const qint64 sectorsPerMiB = 1_MiB / m_device->logicalSize();
|
||||
|
||||
|
@ -36,6 +36,7 @@ class QueueRunner : public QObject
|
||||
{
|
||||
public:
|
||||
QueueRunner( Calamares::JobQueue* queue );
|
||||
virtual ~QueueRunner() override;
|
||||
|
||||
/**
|
||||
* Synchronously runs the queue. Returns true on success
|
||||
|
Loading…
Reference in New Issue
Block a user