diff --git a/test/testdevice.cpp b/test/testdevice.cpp index 1bfb29f..43a424b 100644 --- a/test/testdevice.cpp +++ b/test/testdevice.cpp @@ -1,130 +1,124 @@ /************************************************************************* * Copyright (C) 2019 by Shubham * * * * This program 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. * * * * This program 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 this program. If not, see .* *************************************************************************/ // SPDX-License-Identifier: GPL-3.0+ #include "helpers.h" #include "testdevice.h" #include "backend/corebackend.h" #include "backend/corebackendmanager.h" #include #include #include int main(int argc, char **argv) { QCoreApplication app(argc, argv); KPMCoreInitializer init; if (argc == 2) init = KPMCoreInitializer(argv[1]); - return init.isValid() ? true : false; + return init.isValid() ? EXIT_SUCCESS : EXIT_FAILURE; CoreBackend *backend = CoreBackendManager::self()->backend(); if (!backend) { qWarning() << "Failed to load backend plugin"; - return false; + return EXIT_FAILURE; } TestDevice device; - if (!device.testDeviceName() || !device.testDeviceNode() || !device.testDeviceSize() || !device.testDeviceTotalSectors()) - return false; + device.testDeviceName(); + device.testDeviceNode(); + device.testDeviceSize(); + device.testDeviceTotalSectors(); return app.exec(); } TestDevice::TestDevice() { operationStack = new OperationStack(); deviceScanner = new DeviceScanner(nullptr, *operationStack); deviceScanner->scan(); // Get list of available devices on the system devices = operationStack->previewDevices(); } TestDevice::~TestDevice() { delete operationStack; delete deviceScanner; // Delete the list of devices qDeleteAll(devices.begin(), devices.end()); devices.clear(); } -bool TestDevice::testDeviceName() +void TestDevice::testDeviceName() { if (devices.isEmpty()) { - return false; + exit(EXIT_FAILURE); } else { for (const auto &device : devices) { if (device->name() == QString()) - return false; + exit(EXIT_FAILURE); } } - - return true; } -bool TestDevice::testDeviceNode() +void TestDevice::testDeviceNode() { if (devices.isEmpty()) { - return false; + exit(EXIT_FAILURE); } else { for (const auto &device : devices) { if (device->deviceNode() == QString()) - return false; + exit(EXIT_FAILURE); } } - - return true; } -bool TestDevice::testDeviceSize() +void TestDevice::testDeviceSize() { if (devices.isEmpty()) { - return false; + exit(EXIT_FAILURE); } else { for (const auto &device : devices) { if (device->logicalSize() < 0) - return false; + exit(EXIT_FAILURE); } } - - return true; } -bool TestDevice::testDeviceTotalSectors() +void TestDevice::testDeviceTotalSectors() { if (devices.isEmpty()) { - return false; + exit(EXIT_FAILURE); } else { for (const auto &device : devices) { if (device->totalLogical() < 0) - return false; + exit(EXIT_FAILURE); } } - - return true; } diff --git a/test/testdevice.h b/test/testdevice.h index 07b9d65..0256792 100644 --- a/test/testdevice.h +++ b/test/testdevice.h @@ -1,46 +1,46 @@ /************************************************************************* * Copyright (C) 2019 by Shubham * * * * This program 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. * * * * This program 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 this program. If not, see .* **************************************************************************/ // SPDX-License-Identifier: GPL-3.0+ #ifndef TESTDEVICE_H #define TESTDEVICE_H #include "core/device.h" #include "core/devicescanner.h" #include "core/operationstack.h" #include class TestDevice { public: TestDevice(); ~TestDevice(); - bool testDeviceName(); - bool testDeviceNode(); - bool testDeviceSize(); - bool testDeviceTotalSectors(); + void testDeviceName(); + void testDeviceNode(); + void testDeviceSize(); + void testDeviceTotalSectors(); private: OperationStack *operationStack; DeviceScanner *deviceScanner; QList devices; }; #endif // TESTDEVICE_H