From: Joel Rosdahl Date: Mon, 1 Apr 2024 19:24:14 +0000 (+0200) Subject: test: Don't leave fs_test.tmp* files after InodeCache unit tests X-Git-Tag: v4.10~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be742bad1e2ddf385fd3b1d2749f83248f14f452;p=thirdparty%2Fccache.git test: Don't leave fs_test.tmp* files after InodeCache unit tests --- diff --git a/unittest/test_InodeCache.cpp b/unittest/test_InodeCache.cpp index 5e9cd806..41a9c348 100644 --- a/unittest/test_InodeCache.cpp +++ b/unittest/test_InodeCache.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -32,6 +33,8 @@ #include #include +namespace fs = util::filesystem; + using TestUtil::TestContext; namespace { @@ -40,7 +43,12 @@ bool inode_cache_available() { auto tmp_file = util::TemporaryFile::create(util::actual_cwd() + "/fs_test"); - return tmp_file && tmp_file->fd && InodeCache::available(*tmp_file->fd); + if (!tmp_file) { + return false; + } + bool available = tmp_file->fd && InodeCache::available(*tmp_file->fd); + fs::remove(tmp_file->path); + return available; } void