Fix and enable SysV IPC tests.

Don't declare some types that FreeBSD incorrectly declares.

Fix an incorrect call to open() (missing mode).

ANSIfy prototypes.

Enable SysV message queue, semaphore, and shared memory tests.

With exception of the workaround for union semun, these fixes have been
committed to NetBSD.

Reviewed by:	asomers
Approved by:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D13471
This commit is contained in:
Brooks Davis 2018-02-05 18:48:00 +00:00
parent e9a7bae553
commit 5e1e3ea237
2 changed files with 13 additions and 16 deletions

View File

@ -72,7 +72,7 @@ void sharer(void);
#define MESSAGE_TEXT_LEN 256
struct mymsg {
struct testmsg {
long mtype;
char mtext[MESSAGE_TEXT_LEN];
};
@ -94,11 +94,13 @@ key_t msgkey, semkey, shmkey;
int maxloop = 1;
#ifndef __FreeBSD__
union semun {
int val; /* value for SETVAL */
struct semid_ds *buf; /* buffer for IPC_{STAT,SET} */
u_short *array; /* array for GETALL & SETALL */
};
#endif
/* Writes an integer to a file. To be used from the body of the test
@ -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);
@ -202,7 +204,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 +349,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();
@ -381,9 +381,9 @@ print_msqid_ds(mp, mode)
}
void
receiver()
receiver(void)
{
struct mymsg m;
struct testmsg m;
int msqid, loop;
if ((msqid = msgget(msgkey, 0)) == -1)
@ -588,9 +588,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 +618,7 @@ print_semid_ds(sp, mode)
}
void
waiter()
waiter(void)
{
struct sembuf s;
int semid;
@ -789,9 +787,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();
@ -823,7 +819,7 @@ print_shmid_ds(sp, mode)
}
void
sharer()
sharer(void)
{
int shmid;
void *shm_buf;

View File

@ -26,6 +26,7 @@ LIBADD.unix_seqpacket_test+= pthread
NETBSD_ATF_TESTS_C+= lockf_test
NETBSD_ATF_TESTS_C+= mqueue_test
NETBSD_ATF_TESTS_C+= sysv_test
CFLAGS.mqueue_test+= -I${SRCTOP}/tests
LIBADD.mqueue_test+= rt