diff options
author | ngie <ngie@FreeBSD.org> | 2015-04-11 09:20:20 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2015-04-11 09:20:20 +0000 |
commit | 33c0504f3c3bb23159abe35f9d36676628e910f0 (patch) | |
tree | 92317236c894dca592248110c89205e7366fd8f1 /tools | |
parent | 6fa249869e7f6f524d776f5e0c641b0a26211e2f (diff) | |
download | FreeBSD-src-33c0504f3c3bb23159abe35f9d36676628e910f0.zip FreeBSD-src-33c0504f3c3bb23159abe35f9d36676628e910f0.tar.gz |
Integrate tools/regression/mqueue into the FreeBSD test suite as tests/sys/mqueue
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/mqueue/Makefile | 5 | ||||
-rw-r--r-- | tools/regression/mqueue/mqtest1/Makefile | 9 | ||||
-rw-r--r-- | tools/regression/mqueue/mqtest1/mqtest1.c | 52 | ||||
-rw-r--r-- | tools/regression/mqueue/mqtest2/Makefile | 9 | ||||
-rw-r--r-- | tools/regression/mqueue/mqtest2/mqtest2.c | 93 | ||||
-rw-r--r-- | tools/regression/mqueue/mqtest3/Makefile | 9 | ||||
-rw-r--r-- | tools/regression/mqueue/mqtest3/mqtest3.c | 109 | ||||
-rw-r--r-- | tools/regression/mqueue/mqtest4/Makefile | 9 | ||||
-rw-r--r-- | tools/regression/mqueue/mqtest4/mqtest4.c | 115 | ||||
-rw-r--r-- | tools/regression/mqueue/mqtest5/Makefile | 9 | ||||
-rw-r--r-- | tools/regression/mqueue/mqtest5/mqtest5.c | 122 |
11 files changed, 0 insertions, 541 deletions
diff --git a/tools/regression/mqueue/Makefile b/tools/regression/mqueue/Makefile deleted file mode 100644 index a4f386b..0000000 --- a/tools/regression/mqueue/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -SUBDIR=mqtest1 mqtest2 mqtest3 mqtest4 mqtest5 - -.include <bsd.subdir.mk> diff --git a/tools/regression/mqueue/mqtest1/Makefile b/tools/regression/mqueue/mqtest1/Makefile deleted file mode 100644 index 3a50cee..0000000 --- a/tools/regression/mqueue/mqtest1/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD$ - -PROG=mqtest1 -DPADD= ${LIBRT} -LDADD= -lrt -MAN= -DEBUG_FLAGS=-g - -.include <bsd.prog.mk> diff --git a/tools/regression/mqueue/mqtest1/mqtest1.c b/tools/regression/mqueue/mqtest1/mqtest1.c deleted file mode 100644 index 25fc1ba..0000000 --- a/tools/regression/mqueue/mqtest1/mqtest1.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $FreeBSD$ */ - -#include <err.h> -#include <errno.h> -#include <fcntl.h> -#include <mqueue.h> -#include <signal.h> -#include <stdio.h> - -#define MQNAME "/mytstqueue1" - -int main() -{ - struct mq_attr attr, attr2; - struct sigevent sigev; - mqd_t mq; - int status; - - attr.mq_maxmsg = 2; - attr.mq_msgsize = 100; - mq = mq_open(MQNAME, O_CREAT | O_RDWR | O_EXCL, 0666, &attr); - if (mq == (mqd_t)-1) - err(1, "mq_open"); - status = mq_unlink(MQNAME); - if (status) - err(1, "mq_unlink"); - status = mq_getattr(mq, &attr2); - if (status) - err(1, "mq_getattr"); - if (attr.mq_maxmsg != attr2.mq_maxmsg) - err(1, "mq_maxmsg changed"); - if (attr.mq_msgsize != attr2.mq_msgsize) - err(1, "mq_msgsize changed"); - - sigev.sigev_notify = SIGEV_SIGNAL; - sigev.sigev_signo = SIGRTMIN; - status = mq_notify(mq, &sigev); - if (status) - err(1, "mq_notify"); - status = mq_notify(mq, &sigev); - if (status == 0) - err(1, "mq_notify 2"); - else if (errno != EBUSY) - err(1, "mq_notify 3"); - status = mq_notify(mq, NULL); - if (status) - err(1, "mq_notify 4"); - status = mq_close(mq); - if (status) - err(1, "mq_close"); - return (0); -} diff --git a/tools/regression/mqueue/mqtest2/Makefile b/tools/regression/mqueue/mqtest2/Makefile deleted file mode 100644 index 0709854..0000000 --- a/tools/regression/mqueue/mqtest2/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD$ - -PROG=mqtest2 -DPADD= ${LIBRT} -LDADD= -lrt -MAN= -DEBUG_FLAGS=-g - -.include <bsd.prog.mk> diff --git a/tools/regression/mqueue/mqtest2/mqtest2.c b/tools/regression/mqueue/mqtest2/mqtest2.c deleted file mode 100644 index bfe6d97..0000000 --- a/tools/regression/mqueue/mqtest2/mqtest2.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $FreeBSD$ */ - -#include <sys/types.h> -#include <sys/wait.h> -#include <err.h> -#include <fcntl.h> -#include <mqueue.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#define MQNAME "/mytstqueue2" -#define LOOPS 1000 -#define PRIO 10 - -void alarmhandler(int sig) -{ - write(1, "timeout\n", 8); - _exit(1); -} - -int main() -{ - struct mq_attr attr; - mqd_t mq; - int status, pid; - - mq_unlink(MQNAME); - - attr.mq_maxmsg = 5; - attr.mq_msgsize = 128; - mq = mq_open(MQNAME, O_CREAT | O_RDWR | O_EXCL, 0666, &attr); - if (mq == (mqd_t)-1) - err(1, "mq_open"); - status = mq_getattr(mq, &attr); - if (status) - err(1, "mq_getattr"); - pid = fork(); - if (pid == 0) { /* child */ - int prio, j, i; - char *buf; - - mq_close(mq); - - signal(SIGALRM, alarmhandler); - - mq = mq_open(MQNAME, O_RDWR); - if (mq == (mqd_t)-1) - err(1, "child: mq_open"); - buf = malloc(attr.mq_msgsize); - for (j = 0; j < LOOPS; ++j) { - alarm(3); - status = mq_receive(mq, buf, attr.mq_msgsize, &prio); - if (status == -1) - err(2, "child: mq_receive"); - for (i = 0; i < attr.mq_msgsize; ++i) - if (buf[i] != i) - err(3, "child: message data corrupted"); - if (prio != PRIO) - err(4, "child: priority is incorrect: %d", - prio); - } - alarm(0); - free(buf); - mq_close(mq); - return (0); - } else if (pid == -1) { - err(1, "fork()"); - } else { - char *buf; - int i, j, prio; - - signal(SIGALRM, alarmhandler); - buf = malloc(attr.mq_msgsize); - for (j = 0; j < LOOPS; ++j) { - for (i = 0; i < attr.mq_msgsize; ++i) - buf[i] = i; - alarm(3); - status = mq_send(mq, buf, attr.mq_msgsize, PRIO); - if (status) - err(1, "mq_send"); - } - alarm(3); - wait(&status); - alarm(0); - } - status = mq_close(mq); - if (status) - err(1, "mq_close"); - mq_unlink(MQNAME); - return (0); -} diff --git a/tools/regression/mqueue/mqtest3/Makefile b/tools/regression/mqueue/mqtest3/Makefile deleted file mode 100644 index 514cbac..0000000 --- a/tools/regression/mqueue/mqtest3/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD$ - -PROG=mqtest3 -DPADD= ${LIBRT} -LDADD= -lrt -MAN= -DEBUG_FLAGS=-g - -.include <bsd.prog.mk> diff --git a/tools/regression/mqueue/mqtest3/mqtest3.c b/tools/regression/mqueue/mqtest3/mqtest3.c deleted file mode 100644 index aa47ffa..0000000 --- a/tools/regression/mqueue/mqtest3/mqtest3.c +++ /dev/null @@ -1,109 +0,0 @@ -/* $FreeBSD$ */ - -#include <sys/types.h> -#include <sys/select.h> -#include <sys/wait.h> -#include <err.h> -#include <fcntl.h> -#include <mqueue.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#define MQNAME "/mytstqueue3" -#define LOOPS 1000 -#define PRIO 10 - -void sighandler(int sig) -{ - write(1, "timeout\n", 8); - _exit(1); -} - -int main() -{ - mqd_t mq; - int status; - struct mq_attr attr; - int pid; - fd_set set; - - mq_unlink(MQNAME); - - attr.mq_maxmsg = 5; - attr.mq_msgsize = 128; - mq = mq_open(MQNAME, O_CREAT | O_RDWR | O_EXCL, 0666, &attr); - if (mq == (mqd_t)-1) - err(1, "mq_open()"); - status = mq_getattr(mq, &attr); - if (status) - err(1, "mq_getattr()"); - - pid = fork(); - if (pid == 0) { /* child */ - int prio, j, i; - char *buf; - - mq_close(mq); - - signal(SIGALRM, sighandler); - - mq = mq_open(MQNAME, O_RDWR); - if (mq == (mqd_t)-1) - err(1, "child process: mq_open"); - buf = malloc(attr.mq_msgsize); - for (j = 0; j < LOOPS; ++j) { - FD_ZERO(&set); - FD_SET(__mq_oshandle(mq), &set); - alarm(3); - status = select(__mq_oshandle(mq)+1, &set, NULL, NULL, NULL); - if (status != 1) - err(1, "child process: select()"); - status = mq_receive(mq, buf, attr.mq_msgsize, &prio); - if (status == -1) - err(2, "child process: mq_receive"); - for (i = 0; i < attr.mq_msgsize; ++i) - if (buf[i] != i) - err(3, "message data corrupted"); - if (prio != PRIO) - err(4, "priority is incorrect: %d", prio); - } - alarm(0); - free(buf); - mq_close(mq); - return (0); - } else if (pid == -1) { - err(1, "fork()"); - } else { - char *buf; - int i, j, prio; - - signal(SIGALRM, sighandler); - buf = malloc(attr.mq_msgsize); - for (j = 0; j < LOOPS; ++j) { - for (i = 0; i < attr.mq_msgsize; ++i) { - buf[i] = i; - } - alarm(3); - FD_ZERO(&set); - FD_SET(__mq_oshandle(mq), &set); - status = select(__mq_oshandle(mq)+1, NULL, &set, NULL, NULL); - if (status != 1) - err(1, "select()"); - status = mq_send(mq, buf, attr.mq_msgsize, PRIO); - if (status) { - kill(pid, SIGKILL); - err(2, "mq_send()"); - } - } - alarm(3); - wait(&status); - alarm(0); - } - status = mq_close(mq); - if (status) - err(1, "mq_close"); - mq_unlink(MQNAME); - return (0); -} diff --git a/tools/regression/mqueue/mqtest4/Makefile b/tools/regression/mqueue/mqtest4/Makefile deleted file mode 100644 index 781d76d..0000000 --- a/tools/regression/mqueue/mqtest4/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD$ - -PROG=mqtest4 -DPADD= ${LIBRT} -LDADD= -lrt -MAN= -DEBUG_FLAGS=-g - -.include <bsd.prog.mk> diff --git a/tools/regression/mqueue/mqtest4/mqtest4.c b/tools/regression/mqueue/mqtest4/mqtest4.c deleted file mode 100644 index 80a7f88..0000000 --- a/tools/regression/mqueue/mqtest4/mqtest4.c +++ /dev/null @@ -1,115 +0,0 @@ -/* $FreeBSD$ */ - -#include <sys/types.h> -#include <sys/event.h> -#include <sys/select.h> -#include <sys/wait.h> -#include <err.h> -#include <fcntl.h> -#include <mqueue.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#define MQNAME "/mytstqueue4" -#define LOOPS 1000 -#define PRIO 10 - -void sighandler(int sig) -{ - write(1, "timeout\n", 8); - _exit(1); -} - -int main() -{ - mqd_t mq; - int status; - struct mq_attr attr; - int pid; - fd_set set; - int kq; - struct kevent kev; - - mq_unlink(MQNAME); - - attr.mq_maxmsg = 5; - attr.mq_msgsize = 128; - mq = mq_open(MQNAME, O_CREAT | O_RDWR | O_EXCL, 0666, &attr); - if (mq == (mqd_t) -1) - err(1, "mq_open()"); - status = mq_getattr(mq, &attr); - if (status) - err(1, "mq_getattr()"); - pid = fork(); - if (pid == 0) { /* child */ - int prio, j, i; - char *buf; - - mq_close(mq); - kq = kqueue(); - mq = mq_open(MQNAME, O_RDWR); - if (mq == (mqd_t)-1) - err(1, "child: mq_open"); - EV_SET(&kev, __mq_oshandle(mq), EVFILT_READ, EV_ADD, 0, 0, 0); - status = kevent(kq, &kev, 1, NULL, 0, NULL); - if (status == -1) - err(1, "child: kevent"); - buf = malloc(attr.mq_msgsize); - for (j = 0; j < LOOPS; ++j) { - alarm(3); - status = kevent(kq, NULL, 0, &kev, 1, NULL); - if (status != 1) - err(1, "child: kevent 2"); - status = mq_receive(mq, buf, attr.mq_msgsize, &prio); - if (status == -1) - err(2, "child: mq_receive"); - for (i = 0; i < attr.mq_msgsize; ++i) - if (buf[i] != i) - err(3, "child: message data corrupted"); - if (prio != PRIO) - err(4, "child: priority is incorrect: %d", - prio); - } - alarm(0); - free(buf); - mq_close(mq); - return (0); - } else if (pid == -1) { - err(1, "fork()"); - } else { - char *buf; - int i, j, prio; - - signal(SIGALRM, sighandler); - kq = kqueue(); - EV_SET(&kev, __mq_oshandle(mq), EVFILT_WRITE, EV_ADD, 0, 0, 0); - status = kevent(kq, &kev, 1, NULL, 0, NULL); - if (status == -1) - err(1, "kevent"); - buf = malloc(attr.mq_msgsize); - for (j = 0; j < LOOPS; ++j) { - for (i = 0; i < attr.mq_msgsize; ++i) { - buf[i] = i; - } - alarm(3); - status = kevent(kq, NULL, 0, &kev, 1, NULL); - if (status != 1) - err(1, "child: kevent 2"); - status = mq_send(mq, buf, attr.mq_msgsize, PRIO); - if (status) { - err(2, "mq_send()"); - } - } - free(buf); - alarm(3); - wait(&status); - alarm(0); - } - status = mq_close(mq); - if (status) - err(1, "mq_close"); - mq_unlink(MQNAME); - return (0); -} diff --git a/tools/regression/mqueue/mqtest5/Makefile b/tools/regression/mqueue/mqtest5/Makefile deleted file mode 100644 index d94e541..0000000 --- a/tools/regression/mqueue/mqtest5/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD$ - -PROG=mqtest5 -DPADD= ${LIBRT} -LDADD= -lrt -MAN= -DEBUG_FLAGS=-g - -.include <bsd.prog.mk> diff --git a/tools/regression/mqueue/mqtest5/mqtest5.c b/tools/regression/mqueue/mqtest5/mqtest5.c deleted file mode 100644 index 354a7bb..0000000 --- a/tools/regression/mqueue/mqtest5/mqtest5.c +++ /dev/null @@ -1,122 +0,0 @@ -/* $FreeBSD$ */ - -#include <sys/types.h> -#include <sys/event.h> -#include <sys/select.h> -#include <sys/wait.h> -#include <err.h> -#include <fcntl.h> -#include <mqueue.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#define MQNAME "/mytstqueue5" -#define LOOPS 1000 -#define PRIO 10 - -void sighandler(int sig) -{ - write(1, "timeout\n", 8); - _exit(1); -} - -int main() -{ - mqd_t mq; - int status; - struct mq_attr attr; - int pid; - sigset_t set; - struct sigaction sa; - siginfo_t info; - - mq_unlink(MQNAME); - - sigemptyset(&set); - sigaddset(&set, SIGRTMIN); - sigprocmask(SIG_BLOCK, &set, NULL); - sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_SIGINFO; - sa.sa_sigaction = (void *) SIG_DFL; - sigaction(SIGRTMIN, &sa, NULL); - - attr.mq_maxmsg = 5; - attr.mq_msgsize = 128; - mq = mq_open(MQNAME, O_CREAT | O_RDWR | O_EXCL, 0666, &attr); - if (mq == (mqd_t)-1) - err(1, "mq_open()"); - status = mq_getattr(mq, &attr); - if (status) - err(1, "mq_getattr()"); - pid = fork(); - if (pid == 0) { /* child */ - int prio, j, i; - char *buf; - struct sigevent sigev; - - signal(SIGALRM, sighandler); - - sigev.sigev_notify = SIGEV_SIGNAL; - sigev.sigev_signo = SIGRTMIN; - sigev.sigev_value.sival_int = 2; - - mq_close(mq); - mq = mq_open(MQNAME, O_RDWR | O_NONBLOCK); - if (mq == (mqd_t)-1) - err(1, "child: mq_open"); - buf = malloc(attr.mq_msgsize); - for (j = 0; j < LOOPS; ++j) { - alarm(3); - status = mq_notify(mq, &sigev); - if (status) - err(1, "child: mq_notify"); - status = sigwaitinfo(&set, &info); - if (status == -1) - err(1, "child: sigwaitinfo"); - if (info.si_value.sival_int != 2) - err(1, "child: sival_int"); - status = mq_receive(mq, buf, attr.mq_msgsize, &prio); - if (status == -1) - err(2, "child: mq_receive"); - for (i = 0; i < attr.mq_msgsize; ++i) - if (buf[i] != i) - err(3, "child: message data corrupted"); - if (prio != PRIO) - err(4, "child: priority is incorrect: %d", - prio); - } - alarm(0); - free(buf); - mq_close(mq); - return (0); - } else if (pid == -1) { - err(1, "fork()"); - } else { - char *buf; - int i, j, prio; - - signal(SIGALRM, sighandler); - buf = malloc(attr.mq_msgsize); - for (j = 0; j < LOOPS; ++j) { - for (i = 0; i < attr.mq_msgsize; ++i) { - buf[i] = i; - } - alarm(3); - status = mq_send(mq, buf, attr.mq_msgsize, PRIO); - if (status) { - kill(pid, SIGKILL); - err(2, "mq_send()"); - } - } - alarm(3); - wait(&status); - alarm(0); - } - status = mq_close(mq); - if (status) - err(1, "mq_close"); - mq_unlink(MQNAME); - return (0); -} |