diff --git a/tests/tst-fs.hh b/tests/tst-fs.hh index 6d5321ef4f..6330dea2d9 100644 --- a/tests/tst-fs.hh +++ b/tests/tst-fs.hh @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -22,8 +23,13 @@ typedef boost::format fmt; class TempDir : public fs::path { public: - TempDir() : fs::path(tmpnam(NULL)) { - fs::create_directories(*this); + TempDir() : fs::path() { + char path[64] = "/tmp/dirXXXXXX"; + auto dir_path = mkdtemp(path); + if (!dir_path) { + throw std::system_error(std::error_code(errno, std::system_category()), "error creating temp directory"); + } + *this += dir_path; } virtual ~TempDir() {