diff options
-rw-r--r-- | common/FileUtil.cpp | 5 | ||||
-rw-r--r-- | common/Unit.hpp | 7 | ||||
-rw-r--r-- | test/UnitStorage.cpp | 16 |
3 files changed, 17 insertions, 11 deletions
diff --git a/common/FileUtil.cpp b/common/FileUtil.cpp index 02d2e705f..af6dfef57 100644 --- a/common/FileUtil.cpp +++ b/common/FileUtil.cpp @@ -27,6 +27,7 @@ #include "Log.hpp" #include "Util.hpp" +#include "Unit.hpp" namespace { @@ -233,6 +234,10 @@ namespace FileUtil { assert(!path.empty()); + bool hookResult; + if (UnitBase::get().filterCheckDiskSpace(path, hookResult)) + return hookResult; + struct statfs sfs; if (statfs(path.c_str(), &sfs) == -1) return true; diff --git a/common/Unit.hpp b/common/Unit.hpp index 69d0b3bc2..e8197fd15 100644 --- a/common/Unit.hpp +++ b/common/Unit.hpp @@ -95,6 +95,13 @@ public: return false; } + /// Hook the disk space check + virtual bool filterCheckDiskSpace(const std::string & /* path */, + bool & /* newResult */) + { + return false; + } + /// If the test times out this gets invoked, the default just exits. virtual void timeout(); diff --git a/test/UnitStorage.cpp b/test/UnitStorage.cpp index e67118fc9..525a2fd28 100644 --- a/test/UnitStorage.cpp +++ b/test/UnitStorage.cpp @@ -33,17 +33,11 @@ public: { } - virtual bool filterLoad(const std::string &sessionId, - const std::string &jailId, - bool &/* result */) + bool filterCheckDiskSpace(const std::string & /* path */, + bool &newResult) override { - LOG_TRC("FilterLoad: " << sessionId << " jail " << jailId); - if (_phase == Phase::Filter) - { - LOG_INF("Throwing low disk space exception."); - throw StorageSpaceLowException("test: low disk space"); - } - return false; + newResult = _phase != Phase::Filter; + return true; } void loadDocument(bool bExpectFailure) @@ -76,7 +70,7 @@ public: } } - virtual void invokeTest() + void invokeTest() override { LOG_TRC("invokeTest: " << (int)_phase); switch (_phase) |