fix hddtemp tests

This commit is contained in:
Evgenii Alekseev 2017-12-17 05:07:50 +03:00
parent 423eabd857
commit ce30d90a23

View File

@ -28,7 +28,6 @@ void TestHDDTemperatureSource::initTestCase()
{ {
AWTestLibrary::init(); AWTestLibrary::init();
devices = HDDTemperatureSource::allHdd(); devices = HDDTemperatureSource::allHdd();
QVERIFY(devices.count() > 0);
hddtempSource hddtempSource
= new HDDTemperatureSource(this, QStringList() << devices.join(',') << hddtempCmd); = new HDDTemperatureSource(this, QStringList() << devices.join(',') << hddtempCmd);
@ -46,6 +45,9 @@ void TestHDDTemperatureSource::cleanupTestCase()
void TestHDDTemperatureSource::test_sources() void TestHDDTemperatureSource::test_sources()
{ {
if (devices.isEmpty())
QSKIP("No hdd devices found, test will be skipped");
std::for_each(devices.begin(), devices.end(), std::for_each(devices.begin(), devices.end(),
[](QString &device) { device.prepend("hdd/temperature"); }); [](QString &device) { device.prepend("hdd/temperature"); });
@ -56,6 +58,9 @@ void TestHDDTemperatureSource::test_sources()
void TestHDDTemperatureSource::test_hddtemp() void TestHDDTemperatureSource::test_hddtemp()
{ {
if (devices.isEmpty())
QSKIP("No hdd devices found, test will be skipped");
std::for_each(devices.begin(), devices.end(), [this](QString device) { std::for_each(devices.begin(), devices.end(), [this](QString device) {
QSignalSpy spy(hddtempSource, SIGNAL(dataReceived(const QVariantHash &))); QSignalSpy spy(hddtempSource, SIGNAL(dataReceived(const QVariantHash &)));
float firstValue = hddtempSource->data(device).toFloat(); float firstValue = hddtempSource->data(device).toFloat();
@ -73,6 +78,9 @@ void TestHDDTemperatureSource::test_hddtemp()
void TestHDDTemperatureSource::test_smartctl() void TestHDDTemperatureSource::test_smartctl()
{ {
if (devices.isEmpty())
QSKIP("No hdd devices found, test will be skipped");
std::for_each(devices.begin(), devices.end(), [this](QString &device) { std::for_each(devices.begin(), devices.end(), [this](QString &device) {
QSignalSpy spy(smartctlSource, SIGNAL(dataReceived(const QVariantHash &))); QSignalSpy spy(smartctlSource, SIGNAL(dataReceived(const QVariantHash &)));
float firstValue = smartctlSource->data(device).toFloat(); float firstValue = smartctlSource->data(device).toFloat();