aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2015-04-11 03:54:43 +0000
committerEnji Cooper <ngie@FreeBSD.org>2015-04-11 03:54:43 +0000
commit5a3935b6d66c1810125b0a92a0f26e207236f6fb (patch)
tree1fda663967c0c73bce7ba3f5e0a1038a3f836001 /tools
parent1e0d20633776de016f35022ecd48213941cd1cc3 (diff)
downloadsrc-5a3935b6d66c1810125b0a92a0f26e207236f6fb.tar.gz
src-5a3935b6d66c1810125b0a92a0f26e207236f6fb.zip
- Garbage collect argc/argv
- Use random paths instead of one in /tmp MFC after: 1 week Sponsored by: EMC / Isilon Storage Division
Notes
Notes: svn path=/head/; revision=281401
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/sockets/unix_sendtorace/Makefile2
-rw-r--r--tools/regression/sockets/unix_sendtorace/unix_sendtorace.c23
2 files changed, 14 insertions, 11 deletions
diff --git a/tools/regression/sockets/unix_sendtorace/Makefile b/tools/regression/sockets/unix_sendtorace/Makefile
index 0b183760bb1b..75e7b9f0b606 100644
--- a/tools/regression/sockets/unix_sendtorace/Makefile
+++ b/tools/regression/sockets/unix_sendtorace/Makefile
@@ -2,6 +2,6 @@
PROG= unix_sendtorace
MAN=
-WARNS?= 3
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/unix_sendtorace/unix_sendtorace.c b/tools/regression/sockets/unix_sendtorace/unix_sendtorace.c
index 2445b81752e6..9fd748d6f7bb 100644
--- a/tools/regression/sockets/unix_sendtorace/unix_sendtorace.c
+++ b/tools/regression/sockets/unix_sendtorace/unix_sendtorace.c
@@ -45,9 +45,10 @@
#include <string.h>
#include <unistd.h>
-#define PATH "/tmp/123"
#define ITERATIONS 1000000
+static char socket_path[] = "tmp.XXXXXX";
+
static void
stream_server(int listenfd)
{
@@ -75,7 +76,7 @@ stream_client(void)
bzero(&sun, sizeof(sun));
sun.sun_len = sizeof(sun);
sun.sun_family = AF_UNIX;
- strcpy(sun.sun_path, PATH);
+ strcpy(sun.sun_path, socket_path);
for (i = 0; i < ITERATIONS; i++) {
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
@@ -104,7 +105,7 @@ stream_test(void)
bzero(&sun, sizeof(sun));
sun.sun_len = sizeof(sun);
sun.sun_family = AF_UNIX;
- strcpy(sun.sun_path, PATH);
+ strcpy(sun.sun_path, socket_path);
if (bind(listenfd, (struct sockaddr *)&sun, sizeof(sun)) < 0)
err(-1, "stream_test: bind");
@@ -124,7 +125,7 @@ stream_test(void)
} else
stream_server(listenfd);
- (void)unlink(PATH);
+ (void)unlink(socket_path);
}
static void
@@ -151,7 +152,7 @@ datagram_client(void)
bzero(&sun, sizeof(sun));
sun.sun_len = sizeof(sun);
sun.sun_family = AF_UNIX;
- strcpy(sun.sun_path, PATH);
+ strcpy(sun.sun_path, socket_path);
for (i = 0; i < ITERATIONS; i++) {
fd = socket(PF_UNIX, SOCK_DGRAM, 0);
if (fd < 0) {
@@ -180,7 +181,7 @@ datagram_test(void)
bzero(&sun, sizeof(sun));
sun.sun_len = sizeof(sun);
sun.sun_family = AF_UNIX;
- strcpy(sun.sun_path, PATH);
+ strcpy(sun.sun_path, socket_path);
if (bind(serverfd, (struct sockaddr *)&sun, sizeof(sun)) < 0)
err(-1, "datagram_test: bind");
@@ -197,14 +198,16 @@ datagram_test(void)
} else
datagram_server(serverfd);
- (void)unlink(PATH);
+ (void)unlink(socket_path);
}
int
-main(int argc, char *argv[])
+main(void)
{
-
- (void)unlink(PATH);
+
+ if (mkstemp(socket_path) == -1)
+ err(1, "mkstemp failed");
+ (void)unlink(socket_path);
datagram_test();
if (0)
stream_test();