diff --git a/test/testfolderwatcher.cpp b/test/testfolderwatcher.cpp index 10d945b5de5d7..a769f07d41e7b 100644 --- a/test/testfolderwatcher.cpp +++ b/test/testfolderwatcher.cpp @@ -5,12 +5,20 @@ * */ +#include #include #include "folderwatcher.h" #include "common/utility.h" #include "logger.h" +#define CHECKED_SYSTEM(cmd_) \ + do { \ + int result_ = system(cmd_); \ + Q_ASSERT(WIFEXITED(result_)); \ + Q_ASSERT(WEXITSTATUS(result_) == 0); \ + } while(0) + void touch(const QString &file) { #ifdef Q_OS_WIN @@ -19,7 +27,7 @@ void touch(const QString &file) QString cmd; cmd = QString("touch %1").arg(file); qDebug() << "Command: " << cmd; - system(cmd.toLocal8Bit()); + CHECKED_SYSTEM(cmd.toLocal8Bit()); #endif } @@ -31,7 +39,7 @@ void mkdir(const QString &file) #else QString cmd = QString("mkdir %1").arg(file); qDebug() << "Command: " << cmd; - system(cmd.toLocal8Bit()); + CHECKED_SYSTEM(cmd.toLocal8Bit()); #endif } @@ -43,7 +51,7 @@ void rmdir(const QString &file) #else QString cmd = QString("rmdir %1").arg(file); qDebug() << "Command: " << cmd; - system(cmd.toLocal8Bit()); + CHECKED_SYSTEM(cmd.toLocal8Bit()); #endif } @@ -54,7 +62,7 @@ void rm(const QString &file) #else QString cmd = QString("rm %1").arg(file); qDebug() << "Command: " << cmd; - system(cmd.toLocal8Bit()); + CHECKED_SYSTEM(cmd.toLocal8Bit()); #endif } @@ -65,7 +73,7 @@ void mv(const QString &file1, const QString &file2) #else QString cmd = QString("mv %1 %2").arg(file1, file2); qDebug() << "Command: " << cmd; - system(cmd.toLocal8Bit()); + CHECKED_SYSTEM(cmd.toLocal8Bit()); #endif } @@ -160,7 +168,7 @@ private slots: QString cmd; cmd = QString("echo \"xyz\" > \"%1\"").arg(file); qDebug() << "Command: " << cmd; - system(cmd.toLocal8Bit()); + CHECKED_SYSTEM(cmd.toLocal8Bit()); QVERIFY(waitForPathChanged(file)); } diff --git a/test/testinotifywatcher.cpp b/test/testinotifywatcher.cpp index 204939f9132c6..fda28e4495636 100644 --- a/test/testinotifywatcher.cpp +++ b/test/testinotifywatcher.cpp @@ -4,11 +4,19 @@ * any purpose. * */ +#include #include #include "folderwatcher_linux.h" #include "common/utility.h" +#define CHECKED_SYSTEM(cmd_) \ + do { \ + int result_ = system(cmd_); \ + Q_ASSERT(WIFEXITED(result_)); \ + Q_ASSERT(WEXITSTATUS(result_) == 0); \ + } while(0) + using namespace OCC; class TestInotifyWatcher: public FolderWatcherPrivate @@ -62,7 +70,7 @@ private slots: void cleanupTestCase() { if( _root.startsWith(QDir::tempPath() )) { - system( QString("rm -rf %1").arg(_root).toLocal8Bit() ); + CHECKED_SYSTEM( QString("rm -rf %1").arg(_root).toLocal8Bit() ); } } };