Skip to content

Commit 933d5a2

Browse files
authored
Workaround for if /tmp/ directory does not exist in the testing environment (#20)
1 parent 3d762fc commit 933d5a2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

winsup/testsuite/libltp/lib/tst_tmpdir.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,24 @@ tst_tmpdir()
136136
tst_brkm(TBROK, tmpdir_cleanup, "%s: tempnam(%s, %s) failed",
137137
FN_NAME, TEMPDIR, prefix);
138138

139+
struct stat st;
140+
if ( stat(P_tmpdir, &st) != 0 ) {
141+
if ( errno == ENOENT ) { /* Directory does not exist */
142+
if ( mkdir(P_tmpdir, DIR_MODE) == -1 )
143+
tst_brkm(TBROK, tmpdir_cleanup,
144+
"%s: mkdir(%s, %#o) failed; errno = %d: %s",
145+
FN_NAME, P_tmpdir, DIR_MODE, errno, strerror(errno));
146+
} else {
147+
tst_brkm(TBROK, tmpdir_cleanup,
148+
"%s: stat(%s) failed; errno = %d: %s",
149+
FN_NAME, P_tmpdir, errno, strerror(errno));
150+
}
151+
} else if ( !S_ISDIR(st.st_mode) ) {
152+
tst_brkm(TBROK, tmpdir_cleanup,
153+
"%s: %s exists but is not a directory",
154+
FN_NAME, P_tmpdir);
155+
}
156+
139157
/*
140158
* Create the temporary directory.
141159
*/

0 commit comments

Comments
 (0)