Fix a failing test.

This commit is contained in:
Andrius Štikonas 2019-11-07 22:28:01 +00:00
parent 1c771436d4
commit 660aa6a55e
2 changed files with 22 additions and 28 deletions

View File

@ -36,19 +36,21 @@ int main(int argc, char **argv)
if (argc == 2) if (argc == 2)
init = KPMCoreInitializer(argv[1]); init = KPMCoreInitializer(argv[1]);
return init.isValid() ? true : false; return init.isValid() ? EXIT_SUCCESS : EXIT_FAILURE;
CoreBackend *backend = CoreBackendManager::self()->backend(); CoreBackend *backend = CoreBackendManager::self()->backend();
if (!backend) { if (!backend) {
qWarning() << "Failed to load backend plugin"; qWarning() << "Failed to load backend plugin";
return false; return EXIT_FAILURE;
} }
TestDevice device; TestDevice device;
if (!device.testDeviceName() || !device.testDeviceNode() || !device.testDeviceSize() || !device.testDeviceTotalSectors()) device.testDeviceName();
return false; device.testDeviceNode();
device.testDeviceSize();
device.testDeviceTotalSectors();
return app.exec(); return app.exec();
} }
@ -73,58 +75,50 @@ TestDevice::~TestDevice()
devices.clear(); devices.clear();
} }
bool TestDevice::testDeviceName() void TestDevice::testDeviceName()
{ {
if (devices.isEmpty()) { if (devices.isEmpty()) {
return false; exit(EXIT_FAILURE);
} else { } else {
for (const auto &device : devices) { for (const auto &device : devices) {
if (device->name() == QString()) if (device->name() == QString())
return false; exit(EXIT_FAILURE);
} }
} }
return true;
} }
bool TestDevice::testDeviceNode() void TestDevice::testDeviceNode()
{ {
if (devices.isEmpty()) { if (devices.isEmpty()) {
return false; exit(EXIT_FAILURE);
} else { } else {
for (const auto &device : devices) { for (const auto &device : devices) {
if (device->deviceNode() == QString()) if (device->deviceNode() == QString())
return false; exit(EXIT_FAILURE);
} }
} }
return true;
} }
bool TestDevice::testDeviceSize() void TestDevice::testDeviceSize()
{ {
if (devices.isEmpty()) { if (devices.isEmpty()) {
return false; exit(EXIT_FAILURE);
} else { } else {
for (const auto &device : devices) { for (const auto &device : devices) {
if (device->logicalSize() < 0) if (device->logicalSize() < 0)
return false; exit(EXIT_FAILURE);
} }
} }
return true;
} }
bool TestDevice::testDeviceTotalSectors() void TestDevice::testDeviceTotalSectors()
{ {
if (devices.isEmpty()) { if (devices.isEmpty()) {
return false; exit(EXIT_FAILURE);
} else { } else {
for (const auto &device : devices) { for (const auto &device : devices) {
if (device->totalLogical() < 0) if (device->totalLogical() < 0)
return false; exit(EXIT_FAILURE);
} }
} }
return true;
} }

View File

@ -32,10 +32,10 @@ public:
TestDevice(); TestDevice();
~TestDevice(); ~TestDevice();
bool testDeviceName(); void testDeviceName();
bool testDeviceNode(); void testDeviceNode();
bool testDeviceSize(); void testDeviceSize();
bool testDeviceTotalSectors(); void testDeviceTotalSectors();
private: private:
OperationStack *operationStack; OperationStack *operationStack;