cr_tests: Add two testcases for epoll checkpoint/restart.
PATCH 1/1 cr_tests: Add two testcases for epoll checkpoint/restart.
The first, "empty" creates an empty epoll set, waits for checkpoint, and closes it afterwards.
The second test creates and epoll set, adds the write end of a pipe, waits for EPOLLOUT (writability) with epoll, writes, adds the read end, removes the write end, waits for EPOLLIN (readability), reads, and closes the epoll set.
Finally the patch adds a run.sh script much like the one for futexes. This one contains modifications which run all of the "subtests" of the pipe test as well.
--- Makefile | 2 +- epoll/Makefile | 21 ++++ epoll/empty.c | 83 ++++++++++++++ epoll/pipe.c | 338 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ epoll/run.sh | 135 ++++++++++++++++++++++ 5 files changed, 578 insertions(+), 1 deletions(-) create mode 100644 epoll/Makefile create mode 100644 epoll/empty.c create mode 100644 epoll/pipe.c create mode 100755 epoll/run.sh
Makefile +1 -1
@@ -1,5 +1,5 @@ SUBDIRS = libcrtest counterloop fileio simple cr-ipc-test userns ipc \ - sleep process-tree futex + sleep process-tree futex epoll targets = ns_exec
epoll/Makefile new file +21 -0
@@ -0,0 +1,21 @@ +.PHONY: clean all + +LIBS := ../libcrtest/libcrtest.a +CFLAGS := -Wall $(ARCHOPTS) -I./libfutex -I../ -I../libcrtest + +PROGS=empty pipe + +.PHONY: all clean + +all: $(PROGS) + +../libcrtest/libcrtest.a: ../libcrtest/libcrtest.h ../libcrtest/common.c + $(MAKE) -C ../libcrtest libcrtest.a + +$(PROGS): %: %.c $(LIBS) + gcc -Wall $(CFLAGS) -o $@ $< $(LIBS) + +clean: + rm -f $(PROGS) + rm -rf log.* checkpoint-ready checkpoint-done + $(MAKE) -C ../libcrtest clean
epoll/empty.c new file +83 -0
83 lines not on this page · raw message
epoll/pipe.c new file +338 -0
338 lines not on this page · raw message
epoll/run.sh new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
1.5.6.3
A message that is not in the archive (sent off-list or not yet received): 1250744745-1360-1-git-send-email-matthltc-r/[email protected]
Quoting Matt Helsley (matthltc-r/[email protected]):
...
epoll/Makefile line 4
Quoted 10 lines
epoll/Makefile new file +4
-0@@ -0,0 +1,21 @@ +.PHONY: clean all + +LIBS := ../libcrtest/libcrtest.a +CFLAGS := -Wall $(ARCHOPTS) -I./libfutex -I../ -I../libcrtest
libfutex?
You also mention futexes in several places where i think you mean epoll.
Quoted 36 lines
epoll/empty.c new file +30
-0@@ -0,0 +1,83 @@ +/* +* Make sure epoll sets stay empty across c/r. +* +* epoll create +* checkpoint +* close epoll +*/ +/* pretty standard stuff really */ +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <unistd.h> +#include <string.h> + +/* open() */ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +/* waitpid() and W* status macros */ +#include <sys/wait.h> + +/* epoll syscalls */ +#include <sys/epoll.h> + +#include "libcrtest/libcrtest.h" + +#define LOG_FILE "log.empty" +FILE *logfp =NULL ; +
epoll/empty.c line 40
Quoted 10 lines
epoll/empty.c new file +10
-0+/* +* Log output with a tag (INFO, WARN, FAIL, PASS) and a format. +* Adds information about the thread originating the message. +* +* Flush the log after every write to make sure we get consistent, and +* complete logs. +*/ +#define log (tag, fmt, ...) \ +do { \ + pid_t __tid = getpid(); \
gettid()?
Quoted 11 lines
epoll/empty.c new file +11
-0+ fprintf(logfp, ("%s: thread %d: " fmt), (tag), __tid, ##__VA_ARGS__ ); \ +fflush (logfp); \ +fsync (fileno (logfp)); \ +}while (0 ) + +/* like perror() except to the log */ +#define log_error (s) log("FAIL", "%s: %s\n", (s), strerror(errno)) + +int main (int argc,char **argv) +{ +int efd;
epoll/empty.c line 61
Quoted 10 lines
epoll/empty.c new file +10
-0+ +/* FIXME eventually stdio streams should be harmless */ +close (0 ); + logfp =fopen (LOG_FILE ,"w" ); +if (!logfp) { +perror ("could not open logfile" ); +exit (1 ); + } +dup2 (fileno (logfp),1 );/* redirect stdout and stderr to the log file */ +dup2 (fileno (logfp),2 );
Hmm? Does dup2 automatically close first? Manpage suggests not, so shouldn't you do so?
No other comments... will wait to apply until the updated kernel patches hit the list - and the tree.
thanks,
-serge