diff options
author | ngie <ngie@FreeBSD.org> | 2015-11-16 05:28:14 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2015-11-16 05:28:14 +0000 |
commit | 0def4f1e60029398eea2f9c9e94747ee08754356 (patch) | |
tree | ffdb9f1156996c9b467e65b76efe74def3dd2545 /contrib/netbsd-tests/kernel | |
parent | c7ad5e15a51a2267b5d539ac5c899843431832eb (diff) | |
download | FreeBSD-src-0def4f1e60029398eea2f9c9e94747ee08754356.zip FreeBSD-src-0def4f1e60029398eea2f9c9e94747ee08754356.tar.gz |
Port contrib/netbsd-tests/kernel/t_mqueue.c to FreeBSD
- Add missing headers
- Ensure mqueuefs is loaded
- Make sure the mqueuefs path is absolute and relative to /
- Cast the result of mq_open returning -1 to (mqd_t) to mute a compiler
warning
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'contrib/netbsd-tests/kernel')
-rw-r--r-- | contrib/netbsd-tests/kernel/t_mqueue.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/kernel/t_mqueue.c b/contrib/netbsd-tests/kernel/t_mqueue.c index 2a03101..aa98d91 100644 --- a/contrib/netbsd-tests/kernel/t_mqueue.c +++ b/contrib/netbsd-tests/kernel/t_mqueue.c @@ -6,6 +6,13 @@ * This file is in the Public Domain. */ +#ifdef __FreeBSD__ +#include <sys/stat.h> +#include <fcntl.h> + +#include "freebsd_test_suite/macros.h" +#endif + #include <atf-c.h> #include <stdio.h> @@ -111,16 +118,28 @@ ATF_TC_BODY(mqueue, tc) char template[32]; char mq_name[64]; +#ifdef __FreeBSD__ + ATF_REQUIRE_KERNEL_MODULE("mqueuefs"); +#endif + strlcpy(template, "./t_mqueue.XXXXXX", sizeof(template)); tmpdir = mkdtemp(template); ATF_REQUIRE_MSG(tmpdir != NULL, "mkdtemp failed: %d", errno); +#ifdef __FreeBSD__ + snprintf(mq_name, sizeof(mq_name), "/t_mqueue"); +#else snprintf(mq_name, sizeof(mq_name), "%s/mq", tmpdir); +#endif mqd_t mqfd; mqfd = mq_open(mq_name, O_RDWR | O_CREAT, S_IRUSR | S_IRWXG | S_IROTH, NULL); +#ifdef __FreeBSD__ + ATF_REQUIRE_MSG(mqfd != (mqd_t)-1, "mq_open failed: %d", errno); +#else ATF_REQUIRE_MSG(mqfd != -1, "mq_open failed: %d", errno); +#endif send_msgs(mqfd); receive_msgs(mqfd); |