Committed - thanks!

On Sat, 3 Feb 2018, Paul Goyette wrote:

Thanks, Brooks, I'll have a look at this.


On Sat, 3 Feb 2018, Brooks Davis wrote:

In our FreeBSD derivative I made some changes to the kernel/t_sysv.c test
(I'm not sure where it lives in the NetBSD tree).  I've included them
below.

The changes are:
- Don't use the example msg struct name (FreeBSD erroneously defines it).
- Fix a broken call to open(2) with O_CREAT and no permission argument.
- ANSIfy function definitions.
- Improve failure messages.

-- Brooks

P.S. FreeBSD also erroneously defines union semun, but I'm working to
fix that so haven't included the change.

diff --git a/contrib/netbsd-tests/kernel/t_sysv.c b/contrib/netbsd-tests/kernel/t_sysv.c
index 0860d4b35c6..50fa0edcb36 100644
--- a/contrib/netbsd-tests/kernel/t_sysv.c
+++ b/contrib/netbsd-tests/kernel/t_sysv.c
@@ -72,7 +72,7 @@ void  sharer(void);

#define MESSAGE_TEXT_LEN        256

-struct mymsg {
+struct testmsg {
        long    mtype;
        char    mtext[MESSAGE_TEXT_LEN];
};
@@ -174,7 +176,7 @@ key_t get_ftok(int id)

        /* Create the file, since ftok() requires it to exist! */

-       fd = open(token_key, O_RDWR | O_CREAT | O_EXCL);
+       fd = open(token_key, O_RDWR | O_CREAT | O_EXCL, 0600);
        if (fd == -1) {
                rmdir(tmpdir);
                atf_tc_fail("open() of temp file failed: %d", errno);
@@ -183,6 +185,7 @@ key_t get_ftok(int id)
                close(fd);

        key = ftok(token_key, id);
+       ATF_REQUIRE_MSG(key != (key_t)-1, "ftok() failed");

ATF_REQUIRE_MSG(unlink(token_key) != -1, "unlink() failed: %d", errno);
        ATF_REQUIRE_MSG(rmdir(token_dir) != -1, "rmdir() failed: %d", errno);
@@ -202,7 +205,7 @@ ATF_TC_BODY(msg, tc)
{
        struct sigaction sa;
        struct msqid_ds m_ds;
-       struct mymsg m;
+       struct testmsg m;
        sigset_t sigmask;
        int sender_msqid;
        int loop;
@@ -347,9 +350,7 @@ ATF_TC_CLEANUP(msg, tc)
}

void
-print_msqid_ds(mp, mode)
-       struct msqid_ds *mp;
-       mode_t mode;
+print_msqid_ds(struct msqid_ds *mp, mode_t mode)
{
        uid_t uid = geteuid();
        gid_t gid = getegid();
@@ -377,13 +378,14 @@ print_msqid_ds(mp, mode)
        ATF_REQUIRE_MSG(mp->msg_perm.gid == gid && mp->msg_perm.cgid == gid,
            "gid mismatch");

-       ATF_REQUIRE_MSG((mp->msg_perm.mode & 0777) == mode, "mode mismatch");
+       ATF_REQUIRE_MSG((mp->msg_perm.mode & 0777) == mode,
+           "mode mismatch %o != %o", (mp->msg_perm.mode & 0777), mode);
}

void
-receiver()
+receiver(void)
{
-       struct mymsg m;
+       struct testmsg m;
        int msqid, loop;

        if ((msqid = msgget(msgkey, 0)) == -1)
@@ -588,9 +590,7 @@ ATF_TC_CLEANUP(sem, tc)
}

void
-print_semid_ds(sp, mode)
-       struct semid_ds *sp;
-       mode_t mode;
+print_semid_ds(struct semid_ds *sp, mode_t mode)
{
        uid_t uid = geteuid();
        gid_t gid = getegid();
@@ -620,7 +620,7 @@ print_semid_ds(sp, mode)
}

void
-waiter()
+waiter(void)
{
        struct sembuf s;
        int semid;
@@ -789,9 +789,7 @@ ATF_TC_CLEANUP(shm, tc)
}

void
-print_shmid_ds(sp, mode)
-       struct shmid_ds *sp;
-       mode_t mode;
+print_shmid_ds(struct shmid_ds *sp, mode_t mode)
{
        uid_t uid = geteuid();
        gid_t gid = getegid();
@@ -819,11 +817,12 @@ print_shmid_ds(sp, mode)
        ATF_REQUIRE_MSG(sp->shm_perm.gid == gid && sp->shm_perm.cgid == gid,
            "gid mismatch");

-       ATF_REQUIRE_MSG((sp->shm_perm.mode & 0777) == mode, "mode mismatch");
+       ATF_REQUIRE_MSG((sp->shm_perm.mode & 0777) == mode,
+           "mode mismatch %o != %o", (sp->shm_perm.mode & 0777), mode);
}

void
-sharer()
+sharer(void)
{
        int shmid;
        void *shm_buf;


+------------------+--------------------------+----------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+------------------+--------------------------+----------------------------+

!DSPAM:5a750887127691055528547!



+------------------+--------------------------+----------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:          |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+------------------+--------------------------+----------------------------+

Reply via email to