Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/regress/sys/kern/mqueue The mqueue test has been atf-ified
details: https://anonhg.NetBSD.org/src/rev/3e09602d23ec
branches: trunk
changeset: 782447:3e09602d23ec
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sat Nov 03 05:22:24 2012 +0000
description:
The mqueue test has been atf-ified
diffstat:
regress/sys/kern/mqueue/Makefile | 16 ----
regress/sys/kern/mqueue/mq_prio_test.c | 122 ---------------------------------
2 files changed, 0 insertions(+), 138 deletions(-)
diffs (146 lines):
diff -r 56b9fe91ca20 -r 3e09602d23ec regress/sys/kern/mqueue/Makefile
--- a/regress/sys/kern/mqueue/Makefile Sat Nov 03 05:19:49 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-# $NetBSD: Makefile,v 1.2 2009/07/19 02:31:19 rmind Exp $
-#
-PROG= mq_prio_test
-NOMAN= # defined
-WARNS= 4
-LDADD= -lrt
-
-regress:
- @/sbin/sysctl -w kern.mqueue.mq_prio_max=33
- @if ./$(PROG); then \
- echo "PASSED"; \
- else \
- echo "FAILED"; \
- fi
-
-.include <bsd.prog.mk>
diff -r 56b9fe91ca20 -r 3e09602d23ec regress/sys/kern/mqueue/mq_prio_test.c
--- a/regress/sys/kern/mqueue/mq_prio_test.c Sat Nov 03 05:19:49 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/* $NetBSD: mq_prio_test.c,v 1.2 2009/07/19 02:31:19 rmind Exp $ */
-
-/*
- * Test for POSIX message queue priority handling.
- *
- * This file is in the Public Domain.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <err.h>
-
-#include <mqueue.h>
-#include <assert.h>
-
-#define MQUEUE "/mq_prio_test"
-#define MQ_PRIO_BOUNDARY 31
-
-static void
-send_msgs(mqd_t mqfd)
-{
- char msg[2];
-
- msg[1] = '\0';
-
- msg[0] = 'a';
- if (mq_send(mqfd, msg, sizeof(msg), MQ_PRIO_BOUNDARY) == -1)
- err(EXIT_FAILURE, "mq_send 1");
-
- msg[0] = 'b';
- if (mq_send(mqfd, msg, sizeof(msg), MQ_PRIO_BOUNDARY + 1) == -1)
- err(EXIT_FAILURE, "mq_send 2");
-
- msg[0] = 'c';
- if (mq_send(mqfd, msg, sizeof(msg), MQ_PRIO_BOUNDARY) == -1)
- err(EXIT_FAILURE, "mq_send 3");
-
- msg[0] = 'd';
- if (mq_send(mqfd, msg, sizeof(msg), MQ_PRIO_BOUNDARY - 1) == -1)
- err(EXIT_FAILURE, "mq_send 4");
-
- msg[0] = 'e';
- if (mq_send(mqfd, msg, sizeof(msg), 0) == -1)
- err(EXIT_FAILURE, "mq_send 5");
-
- msg[0] = 'f';
- if (mq_send(mqfd, msg, sizeof(msg), MQ_PRIO_BOUNDARY + 1) == -1)
- err(EXIT_FAILURE, "mq_send 6");
-}
-
-static void
-receive_msgs(mqd_t mqfd)
-{
- struct mq_attr mqa;
- char *m;
- unsigned p;
- int len;
-
- if (mq_getattr(mqfd, &mqa) == -1) {
- err(EXIT_FAILURE, "mq_getattr");
- }
- len = mqa.mq_msgsize;
- m = calloc(1, len);
- if (m == NULL) {
- err(EXIT_FAILURE, "calloc");
- }
-
- if (mq_receive(mqfd, m, len, &p) == -1) {
- err(EXIT_FAILURE, "mq_receive 1");
- }
- assert(p == (MQ_PRIO_BOUNDARY + 1) && m[0] == 'b');
-
- if (mq_receive(mqfd, m, len, &p) == -1) {
- err(EXIT_FAILURE, "mq_receive 2");
- }
- assert(p == (MQ_PRIO_BOUNDARY + 1) && m[0] == 'f');
-
- if (mq_receive(mqfd, m, len, &p) == -1) {
- err(EXIT_FAILURE, "mq_receive 3");
- }
- assert(p == MQ_PRIO_BOUNDARY && m[0] == 'a');
-
- if (mq_receive(mqfd, m, len, &p) == -1) {
- err(EXIT_FAILURE, "mq_receive 4");
- }
- assert(p == MQ_PRIO_BOUNDARY && m[0] == 'c');
-
- if (mq_receive(mqfd, m, len, &p) == -1) {
- err(EXIT_FAILURE, "mq_receive 5");
- }
- assert(p == (MQ_PRIO_BOUNDARY - 1) && m[0] == 'd');
-
- if (mq_receive(mqfd, m, len, &p) == -1) {
- err(EXIT_FAILURE, "mq_receive 6");
- }
- assert(p == 0 && m[0] == 'e');
-
- free(m);
-}
-
-int
-main(int argc, char **argv)
-{
- mqd_t mqfd;
-
- (void)mq_unlink(MQUEUE);
-
- mqfd = mq_open(MQUEUE, O_RDWR | O_CREAT,
- S_IRUSR | S_IRWXG | S_IROTH, NULL);
- if (mqfd == -1)
- err(EXIT_FAILURE, "mq_open");
-
- send_msgs(mqfd);
- receive_msgs(mqfd);
-
- mq_close(mqfd);
-
- if (mq_unlink(MQUEUE) == -1)
- err(EXIT_FAILURE, "mq_unlink");
-
- return 0;
-}
Home |
Main Index |
Thread Index |
Old Index