public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Hridya Valsaraju <hridya@google.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] mtest06: Use temp dir from $TMPDIR if present
Date: Wed,  7 Mar 2018 16:52:50 -0800	[thread overview]
Message-ID: <20180308005250.210404-1-hridya@google.com> (raw)

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


             reply	other threads:[~2018-03-08  0:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-08  0:52 Hridya Valsaraju [this message]
2018-03-08 14:07 ` [LTP] [PATCH] mtest06: Use temp dir from $TMPDIR if present Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180308005250.210404-1-hridya@google.com \
    --to=hridya@google.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox