diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-12-13 20:27:46 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-12-13 20:27:46 +0000 |
commit | b8a76a26d7efee89c5b8137ee8c47ded132f83c9 (patch) | |
tree | 6dd819ceb3ef5a8b6b4cd08d72439d0dc034a7ca /tools/regression/kqueue/common.h | |
parent | 0266d1d9310dadac44284b66cf2f8bb3740f75df (diff) | |
download | FreeBSD-src-b8a76a26d7efee89c5b8137ee8c47ded132f83c9.zip FreeBSD-src-b8a76a26d7efee89c5b8137ee8c47ded132f83c9.tar.gz |
Add Mark Heily's libkqueue test suite as a general kqueue test suite to
tools/regression. It tests a number of aspects of kqueue behavior,
although not all currently pass (possibly bugs in the test suite?).
Submitted by: Mark Heily <mark at heily.com>
Obtained from: svn://mark.heily.com/libkqueue/trunk/test (r114)
Diffstat (limited to 'tools/regression/kqueue/common.h')
-rw-r--r-- | tools/regression/kqueue/common.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/tools/regression/kqueue/common.h b/tools/regression/kqueue/common.h new file mode 100644 index 0000000..aada778 --- /dev/null +++ b/tools/regression/kqueue/common.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2009 Mark Heily <mark@heily.com> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $FreeBSD$ + */ + +#ifndef _COMMON_H +#define _COMMON_H + + +#if HAVE_ERR_H +# include <err.h> +#else +# define err(rc,msg,...) do { perror(msg); exit(rc); } while (0) +# define errx(rc,msg,...) do { puts(msg); exit(rc); } while (0) +#endif +#include <errno.h> +#include <fcntl.h> +#include <signal.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <stdint.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <unistd.h> + +#include <sys/event.h> + +#include "config.h" + +extern char *cur_test_id; +int vnode_fd; + +extern const char * kevent_to_str(struct kevent *); +struct kevent * kevent_get(int); + + +void kevent_cmp(struct kevent *, struct kevent *); + +void +kevent_add(int kqfd, struct kevent *kev, + uintptr_t ident, + short filter, + u_short flags, + u_int fflags, + intptr_t data, + void *udata); + +/* DEPRECATED: */ +#define KEV_CMP(kev,_ident,_filter,_flags) do { \ + if (kev.ident != (_ident) || \ + kev.filter != (_filter) || \ + kev.flags != (_flags)) \ + err(1, "kevent mismatch: got [%d,%d,%d] but expecting [%d,%d,%d]", \ + (int)_ident, (int)_filter, (int)_flags,\ + (int)kev.ident, kev.filter, kev.flags);\ +} while (0); + +/* Checks if any events are pending, which is an error. */ +extern void test_no_kevents(void); + +extern void test_begin(const char *); +extern void success(void); + +#endif /* _COMMON_H */ |