diff --git a/autotests/klistopenfilesjobtest_unix.cpp b/autotests/klistopenfilesjobtest_unix.cpp --- a/autotests/klistopenfilesjobtest_unix.cpp +++ b/autotests/klistopenfilesjobtest_unix.cpp @@ -20,15 +20,28 @@ #include "klistopenfilesjobtest_unix.h" #include "klistopenfilesjob.h" #include +#include #include #include #include #include QTEST_MAIN(KListOpenFilesJobTest) +namespace { + +bool hasLsofInstalled() +{ + return !QStandardPaths::findExecutable(QStringLiteral("lsof")).isEmpty(); +} + +} + void KListOpenFilesJobTest::testOpenFiles() { + if (!hasLsofInstalled()) { + QSKIP("lsof is not installed - skipping test"); + } QDir path(QCoreApplication::applicationDirPath()); auto job = new KListOpenFilesJob(path.path()); job->exec(); @@ -48,6 +61,9 @@ void KListOpenFilesJobTest::testNoOpenFiles() { + if (!hasLsofInstalled()) { + QSKIP("lsof is not installed - skipping test"); + } QTemporaryDir tempDir; auto job = new KListOpenFilesJob(tempDir.path()); job->exec(); @@ -57,6 +73,9 @@ void KListOpenFilesJobTest::testNonExistingDir() { + if (!hasLsofInstalled()) { + QSKIP("lsof is not installed - skipping test"); + } QString nonExistingDir(QStringLiteral("/does/not/exist")); auto job = new KListOpenFilesJob(nonExistingDir); job->exec();