* [LTP] [PATCH] mtest06: Use temp dir from $TMPDIR if present
@ 2018-03-08 0:52 Hridya Valsaraju
2018-03-08 14:07 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Hridya Valsaraju @ 2018-03-08 0:52 UTC (permalink / raw)
To: ltp
The test was failing in Android devices due to
/tmp not existing. This change uses tst_tmpir()
to create a temporary directory in $TMPDIR if it
is defined.
Signed-off-by: Hridya Valsaraju <hridya@google.com>
---
testcases/kernel/mem/mtest06/mmap1.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/mem/mtest06/mmap1.c b/testcases/kernel/mem/mtest06/mmap1.c
index 8894b0dbf..8f757d4c9 100644
--- a/testcases/kernel/mem/mtest06/mmap1.c
+++ b/testcases/kernel/mem/mtest06/mmap1.c
@@ -47,6 +47,7 @@
#include <stdlib.h>
#include <signal.h>
#include <sys/time.h>
+#include <sys/param.h>
#include <sys/wait.h>
#include <setjmp.h>
#include <pthread.h>
@@ -109,8 +110,13 @@ static void sig_handler_mapped(int signal, siginfo_t * info, void *ut)
int mkfile(int size)
{
- char template[] = "/tmp/ashfileXXXXXX";
int fd, i;
+ char template[MAXPATHLEN];
+ char *tmpdir;
+
+ tmpdir = tst_get_tmpdir();
+ snprintf(template, sizeof(template), "%s/ashfileXXXXXX", tmpdir);
+ free(tmpdir);
if ((fd = mkstemp(template)) == -1)
tst_brkm(TBROK | TERRNO, NULL, "mkstemp() failed");
@@ -375,6 +381,8 @@ int main(int argc, char **argv)
}
}
+ tst_tmpdir();
+
for (;;) {
if ((fd = mkfile(file_size)) == -1)
tst_brkm(TBROK, NULL,
@@ -416,5 +424,7 @@ int main(int argc, char **argv)
close(fd);
}
+ tst_rmdir();
+
exit(0);
}
--
2.16.2.395.g2e18187dfd-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [LTP] [PATCH] mtest06: Use temp dir from $TMPDIR if present
2018-03-08 0:52 [LTP] [PATCH] mtest06: Use temp dir from $TMPDIR if present Hridya Valsaraju
@ 2018-03-08 14:07 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2018-03-08 14:07 UTC (permalink / raw)
To: ltp
Hi!
Good catch, but given that the temporary directory created by
tst_tmpdir() is unique we can as well drop the whole mkstemp()
and replace it with just open().
#define FNAME "ashfile"
int mkfile(int size)
{
int fd;
fd = open(FNAME, O_RDWR | O_CREAT, 0600);
if (fd < 0)
tst_brk(...);
unlink(FNAME);
...
return fd;
}
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-08 14:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-08 0:52 [LTP] [PATCH] mtest06: Use temp dir from $TMPDIR if present Hridya Valsaraju
2018-03-08 14:07 ` Cyril Hrubis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.