Skip to content

Commit 93233fe

Browse files
committed
Removed use of tmpnam in tests
1 parent 3924db0 commit 93233fe

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/pass_unit_tests.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
#pragma clang diagnostic push
1010
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1111

12-
bool test_openCreatesFileWithProperMode()
12+
void test_openCreatesFileWithProperMode()
1313
{
1414
namespace fs = std::filesystem;
15-
const fs::path temp_file = std::tmpnam (nullptr);
15+
const fs::path temp_file = fs::temp_directory_path() / "test_file_XXXXXX";
1616

1717
const int mode = S_IRGRP | S_IROTH | S_IRUSR | S_IWUSR;
1818
const int fd = open (temp_file.c_str(), O_CREAT | O_WRONLY, mode);
@@ -32,7 +32,7 @@ bool test_openCreatesFileWithProperMode()
3232
void test_fcntlFlockDiesWhenRealtime()
3333
{
3434
namespace fs = std::filesystem;
35-
const fs::path temp_file = std::tmpnam (nullptr);
35+
const fs::path temp_file = fs::temp_directory_path() / "test_file_XXXXXX";
3636
int fd = creat(temp_file.c_str(), S_IRUSR | S_IWUSR);
3737
assert(fd != -1);
3838

@@ -48,6 +48,8 @@ void test_fcntlFlockDiesWhenRealtime()
4848
assert(lock.l_type == F_UNLCK);
4949
};
5050

51+
func();
52+
5153
close(fd);
5254
std::remove (temp_file.c_str());
5355
}

0 commit comments

Comments
 (0)