Skip to content

Commit 8b2d081

Browse files
committed
test: Improve error message when creating temporary file fails
1 parent de3dc48 commit 8b2d081

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

test/common/test-common.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#include "hipfile.h"
99
#include "magic-word.h"
1010

11+
#include <cerrno>
1112
#include <cstdint>
13+
#include <cstring>
1214
#include <iostream>
1315
#include <random>
1416
#include <stdexcept>
@@ -73,8 +75,10 @@ struct Tmpfile {
7375

7476
path += "/hipFile.XXXXXX";
7577
if ((fd = mkstemp(path.data())) == -1) {
78+
int mkstemp_err{errno};
7679
umask(old_umask);
77-
throw std::runtime_error("Could not create temporary file");
80+
throw std::runtime_error("Could not create temporary file " + path + ": " +
81+
std::string(std::strerror(mkstemp_err)));
7882
}
7983

8084
umask(old_umask);

0 commit comments

Comments
 (0)