summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/misc/bug-glob1.c4
-rw-r--r--test/nptl/tst-cancel4.c48
-rw-r--r--test/stdlib/test-canon2.c18
-rw-r--r--test/test-skeleton.c22
4 files changed, 48 insertions, 44 deletions
diff --git a/test/misc/bug-glob1.c b/test/misc/bug-glob1.c
index aec84ad44..276983a0d 100644
--- a/test/misc/bug-glob1.c
+++ b/test/misc/bug-glob1.c
@@ -32,9 +32,7 @@ prepare (int argc, char *argv[])
again:
strcpy (stpcpy (fname, argv[1]), ext);
-/*
- fname = mktemp (fname);
-*/
+/* fname = mktemp (fname); */
close(mkstemp(fname));
unlink(fname);
diff --git a/test/nptl/tst-cancel4.c b/test/nptl/tst-cancel4.c
index 12d40d5bd..c0f1cd88c 100644
--- a/test/nptl/tst-cancel4.c
+++ b/test/nptl/tst-cancel4.c
@@ -978,6 +978,7 @@ tf_pause (void *arg)
static void *
tf_accept (void *arg)
{
+ int tfd;
struct sockaddr_un sun;
/* To test a non-blocking accept call we make the call file by using
a datagrame socket. */
@@ -999,12 +1000,13 @@ tf_accept (void *arg)
}
strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-1-XXXXXX");
- if (mktemp (sun.sun_path) == NULL)
+ tfd = mkstemp(sun.sun_path);
+ if (tfd < 0)
{
printf ("%s: cannot generate temp file name\n", __FUNCTION__);
exit (1);
}
-
+ close(tfd);
sun.sun_family = AF_UNIX;
}
while (bind (tempfd, (struct sockaddr *) &sun,
@@ -1049,6 +1051,7 @@ tf_accept (void *arg)
static void *
tf_send (void *arg)
{
+ int tfd;
struct sockaddr_un sun;
tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
@@ -1067,12 +1070,13 @@ tf_send (void *arg)
}
strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
- if (mktemp (sun.sun_path) == NULL)
+ tfd = mkstemp(sun.sun_path);
+ if (tfd < 0)
{
printf ("%s: cannot generate temp file name\n", __FUNCTION__);
exit (1);
}
-
+ close(tfd);
sun.sun_family = AF_UNIX;
}
while (bind (tempfd, (struct sockaddr *) &sun,
@@ -1131,6 +1135,7 @@ tf_send (void *arg)
static void *
tf_recv (void *arg)
{
+ int tfd;
struct sockaddr_un sun;
tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
@@ -1149,12 +1154,13 @@ tf_recv (void *arg)
}
strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-3-XXXXXX");
- if (mktemp (sun.sun_path) == NULL)
+ tfd = mkstemp(sun.sun_path);
+ if (tfd < 0)
{
printf ("%s: cannot generate temp file name\n", __FUNCTION__);
exit (1);
}
-
+ close(tfd);
sun.sun_family = AF_UNIX;
}
while (bind (tempfd, (struct sockaddr *) &sun,
@@ -1212,6 +1218,7 @@ tf_recv (void *arg)
static void *
tf_recvfrom (void *arg)
{
+ int tfd;
struct sockaddr_un sun;
tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
@@ -1230,12 +1237,13 @@ tf_recvfrom (void *arg)
}
strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-4-XXXXXX");
- if (mktemp (sun.sun_path) == NULL)
+ tfd = mkstemp(sun.sun_path);
+ if (tfd < 0)
{
printf ("%s: cannot generate temp file name\n", __FUNCTION__);
exit (1);
}
-
+ close(tfd);
sun.sun_family = AF_UNIX;
}
while (bind (tempfd, (struct sockaddr *) &sun,
@@ -1287,6 +1295,7 @@ tf_recvfrom (void *arg)
static void *
tf_recvmsg (void *arg)
{
+ int tfd;
struct sockaddr_un sun;
tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
@@ -1305,12 +1314,13 @@ tf_recvmsg (void *arg)
}
strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-5-XXXXXX");
- if (mktemp (sun.sun_path) == NULL)
+ tfd = mkstemp(sun.sun_path);
+ if (tfd < 0)
{
printf ("%s: cannot generate temp file name\n", __FUNCTION__);
exit (1);
}
-
+ close(tfd);
sun.sun_family = AF_UNIX;
}
while (bind (tempfd, (struct sockaddr *) &sun,
@@ -1663,6 +1673,7 @@ tf_msync (void *arg)
static void *
tf_sendto (void *arg)
{
+ int tfd;
if (arg == NULL)
// XXX If somebody can provide a portable test case in which sendto()
// blocks we can enable this test to run in both rounds.
@@ -1686,12 +1697,13 @@ tf_sendto (void *arg)
}
strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-6-XXXXXX");
- if (mktemp (sun.sun_path) == NULL)
+ tfd = mkstemp(sun.sun_path);
+ if (tfd < 0)
{
printf ("%s: cannot generate temp file name\n", __FUNCTION__);
exit (1);
}
-
+ close(tfd);
sun.sun_family = AF_UNIX;
}
while (bind (tempfd, (struct sockaddr *) &sun,
@@ -1739,6 +1751,7 @@ tf_sendto (void *arg)
static void *
tf_sendmsg (void *arg)
{
+ int tfd;
if (arg == NULL)
// XXX If somebody can provide a portable test case in which sendmsg()
// blocks we can enable this test to run in both rounds.
@@ -1762,12 +1775,13 @@ tf_sendmsg (void *arg)
}
strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX");
- if (mktemp (sun.sun_path) == NULL)
+ tfd = mkstemp(sun.sun_path);
+ if (tfd < 0)
{
printf ("%s: cannot generate temp file name\n", __FUNCTION__);
exit (1);
}
-
+ close(tfd);
sun.sun_family = AF_UNIX;
}
while (bind (tempfd, (struct sockaddr *) &sun,
@@ -1859,6 +1873,7 @@ tf_creat (void *arg)
static void *
tf_connect (void *arg)
{
+ int tfd;
if (arg == NULL)
// XXX If somebody can provide a portable test case in which connect()
// blocks we can enable this test to run in both rounds.
@@ -1882,12 +1897,13 @@ tf_connect (void *arg)
}
strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
- if (mktemp (sun.sun_path) == NULL)
+ tfd = mkstemp(sun.sun_path);
+ if (tfd < 0)
{
printf ("%s: cannot generate temp file name\n", __FUNCTION__);
exit (1);
}
-
+ close(tfd);
sun.sun_family = AF_UNIX;
}
while (bind (tempfd, (struct sockaddr *) &sun,
diff --git a/test/stdlib/test-canon2.c b/test/stdlib/test-canon2.c
index f182e95ad..e7e02e55e 100644
--- a/test/stdlib/test-canon2.c
+++ b/test/stdlib/test-canon2.c
@@ -40,6 +40,7 @@ void
do_prepare (int argc, char *argv[])
{
size_t test_dir_len;
+ int tfd;
test_dir_len = strlen (test_dir);
@@ -48,9 +49,20 @@ do_prepare (int argc, char *argv[])
mempcpy (mempcpy (name1, test_dir, test_dir_len),
"/canonXXXXXX", sizeof ("/canonXXXXXX"));
name2 = strdup (name1);
-
- add_temp_file (mktemp (name1));
- add_temp_file (mktemp (name2));
+ tfd = mkstemp(name1);
+ if (tfd < 0) {
+ printf("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit(1);
+ }
+ close(tfd);
+ add_temp_file (name1);
+ tfd = mkstemp(name2);
+ if (tfd < 0) {
+ printf("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit(1);
+ }
+ close(tfd);
+ add_temp_file (name2);
}
diff --git a/test/test-skeleton.c b/test/test-skeleton.c
index 0be4aa10b..752158405 100644
--- a/test/test-skeleton.c
+++ b/test/test-skeleton.c
@@ -87,28 +87,6 @@ add_temp_file (const char *name)
}
}
-#if defined __UCLIBC__ && !defined __UCLIBC_SUSV3_LEGACY__
-/* mktemp() isn't available, so fake it with tempnam().
- We make a lot of assumptions about the format of the
- "template" name, but we aren't testing that, so eh. */
-__attribute__ ((unused))
-static char *mktemp(char *template)
-{
- char *dir, *pfx, *s;
-
- dir = strdup (template);
- pfx = strrchr (dir, '/');
- *pfx++ = '\0';
- s = strstr (pfx, "XXXXXX");
- *s = '\0';
-
- s = tempnam (dir, pfx);
- strcpy (template, s);
- free (s);
- return template;
-}
-#endif
-
/* Delete all temporary files. */
static void
delete_temp_files (void)