Merge branch '4.0'
This commit is contained in:
commit
1c771436d4
|
@ -178,7 +178,7 @@ static struct {
|
||||||
{ FileSystem::Type::LinuxSwap, { QLatin1String("0657FD6D-A4AB-43C4-84E5-0933C84B4F4F"), QLatin1String("82") } },
|
{ FileSystem::Type::LinuxSwap, { QLatin1String("0657FD6D-A4AB-43C4-84E5-0933C84B4F4F"), QLatin1String("82") } },
|
||||||
{ FileSystem::Type::Fat12, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("6") } },
|
{ FileSystem::Type::Fat12, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("6") } },
|
||||||
{ FileSystem::Type::Fat16, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("6") } },
|
{ FileSystem::Type::Fat16, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("6") } },
|
||||||
{ FileSystem::Type::Fat32, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } },
|
{ FileSystem::Type::Fat32, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("c") } },
|
||||||
{ FileSystem::Type::Nilfs2, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } },
|
{ FileSystem::Type::Nilfs2, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } },
|
||||||
{ FileSystem::Type::Ntfs, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } },
|
{ FileSystem::Type::Ntfs, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } },
|
||||||
{ FileSystem::Type::Exfat, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } },
|
{ FileSystem::Type::Exfat, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } },
|
||||||
|
|
|
@ -54,14 +54,6 @@ find_package (Threads)
|
||||||
kpm_test(testexternalcommand testexternalcommand.cpp)
|
kpm_test(testexternalcommand testexternalcommand.cpp)
|
||||||
add_test(NAME testexternalcommand COMMAND testexternalcommand ${BACKEND})
|
add_test(NAME testexternalcommand COMMAND testexternalcommand ${BACKEND})
|
||||||
|
|
||||||
# Including SMART files reference
|
|
||||||
set(SMARTPARSER ${CMAKE_SOURCE_DIR}/src/core/smartdiskinformation.cpp
|
|
||||||
${CMAKE_SOURCE_DIR}/src/core/smartattributeparseddata.cpp
|
|
||||||
${CMAKE_SOURCE_DIR}/src/core/smartparser.cpp)
|
|
||||||
|
|
||||||
# Test SMART support
|
|
||||||
kpm_test(testsmart testsmart.cpp ${SMARTPARSER})
|
|
||||||
add_test(NAME testsmart COMMAND testsmart ${BACKEND})
|
|
||||||
|
|
||||||
# Test Device
|
# Test Device
|
||||||
kpm_test(testdevice testdevice.cpp)
|
kpm_test(testdevice testdevice.cpp)
|
||||||
|
|
|
@ -1,102 +0,0 @@
|
||||||
#include "helpers.h"
|
|
||||||
|
|
||||||
#include "util/externalcommand.h"
|
|
||||||
#include "backend/corebackend.h"
|
|
||||||
#include "backend/corebackendmanager.h"
|
|
||||||
#include "core/smartstatus.h"
|
|
||||||
#include "core/smartparser.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
static QString getDefaultDevicePath();
|
|
||||||
static bool testSmartStatus();
|
|
||||||
static bool testSmartParser();
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
QCoreApplication app(argc, argv);
|
|
||||||
|
|
||||||
KPMCoreInitializer i;
|
|
||||||
|
|
||||||
if (argc == 2)
|
|
||||||
i = KPMCoreInitializer(argv[1]);
|
|
||||||
|
|
||||||
if (!i.isValid())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
CoreBackend *backend = CoreBackendManager::self()->backend();
|
|
||||||
|
|
||||||
if (!backend)
|
|
||||||
{
|
|
||||||
qWarning() << "Couldn't get backend.";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!testSmartStatus() || !testSmartParser())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return app.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString getDefaultDevicePath()
|
|
||||||
{
|
|
||||||
// Getting default home partition using 'df -P /home | awk 'END{print $1}'' command
|
|
||||||
ExternalCommand command(QStringLiteral("df"), { QStringLiteral("-P"), QStringLiteral("/home"), QStringLiteral("|"),
|
|
||||||
QStringLiteral("awk"), QStringLiteral("\'END{print $1}\'") });
|
|
||||||
|
|
||||||
if (command.run() && command.exitCode() == 0) {
|
|
||||||
QString output = command.output();
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool testSmartStatus()
|
|
||||||
{
|
|
||||||
const QString devicePath = getDefaultDevicePath();
|
|
||||||
|
|
||||||
SmartStatus smart(devicePath);
|
|
||||||
|
|
||||||
if (smart.devicePath() != devicePath)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!smart.status())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (smart.modelName() == QString())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (smart.firmware() == QString())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (smart.serial() == QString())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (smart.selfTestStatus() != SmartStatus::SelfTestStatus::Success)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!smart.isValid())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool testSmartParser()
|
|
||||||
{
|
|
||||||
const QString devicePath = getDefaultDevicePath();
|
|
||||||
|
|
||||||
SmartParser parser(devicePath);
|
|
||||||
|
|
||||||
if (!parser.init())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (parser.devicePath() != devicePath)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!parser.diskInformation())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
Loading…
Reference in New Issue