Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/net/net When running the tests with atf-run the direct...



details:   https://anonhg.NetBSD.org/src/rev/6c39d6256e73
branches:  trunk
changeset: 937886:6c39d6256e73
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Aug 28 13:56:29 2020 +0000

description:
When running the tests with atf-run the directory we are running in is
drwx------ so when we change to a different user, we can't find the socket
we created.

Make a directory and put the socket in there. Of course now atf can't
record its results as a different user, but that is not fatal.

tc-se:FATAL ERROR: Cannot create results file '/tmp/atf-run.9vOjFd/tcr': \
Permission denied

diffstat:

 tests/net/net/t_unix.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (40 lines):

diff -r 9fc5f86c1e90 -r 6c39d6256e73 tests/net/net/t_unix.c
--- a/tests/net/net/t_unix.c    Fri Aug 28 13:50:48 2020 +0000
+++ b/tests/net/net/t_unix.c    Fri Aug 28 13:56:29 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_unix.c,v 1.22 2020/08/28 11:46:05 christos Exp $     */
+/*     $NetBSD: t_unix.c,v 1.23 2020/08/28 13:56:29 christos Exp $     */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #define _GNU_SOURCE
 #include <sys/cdefs.h>
 #ifdef __RCSID
-__RCSID("$Id: t_unix.c,v 1.22 2020/08/28 11:46:05 christos Exp $");
+__RCSID("$Id: t_unix.c,v 1.23 2020/08/28 13:56:29 christos Exp $");
 #else
 #define getprogname() argv[0]
 #endif
@@ -241,6 +241,12 @@
        if ((sun = calloc(1, slen)) == NULL)
                FAIL("calloc");
 
+       if (mkdir("sock", 0777) == -1)
+               FAIL("mkdir");
+
+       if (chdir("sock") == -1)
+               FAIL("chdir");
+
        memset(sun->sun_path, 'a', len);
        sun->sun_path[len] = '\0';
        (void)unlink(sun->sun_path);
@@ -251,6 +257,8 @@
 #endif
        sun->sun_family = AF_UNIX;
 
+       unlink(sun->sun_path);
+
        if (bind(srvr, (struct sockaddr *)sun, sl) == -1) {
                if (errno == EINVAL && sl >= 256) {
                        close(srvr);



Home | Main Index | Thread Index | Old Index