All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/10] cr_tests: Fix quote ordering typo in common.sh
@ 2010-03-15 23:00 Matt Helsley
       [not found] ` <69be886209c375c99b00b0745c1b0efdf334dcc3.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 18+ messages in thread
From: Matt Helsley @ 2010-03-15 23:00 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: Linux Containers

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 common.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/common.sh b/common.sh
index 28b87f1..dd230d0 100644
--- a/common.sh
+++ b/common.sh
@@ -7,7 +7,7 @@ verify_freezer()
 		echo "  mount -t cgroup -o freezer freezer /cgroup"
 		exit 1
 	fi
-	freezermountpoint=`echo $line | awk '{ print $2 '}`
+	freezermountpoint=`echo $line | awk '{ print $2 }'`
 	freezerdir=`mktemp -p $freezermountpoint -d` || \
 		(echo "mktemp for freezer failed"; exit 1)
 	export freezerdir="$freezerdir"
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 02/10] cr_tests: fileio: Fix do_child(i) call
       [not found] ` <69be886209c375c99b00b0745c1b0efdf334dcc3.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-03-15 23:00   ` Matt Helsley
       [not found]   ` <39d445e0d6bb5b1420daf672aa48ebabf8648ffe.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-15 23:00 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: Linux Containers

do_child() does not have an i parameter yet main calls do_child(i).
Clearly it's unused so just remove it.

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 fileio/fsetown1.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fileio/fsetown1.c b/fileio/fsetown1.c
index a30e870..57f9bb6 100644
--- a/fileio/fsetown1.c
+++ b/fileio/fsetown1.c
@@ -226,7 +226,7 @@ int main(int argc, char *argv[])
 	 */
 	pid = fork();
 	if (pid == 0)
-		do_child(i);
+		do_child();
 
 	if (pid < 0) {
 		fprintf(logfp, "%d: fork() failed, error %s\n", getpid(),
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 03/10] cr_tests: libcrtest: Check for NULL checkpoint labels
       [not found]   ` <39d445e0d6bb5b1420daf672aa48ebabf8648ffe.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-03-15 23:00     ` Matt Helsley
  2010-03-15 23:32     ` [PATCH 02/10] cr_tests: fileio: Fix do_child(i) call Nathan Lynch
  1 sibling, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-15 23:00 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: Linux Containers

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 libcrtest/labels.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libcrtest/labels.h b/libcrtest/labels.h
index f0137dc..f55721b 100644
--- a/libcrtest/labels.h
+++ b/libcrtest/labels.h
@@ -48,7 +48,7 @@ lbl: \
 	ret = action ; \
 \
 	if ((ckpt_op_num == op_num) || (ckpt_op_num == -1) || \
-	    (strcmp(ckpt_label, ___ ##lbl## _l) == 0)) \
+	    (ckpt_label && strcmp(ckpt_label, ___ ##lbl## _l) == 0)) \
 		do_ckpt(); \
 	if (ret < 0) { \
 		fprintf(logfp, "FAIL: %d\t%s: %s\n", \
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 04/10] cr_tests: Add dry-run
       [not found]   ` <0c89f69bdb86538762c5e8a5e03fab71bb2e3963.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-03-15 23:01     ` Matt Helsley
  0 siblings, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-15 23:01 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: Linux Containers

Make the cgroup freezer and do_ckpt() no-ops in order to do dry-runs of the
tests. This allows us to establish a baseline for those tests that can do
dry-runsi (i.e. have a dry-run option and use it to avoid restarting checkpoint
images).

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 libcrtest/common.c    |   17 ++++++++++++++---
 libcrtest/libcrtest.h |    2 +-
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/libcrtest/common.c b/libcrtest/common.c
index 6cfc9a9..c496889 100644
--- a/libcrtest/common.c
+++ b/libcrtest/common.c
@@ -42,6 +42,9 @@ int test_checkpoint_done(void)
 {
 	int rc;
 
+	rc = access(CKPT_DRY_RUN, F_OK);
+	if (rc == 0)
+		return 1;
 	rc = access(CKPT_DONE, F_OK);
 	if (rc == 0)
 		return 1;
@@ -57,8 +60,11 @@ int test_checkpoint_done(void)
 
 void set_checkpoint_ready()
 {
-	int fd;
+	int fd, rc;
 
+	rc = access(CKPT_DRY_RUN, F_OK);
+	if (rc == 0)
+		return;
 	fd = creat(CKPT_READY, 0666);
 	if (fd < 0) {
 		fprintf(logfp, "creat(%s) failed, %s\n", CKPT_READY,
@@ -75,7 +81,7 @@ void do_ckpt(void)
 
 	set_checkpoint_ready();
 
-	rc = access(CKPT_SKIP, F_OK);
+	rc = access(CKPT_DRY_RUN, F_OK);
 	if (rc == 0)
 		return;
 	else if (errno != ENOENT)
@@ -340,9 +346,14 @@ static void create_cgroup(char *grp)
  */
 int move_to_cgroup(char *subsys, char *grp, int pid)
 {
+	char fname[MAXPATH];
+	int rc;
+
+	rc = access(CKPT_DRY_RUN, F_OK);
+	if (rc == 0)
+		return 1;
 	if (strcmp(subsys, "freezer"))
 		return 0;
-	char fname[MAXPATH];
 	if (!freezer_mountpoint()) {
 		printf("freezer cgroup is not mounted.\n");
 		do_exit(1);
diff --git a/libcrtest/libcrtest.h b/libcrtest/libcrtest.h
index 7f8cfff..9723c74 100644
--- a/libcrtest/libcrtest.h
+++ b/libcrtest/libcrtest.h
@@ -3,7 +3,7 @@
 
 #define CKPT_READY		"checkpoint-ready"
 #define CKPT_DONE		"checkpoint-done"
-#define CKPT_SKIP		"checkpoint-skip"
+#define CKPT_DRY_RUN		"checkpoint-skip"
 #define TEST_DONE		"test-done"
 
 extern FILE *logfp;
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 05/10] cr_tests: Factor out close_all_fds()
       [not found]   ` <15d3e6bcb9a476add53b72998b45dd62a529871d.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-03-15 23:01     ` Matt Helsley
  2010-03-15 23:32     ` [PATCH 04/10] cr_tests: Add dry-run Nathan Lynch
  1 sibling, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-15 23:01 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: Linux Containers

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 fileio/fileio1.c      |   11 ++++-------
 fileio/filelease1.c   |    6 +-----
 fileio/filelease2.c   |    8 +-------
 fileio/filelock1.c    |    8 ++------
 fileio/filelock2.c    |    8 ++------
 fileio/fsetown1.c     |    8 ++------
 libcrtest/common.c    |   27 ++++++++++++++++++++++++++-
 libcrtest/libcrtest.h |    1 +
 8 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/fileio/fileio1.c b/fileio/fileio1.c
index 9a25176..fbce118 100644
--- a/fileio/fileio1.c
+++ b/fileio/fileio1.c
@@ -9,6 +9,8 @@
 #include <errno.h>
 #include <string.h>
 
+extern void close_all_fds(void);
+
 /*
  * Create a 'test-input' input file.
  *
@@ -244,9 +246,7 @@ enum test_mode {
 
 int main(int argc, char *argv[])
 {
-	int c;
-	int fd;
-	int i;
+	int fd, c;
 	char *srcfile;
 	char *destfile;
 	enum test_mode mode;
@@ -273,10 +273,7 @@ int main(int argc, char *argv[])
 	 * Cannot checkpoint process with open device files yet;
 	 */
 	printf("Closing stdio fds and writing messages to %s\n", log_fnam);
-	for (i=0; i<100; i++)  {
-		if (i != fileno(logfp))
-			close(i);
-	}
+	close_all_fds();
 
 	/*
 	 * Announce that we are now prepared for a checkpoint 
diff --git a/fileio/filelease1.c b/fileio/filelease1.c
index a6731b8..4d5ce5c 100644
--- a/fileio/filelease1.c
+++ b/fileio/filelease1.c
@@ -218,11 +218,7 @@ int main(int argc, char *argv[])
 
 	printf("%s: Closing stdio fds and writing messages to %s\n",
 			argv[0], LOG_FILE);
-
-	for (i=0; i<100; i++)  {
-		if (fileno(logfp) != i)
-			close(i);
-	}
+	close_all_fds();
 
 	setup_test_data();
 	event_fd1 = setup_notification();
diff --git a/fileio/filelease2.c b/fileio/filelease2.c
index bf18ad9..0e3ffe9 100644
--- a/fileio/filelease2.c
+++ b/fileio/filelease2.c
@@ -348,8 +348,6 @@ failed:
 
 int main(int argc, char *argv[])
 {
-	int i;
-
 	if (test_done()) {
 		printf("Remove %s before running test\n", TEST_DONE);
 		do_exit(1);
@@ -363,11 +361,7 @@ int main(int argc, char *argv[])
 
 	printf("%s: Closing stdio fds and writing messages to %s\n",
 			argv[0], LOG_FILE);
-
-	for (i=0; i<100; i++)  {
-		if (fileno(logfp) != i)
-			close(i);
-	}
+	close_all_fds();
 
 	setup_test_data();
 	event_fd1 = setup_notification();
diff --git a/fileio/filelock1.c b/fileio/filelock1.c
index 77060e9..248eb40 100644
--- a/fileio/filelock1.c
+++ b/fileio/filelock1.c
@@ -293,7 +293,7 @@ void usage(char *argv[])
 
 int main(int argc, char *argv[])
 {
-	int i, c;
+	int c;
 
 	logfp = fopen(LOG_FILE, "w");
 	if (!logfp) {
@@ -316,11 +316,7 @@ int main(int argc, char *argv[])
 
 	printf("%s: Closing stdio fds and writing messages to %s\n",
 			argv[0], LOG_FILE);
-
-	for (i=0; i<100; i++)  {
-		if (fileno(logfp) != i)
-			close(i);
-	}
+	close_all_fds();
 
 	setup_test_file();
 	event_fd1 = setup_notification();
diff --git a/fileio/filelock2.c b/fileio/filelock2.c
index 992aaee..e2e69ef 100644
--- a/fileio/filelock2.c
+++ b/fileio/filelock2.c
@@ -319,7 +319,7 @@ int create_child(int idx, void (*child_func)(int))
 
 int main(int argc, char *argv[])
 {
-	int i, c;
+	int c;
 
 	logfp = fopen(LOG_FILE, "w");
 	if (!logfp) {
@@ -345,11 +345,7 @@ int main(int argc, char *argv[])
 
 	printf("%s: Closing stdio fds and writing messages to %s\n",
 			argv[0], LOG_FILE);
-
-	for (i=0; i<100; i++)  {
-		if (fileno(logfp) != i)
-			close(i);
-	}
+	close_all_fds();
 
 	setup_test_file();
 	event_fd1 = setup_notification();
diff --git a/fileio/fsetown1.c b/fileio/fsetown1.c
index 57f9bb6..05ddcee 100644
--- a/fileio/fsetown1.c
+++ b/fileio/fsetown1.c
@@ -190,7 +190,7 @@ void usr1_handler(int sig)
 
 int main(int argc, char *argv[])
 {
-	int i, rc;
+	int rc;
 	int pid;
 
 	if (test_done()) {
@@ -206,11 +206,7 @@ int main(int argc, char *argv[])
 
 	printf("%s: Closing stdio fds and writing messages to %s\n",
 			argv[0], LOG_FILE);
-
-	for (i=0; i<100; i++)  {
-		if (fileno(logfp) != i)
-			close(i);
-	}
+	close_all_fds();
 
 	setup_test_data();
 	event_fd1 = setup_notification();
diff --git a/libcrtest/common.c b/libcrtest/common.c
index c496889..7672189 100644
--- a/libcrtest/common.c
+++ b/libcrtest/common.c
@@ -5,6 +5,7 @@
 #include <errno.h>
 #include <string.h>
 #include <malloc.h>
+#include <dirent.h>
 #include "libcrtest.h"
 #include <sys/eventfd.h>
 #include <sys/stat.h>
@@ -138,7 +139,7 @@ int do_wait(int num_children)
 	return 0;
 }
 
-static void do_sync(FILE *fp)
+void do_sync(FILE *fp)
 {
 	int rc;
 
@@ -148,6 +149,30 @@ static void do_sync(FILE *fp)
 		fprintf(logfp, "ERROR: fsync %s\n", strerror(errno));
 }
 
+void close_all_fds(void)
+{
+	/* Close everything but stdin, stdout, and stderr */
+	DIR *proc_self_fd;
+	struct dirent *dent;
+
+	proc_self_fd = opendir("/proc/self/fd");
+	if (!proc_self_fd) {
+		perror("opendir");
+		do_exit(1);
+	}
+
+	while ((dent = readdir(proc_self_fd)) != NULL) {
+		int fd;
+
+		if (sscanf(dent->d_name, "%12d", &fd) != 1)
+			continue;
+		if ((logfp && fileno(logfp) == fd) || \
+		    (dirfd(proc_self_fd) == fd))
+			continue;
+		close(fd);
+	}
+	closedir(proc_self_fd);
+}
 
 /*
  * Return 0 if data in srcfp matches data in destfp);
diff --git a/libcrtest/libcrtest.h b/libcrtest/libcrtest.h
index 9723c74..8e68261 100644
--- a/libcrtest/libcrtest.h
+++ b/libcrtest/libcrtest.h
@@ -15,6 +15,7 @@ struct record {
 
 typedef unsigned long long u64;
 
+extern void close_all_fds(void);
 extern void do_exit(int status);
 extern int test_done(void);
 extern int test_checkpoint_done();
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 06/10] cr_tests: Factor log() and log_error()
       [not found]   ` <e3169d2bce6c54899bc9a7658d983ac14712583f.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-03-15 23:01     ` Matt Helsley
  0 siblings, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-15 23:01 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: Linux Containers

Factor these macro definitions from epoll, futex, eventfd, and fs tests.

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 epoll/libeptest.h         |   19 +----------------
 eventfd/libeptest.h       |   19 +----------------
 fs/libfstest.h            |   20 +-----------------
 futex/libfutex/libfutex.h |   34 +++----------------------------
 libcrtest/libcrtest.h     |    9 ++++++++
 libcrtest/log.h           |   48 +++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 64 insertions(+), 85 deletions(-)
 create mode 100644 libcrtest/log.h

diff --git a/epoll/libeptest.h b/epoll/libeptest.h
index 990412d..2e4dbc3 100644
--- a/epoll/libeptest.h
+++ b/epoll/libeptest.h
@@ -7,27 +7,10 @@
 
 #include "libcrtest/libcrtest.h"
 #include "libcrtest/labels.h"
+#include "libcrtest/log.h"
 
 extern FILE *logfp;
 
-/*
- * 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(); \
-	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))
-
 /* Non-reentrant!! */
 const char * eflags(unsigned int events);
 
diff --git a/eventfd/libeptest.h b/eventfd/libeptest.h
index 3f1522e..c2f327d 100644
--- a/eventfd/libeptest.h
+++ b/eventfd/libeptest.h
@@ -7,23 +7,6 @@
 
 #include "libcrtest/libcrtest.h"
 #include "libcrtest/labels.h"
+#include "libcrtest/log.h"
 
 extern FILE *logfp;
-
-/*
- * 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(); \
-	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))
diff --git a/fs/libfstest.h b/fs/libfstest.h
index 238846b..143b0bc 100644
--- a/fs/libfstest.h
+++ b/fs/libfstest.h
@@ -7,25 +7,7 @@
 
 #include "libcrtest/libcrtest.h"
 #include "libcrtest/labels.h"
+#include "libcrtest/log.h"
 
-extern FILE *logfp;
-
-/*
- * 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(); \
-	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))
 
 #define HELLO "Hello world!\n"
diff --git a/futex/libfutex/libfutex.h b/futex/libfutex/libfutex.h
index 4fdb527..c5a176d 100644
--- a/futex/libfutex/libfutex.h
+++ b/futex/libfutex/libfutex.h
@@ -15,6 +15,10 @@
 
 #include "atomic.h"
 
+#define HAVE_LOG_LOCK 1
+#define HAVE_GETTID 1
+#include "libcrtest/log.h"
+
 #ifndef SYS_futex
 #ifdef __NR_futex
 #define SYS_futex __NR_futex
@@ -60,11 +64,6 @@ static inline long get_robust_list(pid_t pid, struct robust_list_head **rlist,
 	return syscall(__NR_get_robust_list, pid, rlist, len);
 }
 
-static inline pid_t gettid(void)
-{
-	return syscall(SYS_gettid);
-}
-
 static inline long tgkill(pid_t tgid, pid_t tid, int sig)
 {
 	return syscall(SYS_tgkill, tgid, tid, sig);
@@ -73,29 +72,4 @@ static inline long tgkill(pid_t tgid, pid_t tid, int sig)
 /* Allocate memory suitable for use as a futex */
 extern void *alloc_futex_mem(size_t sz);
 
-
-/* Thread-safe logging */
-extern FILE *logfp;
-extern atomic_t log_lock; /* initialize to = { 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 { \
-	int __tid = gettid(); \
-	while (atomic_cmpxchg(&log_lock, 0, __tid) != 0) {} \
-	fprintf(logfp, ("%s: thread %d: " fmt), (tag), __tid, ##__VA_ARGS__ ); \
-	fflush(logfp); \
-	fsync(fileno(logfp)); \
-	while (atomic_cmpxchg(&log_lock, __tid, 0) != __tid) {} \
-} while(0)
-
-/* like perror() except to the log */
-#define log_error(s) log("FAIL", "%s: %s\n", (s), strerror(errno))
-
 #endif /* __LIBFUTEX_H */
diff --git a/libcrtest/libcrtest.h b/libcrtest/libcrtest.h
index 8e68261..2ef5e1e 100644
--- a/libcrtest/libcrtest.h
+++ b/libcrtest/libcrtest.h
@@ -1,5 +1,7 @@
 #ifndef LIBCRTEST_H
 #define LIBCRTEST_H 1
+#include <unistd.h>
+#include <sys/syscall.h>
 
 #define CKPT_READY		"checkpoint-ready"
 #define CKPT_DONE		"checkpoint-done"
@@ -32,4 +34,11 @@ extern int move_to_cgroup(char *subsys, char *grp, int pid);
 extern void notify_one_event(int efd);
 extern void wait_for_events(int efd, u64 total);
 extern int setup_notification();
+
+static inline pid_t gettid(void)
+{
+	return syscall(SYS_gettid);
+}
+#define HAVE_GETTID 1
+
 #endif /* LIBCRTEST_H */
diff --git a/libcrtest/log.h b/libcrtest/log.h
new file mode 100644
index 0000000..0bb49b2
--- /dev/null
+++ b/libcrtest/log.h
@@ -0,0 +1,48 @@
+#ifndef LIBCRTEST_LOG_H
+#define LIBCRTEST_LOG_H
+
+extern FILE *logfp;
+
+#ifdef HAVE_LOG_LOCK
+/* Thread-safe logging */
+extern atomic_t log_lock; /* initialize to = { 0 }; !! */
+#endif
+
+#ifdef HAVE_LOG_LOCK
+#define lock_log() do { \
+	while (atomic_cmpxchg(&log_lock, 0, __tid) != 0) {} \
+} while(0)
+
+#define unlock_log() do { \
+	while (atomic_cmpxchg(&log_lock, __tid, 0) != __tid) {} \
+} while(0)
+#else
+#define lock_log() do {} while (0)
+#define unlock_log() do {} while (0)
+#endif
+
+#ifndef HAVE_GETTID
+#define gettid getpid
+#endif
+
+/*
+ * 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 = gettid(); \
+	lock_log(); \
+	fprintf(logfp, ("%s: thread %d: " fmt), (tag), __tid, ##__VA_ARGS__ ); \
+	fflush(logfp); \
+	fsync(fileno(logfp)); \
+	unlock_log(); \
+} while(0)
+
+/* like perror() except to the log */
+#define log_error(s) log("FAIL", "%s: %s\n", (s), strerror(errno))
+
+#endif /* LIBCRTEST_LOG_H */
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 07/10] cr_tests: eventfd: run.sh: Remove checkpoint-ready
       [not found]   ` <5b1bb7d32f49f39912aceddc22139fdb342d699f.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-03-15 23:01     ` Matt Helsley
  0 siblings, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-15 23:01 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: Linux Containers

Leaving this file would cause premature checkpoint of the next iteration.

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 eventfd/run.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/eventfd/run.sh b/eventfd/run.sh
index ada9920..910305f 100755
--- a/eventfd/run.sh
+++ b/eventfd/run.sh
@@ -76,6 +76,7 @@ for (( CURTEST = 0; CURTEST < NUMTESTS; CURTEST = CURTEST + 1 )); do
 		err_msg="BROK"
 
 		# Reset for the next iteration
+		rm "./checkpoint-ready"
 		touch "./checkpoint-done"
 		thaw
 		trap 'do_err; break 2' ERR EXIT
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 08/10] cr_tests: eventfd: rw: Fixup cgroup path sent to move_to_cgroup
       [not found]   ` <8bf27318f6f59bc4c03f21121f03995cbb4ce593.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-03-15 23:01     ` Matt Helsley
  0 siblings, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-15 23:01 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: Linux Containers

move_to_cgroup is too smart for full paths.

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 eventfd/run.sh |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/eventfd/run.sh b/eventfd/run.sh
index 910305f..1f29bed 100755
--- a/eventfd/run.sh
+++ b/eventfd/run.sh
@@ -49,7 +49,6 @@ for (( CURTEST = 0; CURTEST < NUMTESTS; CURTEST = CURTEST + 1 )); do
 	T=${TESTS[$CURTEST]}
 	((IMAX = $(../${T} -N)))
 	echo "INFO: Test ${T} does:"
-	../${T} -D | sed -e 's/^/INFO:/'
 	../${T} -L | sed -e 's/^/INFO:/'
 
 	TEST_LABELS=( $(../${T} -L | tail -n '+2' | cut -f 3) )
@@ -57,7 +56,7 @@ for (( CURTEST = 0; CURTEST < NUMTESTS; CURTEST = CURTEST + 1 )); do
 	# First we run the test taking checkpoints at all the labelled points
 	rm -f "./checkpoint-"{ready,done,skip}
 	echo "Running test: \"${T}\""
-	../${T} &
+	../${T} -f `basename $freezerdir` &
 	TEST_PID=$!
 
 	trap 'do_err; break 2' ERR EXIT
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 09/10] cr_tests: eventfd: Entirely new eventfd testcase
       [not found]   ` <9c200071918fda28567d801a2af825d36caa208a.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-03-15 23:01     ` Matt Helsley
  0 siblings, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-15 23:01 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: Linux Containers

Replace the existing eventfd01.c testcase with a simpler case which
does simple blocking and non-blocking reads and writes of the event
file.

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

Passes ckpt-v19-dev on x86-32. A subsequent patch will cause runall.sh
to execute this testcase.
---
 eventfd/Makefile    |   24 +--
 eventfd/eventfd01.c |  899 ---------------------------------------------------
 eventfd/libeptest.c |   16 -
 eventfd/libeptest.h |    4 -
 eventfd/module.mk   |   13 +
 eventfd/run.sh      |    2 +-
 eventfd/rw.c        |  215 ++++++++++++
 7 files changed, 232 insertions(+), 941 deletions(-)
 delete mode 100644 eventfd/eventfd01.c
 create mode 100644 eventfd/module.mk
 create mode 100644 eventfd/rw.c

diff --git a/eventfd/Makefile b/eventfd/Makefile
index 1bcd587..22c194e 100644
--- a/eventfd/Makefile
+++ b/eventfd/Makefile
@@ -1,23 +1,5 @@
-LTPROOT ?= ../ltp
 
-LIBS := ../libcrtest/libcrtest.a ./libeptest.a $(LTPROOT)/lib/libltp.a
-CFLAGS := -Wall $(ARCHOPTS) -I../ -I../libcrtest -I$(LTPROOT)/include
+.DEFAULT_GOAL := all
 
-PROGS=eventfd01
-
-.PHONY: all clean
-
-all: $(PROGS)
-
-../libcrtest/libcrtest.a: ../libcrtest/libcrtest.h ../libcrtest/common.c
-	$(MAKE) -C ../libcrtest libcrtest.a
-
-libeptest.a: libeptest.o libeptest.h
-	$(AR) cr libeptest.a libeptest.o
-
-$(PROGS): %: %.c $(LIBS)
-	$(CC) -Wall $(CFLAGS) -o $@ $< $(LIBS)
-
-clean:
-	rm -f *.o libeptest.a $(PROGS)
-	rm -rf cr_eventfd*
+%:
+	$(MAKE) -C ../ $@
diff --git a/eventfd/eventfd01.c b/eventfd/eventfd01.c
deleted file mode 100644
index 3d9aa6f..0000000
--- a/eventfd/eventfd01.c
+++ /dev/null
@@ -1,899 +0,0 @@
-/*
- *   Adapted for use as a checkpoint/restart testcase by
- *   				Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
- *
- *   Based on testcases/kernel/syscalls/eventfd01/eventfd01.c by:
- *   Copyright (c) 2008 Vijay Kumar B. <vijaykumar-NDm7FNP0skFg9hUCZPvPmw@public.gmane.org>
- *
- *   Based on testcases/kernel/syscalls/waitpid/waitpid01.c
- *   Original copyright message:
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- *   the GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * NAME
- *	eventfd01.c
- *
- * DESCRIPTION
- *      Test cases for eventfd syscall.
- *
- * USAGE:  <for command-line>
- *      eventfd01 [-c n] [-i n] [-I x] [-P x] [-t]
- *      where,  -c n : Run n copies concurrently.
- *              -i n : Execute test n times.
- *              -I x : Execute test for x seconds.
- *              -P x : Pause for x seconds between iterations.
- *              -t   : Turn on syscall timing.
- *
- * History
- *	07/2008 Vijay Kumar
- *		Initial Version.
- *
- * Restrictions
- *	None
- */
-
-#include "config.h"
-
-#include <sys/select.h>
-#include <sys/signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <poll.h>
-
-#include <test.h>
-#include <usctest.h>
-#include <linux_syscall_numbers.h>
-
-#ifdef HAVE_LIBAIO_H
-#include <libaio.h>
-#endif
-
-#define LOG_FILE "log.eventfd01"
-#include "libeptest.h"
-
-static void setup(void);
-static void cleanup(void);
-
-TCID_DEFINE(eventfd01);
-int TST_TOTAL = 15;
-extern int Tst_count;
-
-/*
- * A LABEL is a point in the program we can goto where it's interesting to
- * checkpoint. These enable us to have a set of labels that can be specified
- * on the commandline.
- */
-const char __attribute__((__section__(".LABELs"))) *first_label = "<start>";
-int op_num = 0;
-
-static int myeventfd(unsigned int initval, int flags)
-{
-	/* eventfd2 uses FLAGS but eventfd doesn't take FLAGS. */
-#if defined (__NR_eventfd)
-	return syscall(__NR_eventfd, initval);
-#else
-	errno = ENOSYS;
-	return -1;
-#endif
-}
-
-/*
- * clear_counter() - clears the counter by performing a dummy read
- * @fd: the eventfd
- *
- * RETURNS:
- * 0 on success, and -1 on failure
- */
-static int clear_counter(int fd)
-{
-	uint64_t dummy;
-	int ret;
-
-	ret = read(fd, &dummy, sizeof(dummy));
-	if (ret == -1) {
-		if (errno != EAGAIN) {
-			tst_resm(TINFO|TERRNO, "error clearing counter");
-			return -1;
-		}
-	}
-
-	return 0;
-}
-
-/*
- * set_counter() - sets the count to specified value
- * @fd: the eventfd
- * @val: the value to be set
- *
- * Clears the counter and sets the counter to @val.
- *
- * RETURNS:
- * 0 on success, -1 on failure
- */
-static int set_counter(int fd, uint64_t val)
-{
-	int ret;
-
-	ret = clear_counter(fd);
-	if (ret == -1) {
-		return -1;
-	}
-
-	ret = write(fd, &val, sizeof(val));
-	if (ret == -1) {
-		tst_resm(TINFO|TERRNO, "error setting counter value");
-		return -1;
-	}
-
-	return 0;
-}
-
-/*
- * Test whether the current value of the counter matches @required.
- */
-static void read_test(int fd, uint64_t required)
-{
-	int ret;
-	uint64_t val;
-
-
-label(read_test, ret, read(fd, &val, sizeof(val)));
-	if (ret == -1) {
-		tst_resm(TBROK|TERRNO, "error reading eventfd");
-		return;
-	}
-
-	if (val == required)
-		tst_resm(TPASS, "counter value matches required");
-	else
-		tst_resm(TFAIL, "counter value mismatch: "
-			 "required: %"PRIu64", got: %"PRIu64, required, val);
-}
-
-/*
- * Test whether read returns with error EAGAIN when counter is at 0.
- */
-static void read_eagain_test(int fd)
-{
-	int ret;
-	uint64_t val;
-
-label(read_eagain_test_clear, ret, clear_counter(fd));
-	if (ret == -1) {
-		tst_resm(TBROK, "error clearing counter");
-		return;
-	}
-
-label(read_eagain_test_read, ret, read(fd, &val, sizeof(val)));
-	if (ret == -1) {
-		if (errno == EAGAIN)
-			tst_resm(TPASS, "read failed with EAGAIN as expected");
-		else
-			tst_resm(TFAIL|TERRNO, "read failed (wanted EAGAIN)");
-	} else {
-		tst_resm(TFAIL, "read returned with %d", ret);
-	}
-}
-
-/*
- * Test whether writing to counter works.
- */
-static void write_test(int fd)
-{
-	int ret;
-	uint64_t val;
-
-	val = 12;
-
-label(write_test, ret, set_counter(fd, val));
-	if (ret == -1) {
-		tst_resm(TBROK, "error setting counter value to %"PRIu64, val);
-		return;
-	}
-
-	read_test(fd, val);
-}
-
-/*
- * Test whether write returns with error EAGAIN when counter is at
- * (UINT64_MAX - 1).
- */
-static void write_eagain_test(int fd)
-{
-	int ret;
-	uint64_t val;
-
-label(write_eagain_test_set, ret, set_counter(fd, UINT64_MAX - 1));
-	if (ret == -1) {
-		tst_resm(TBROK, "error setting counter value to UINT64_MAX-1");
-		return;
-	}
-
-	val = 1;
-label(write_eagain_write, ret, write(fd, &val, sizeof(val)));
-	if (ret == -1) {
-		if (errno == EAGAIN)
-			tst_resm(TPASS, "write failed with EAGAIN as expected");
-		else
-			tst_resm(TFAIL, "write failed (wanted EAGAIN)");
-	} else {
-		tst_resm(TFAIL, "write returned with %d", ret);
-	}
-}
-
-/*
- * Test whether read returns with error EINVAL, if buffer size is less
- * than 8 bytes.
- */
-static void read_einval_test(int fd)
-{
-	uint32_t invalid;
-	int ret;
-
-label(read_einval_test_read,
-	ret, read(fd, &invalid, sizeof(invalid)));
-	if (ret == -1) {
-		if (errno == EINVAL) {
-			tst_resm(TPASS, "read failed with EINVAL as expected");
-		} else {
-			tst_resm(TFAIL|TERRNO, "read failed (wanted EINVAL)");
-		}
-	} else {
-		tst_resm(TFAIL, "read returned with %d", ret);
-	}
-}
-
-/*
- * Test whether write returns with error EINVAL, if buffer size is
- * less than 8 bytes.
- */
-static void write_einval_test(int fd)
-{
-	uint32_t invalid;
-	int ret;
-
-label(write_einval_test_write,
-	ret, write(fd, &invalid, sizeof(invalid)));
-	if (ret == -1) {
-		if (errno == EINVAL) {
-			tst_resm(TPASS, "write failed with EINVAL as expected");
-		} else {
-			tst_resm(TFAIL|TERRNO, "write failed (wanted EINVAL)");
-		}
-	} else {
-		tst_resm(TFAIL, "write returned with %d", ret);
-	}
-}
-
-/*
- * Test wheter write returns with error EINVAL, when the written value
- * is 0xFFFFFFFFFFFFFFFF.
- */
-static void write_einval2_test(int fd)
-{
-	int ret;
-	uint64_t val;
-
-label(write_einval2_test_clear,
-	ret, clear_counter(fd));
-	if (ret == -1) {
-		tst_resm(TBROK, "error clearing counter");
-		return;
-	}
-
-	val = 0xffffffffffffffffLL;
-label(write_einval2_test_write,
-	ret, write(fd, &val, sizeof(val)));
-	if (ret == -1) {
-		if (errno == EINVAL)
-			tst_resm(TPASS, "write failed with EINVAL as expected");
-		else
-			tst_resm(TFAIL|TERRNO, "write failed (wanted EINVAL)");
-	} else {
-		tst_resm(TFAIL, "write returned with %d", ret);
-	}
-}
-
-/*
- * Test whether readfd is set by select when counter value is
- * non-zero.
- */
-static void readfd_set_test(int fd)
-{
-	int ret;
-	fd_set readfds;
-	struct timeval timeout = { 0, 0 };
-	uint64_t non_zero = 10;
-
-	FD_ZERO(&readfds);
-	FD_SET(fd, &readfds);
-
-label(readfd_set_test_set,
-      ret, set_counter(fd, non_zero));
-	if (ret == -1) {
-		tst_resm(TBROK, "error setting counter value to %"PRIu64,
-			 non_zero);
-		return;
-	}
-
-label(read_fd_set_test_select,
-      ret, select(fd + 1, &readfds, NULL, NULL, &timeout));
-	if (ret == -1) {
-		/* EINTR cannot occur, since we don't block. */
-		tst_resm(TBROK|TERRNO, "select() failed");
-		return;
-	}
-
-	if (FD_ISSET(fd, &readfds))
-		tst_resm(TPASS, "fd is set in readfds");
-	else
-		tst_resm(TFAIL, "fd is not set in readfds");
-}
-
-/*
- * Test whether readfd is not set by select when counter value is
- * zero.
- */
-static void readfd_not_set_test(int fd)
-{
-	int ret;
-	fd_set readfds;
-	struct timeval timeout = { 0, 0 };
-
-	FD_ZERO(&readfds);
-	FD_SET(fd, &readfds);
-
-label(readfd_not_set_test_clear,
-	ret, clear_counter(fd));
-	if (ret == -1) {
-		tst_resm(TBROK, "error clearing counter");
-		return;
-	}
-
-label(readfd_not_set_test_select,
-      ret, select(fd + 1, &readfds, NULL, NULL, &timeout));
-	if (ret == -1) {
-		/* EINTR cannot occur, since we don't block. */
-		tst_resm(TBROK|TERRNO, "select() failed");
-		return;
-	}
-
-	if (!FD_ISSET(fd, &readfds))
-		tst_resm(TPASS, "fd is not set in readfds");
-	else
-		tst_resm(TFAIL, "fd is set in readfds");
-}
-
-/*
- * Test whether writefd is set by select when counter value is not the
- * maximum counter value.
- */
-static void writefd_set_test(int fd)
-{
-	int ret;
-	fd_set writefds;
-	struct timeval timeout = { 0, 0 };
-	uint64_t non_max = 10;
-
-	FD_ZERO(&writefds);
-	FD_SET(fd, &writefds);
-
-label(writefd_set_test_set,
-	ret, set_counter(fd, non_max));
-	if (ret == -1) {
-		tst_resm(TBROK, "error setting counter value to %"PRIu64, non_max);
-		return;
-	}
-
-label(writefd_set_test_select,
-	ret, select(fd + 1, NULL, &writefds, NULL, &timeout));
-	if (ret == -1) {
-		/* EINTR cannot occur, since we don't block. */
-		tst_resm(TBROK|TERRNO, "select: error getting fd status");
-		return;
-	}
-
-	if (FD_ISSET(fd, &writefds))
-		tst_resm(TPASS, "fd is set in writefds");
-	else
-		tst_resm(TFAIL, "fd is not set in writefds");
-}
-
-/*
- * Test whether writefd is not set by select when counter value is at
- * (UINT64_MAX - 1).
- */
-static void writefd_not_set_test(int fd)
-{
-	int ret;
-	fd_set writefds;
-	struct timeval timeout = { 0, 0 };
-
-	FD_ZERO(&writefds);
-	FD_SET(fd, &writefds);
-
-label(writefd_not_set_test_set,
-	ret, set_counter(fd, UINT64_MAX - 1));
-	if (ret == -1) {
-		tst_resm(TBROK, "error setting counter value to UINT64_MAX-1");
-		return;
-	}
-
-label(writefd_not_set_test_select,
-	ret, select(fd + 1, NULL, &writefds, NULL, &timeout));
-	if (ret == -1) {
-		/* EINTR cannot occur, since we don't block. */
-		tst_resm(TBROK|TERRNO, "select: error getting fd status");
-		return;
-	}
-
-	if (!FD_ISSET(fd, &writefds))
-		tst_resm(TPASS, "fd is not set in writefds");
-	else
-		tst_resm(TFAIL, "fd is set in writefds");
-}
-
-/*
- * Test whether counter update in child is reflected in the parent.
- */
-static void child_inherit_test(int fd)
-{
-	uint64_t val;
-	pid_t cpid;
-	int ret;
-	int status;
-	uint64_t to_parent = 0xdeadbeef;
-	uint64_t dummy;
-
-	cpid = fork();
-	if (cpid == -1)
-		tst_resm(TBROK|TERRNO, "fork() failed");
-	if (cpid != 0) {
-		/* Parent */
-		ret = wait(&status);
-		if (ret == -1) {
-			tst_resm(TBROK, "error getting child exit status");
-			return;
-		}
-
-		if (WEXITSTATUS(status) == 1) {
-			tst_resm(TBROK, "counter value write not "
-				 "succesful in child");
-			return;
-		}
-
-		ret = read(fd, &val, sizeof(val));
-		if (ret == -1) {
-			tst_resm(TBROK|TERRNO, "error reading eventfd");
-			return;
-		}
-
-		if (val == to_parent)
-			tst_resm(TPASS, "counter value write from "
-				 "child successful");
-		else
-			tst_resm(TFAIL, "counter value write in child "
-				 "failed");
-	} else {
-		/* Child */
-		ret = read(fd, &dummy, sizeof(dummy));
-		if (ret == -1 && errno != EAGAIN) {
-			tst_resm(TWARN|TERRNO, "error clearing counter");
-			exit(1);
-		}
-
-		ret = write(fd, &to_parent, sizeof(to_parent));
-		if (ret == -1) {
-			tst_resm(TWARN|TERRNO, "error writing eventfd");
-			exit(1);
-		}
-
-		exit(0);
-	}
-}
-
-#ifdef HAVE_IO_SET_EVENTFD
-/*
- * Test whether counter overflow is detected and handled correctly.
- *
- * It is not possible to directly overflow the counter using the
- * write() syscall. Overflows occur when the counter is incremented
- * from kernel space, in an irq context, when it is not possible to
- * block the calling thread of execution.
- *
- * The AIO subsystem internally uses eventfd mechanism for
- * notification of completion of read or write requests. In this test
- * we trigger a counter overflow, by setting the counter value to the
- * max possible value initially. When the AIO subsystem notifies
- * through the eventfd counter, the counter overflows.
- *
- * NOTE: If the the counter starts from an initial value of 0, it will
- * take decades for an overflow to occur. But since we set the initial
- * value to the max possible counter value, we are able to cause it to
- * overflow with a single increment.
- *
- * When the counter overflows, the following are tested
- *   1. Check whether POLLERR event occurs in poll() for the eventfd.
- *   2. Check whether readfd_set/writefd_set is set in select() for the
-        eventfd.
- *   3. The counter value is UINT64_MAX.
- */
-static int trigger_eventfd_overflow(int evfd, int *fd, io_context_t * ctx)
-{
-	int ret;
-	struct iocb iocb;
-	struct iocb *iocbap[1];
-	static char buf[4 * 1024];
-
-	*ctx = 0;
-	ret = io_setup(16, ctx);
-	if (ret < 0) {
-		errno = -ret;
-		tst_resm(TINFO|TERRNO, "io_setup error");
-		return -1;
-	}
-
-	*fd = open("testfile", O_RDWR | O_CREAT, 0644);
-	if (*fd == -1) {
-		tst_resm(TINFO|TERRNO, "open(testfile) failed");
-		goto err_io_destroy;
-	}
-
-	ret = set_counter(evfd, UINT64_MAX - 1);
-	if (ret == -1) {
-		tst_resm(TINFO, "error setting counter to UINT64_MAX-1");
-		goto err_close_file;
-	}
-
-	io_prep_pwrite(&iocb, *fd, buf, sizeof(buf), 0);
-	io_set_eventfd(&iocb, evfd);
-
-	iocbap[0] = &iocb;
-	ret = io_submit(*ctx, 1, iocbap);
-	if (ret < 0) {
-		errno = -ret;
-		tst_resm(TINFO|TERRNO, "error submitting iocb");
-		goto err_close_file;
-	}
-
-	return 0;
-
-      err_close_file:
-	close(*fd);
-
-      err_io_destroy:
-	io_destroy(*ctx);
-
-	return -1;
-}
-
-static void cleanup_overflow(int fd, io_context_t ctx)
-{
-	close(fd);
-	io_destroy(ctx);
-}
-
-static void overflow_select_test(int evfd)
-{
-	struct timeval timeout = { 10, 0 };
-	fd_set readfds;
-	int fd;
-	io_context_t ctx;
-	int ret;
-
-	ret = trigger_eventfd_overflow(evfd, &fd, &ctx);
-	if (ret == -1) {
-		tst_resm(TBROK, "error triggering eventfd overflow");
-		return;
-	}
-
-	FD_ZERO(&readfds);
-	FD_SET(evfd, &readfds);
-	ret = select(evfd + 1, &readfds, NULL, NULL, &timeout);
-	if (ret == -1) {
-		tst_resm(TBROK|TERRNO, "error getting evfd status with select");
-		goto err_cleanup;
-	}
-
-	if (FD_ISSET(evfd, &readfds))
-		tst_resm(TPASS, "read fd set as expected");
-	else
-		tst_resm(TFAIL, "read fd not set");
-
-      err_cleanup:
-	cleanup_overflow(fd, ctx);
-}
-
-static void overflow_poll_test(int evfd)
-{
-	struct pollfd pollfd;
-	int fd;
-	io_context_t ctx;
-	int ret;
-
-	ret = trigger_eventfd_overflow(evfd, &fd, &ctx);
-	if (fd == -1) {
-		tst_resm(TBROK, "error triggering eventfd overflow");
-		return;
-	}
-
-	pollfd.fd = evfd;
-	pollfd.events = POLLIN;
-	pollfd.revents = 0;
-	ret = poll(&pollfd, 1, 10000);
-	if (ret == -1) {
-		tst_resm(TBROK|TERRNO, "error getting evfd status with poll");
-		goto err_cleanup;
-	}
-	if (pollfd.revents & POLLERR)
-		tst_resm(TPASS, "POLLERR occurred as expected");
-	else
-		tst_resm(TFAIL, "POLLERR did not occur");
-
-      err_cleanup:
-	cleanup_overflow(fd, ctx);
-}
-
-static void overflow_read_test(int evfd)
-{
-	uint64_t count;
-	io_context_t ctx;
-	int fd;
-	int ret;
-
-	ret = trigger_eventfd_overflow(evfd, &fd, &ctx);
-	if (ret == -1) {
-		tst_resm(TBROK, "error triggering eventfd overflow");
-		return;
-	}
-
-	ret = read(evfd, &count, sizeof(count));
-	if (ret == -1) {
-		tst_resm(TBROK|TERRNO, "error reading eventfd");
-		goto err_cleanup;
-	}
-
-	if (count == UINT64_MAX)
-		tst_resm(TPASS, "overflow occurred as expected");
-	else
-		tst_resm(TFAIL, "overflow did not occur");
-
-      err_cleanup:
-	cleanup_overflow(fd, ctx);
-}
-#else
-static void overflow_select_test(int evfd)
-{
-	tst_resm(TCONF, "eventfd support is not available in AIO subsystem");
-}
-
-static void overflow_poll_test(int evfd)
-{
-	tst_resm(TCONF, "eventfd support is not available in AIO subsystem");
-}
-
-static void overflow_read_test(int evfd)
-{
-	tst_resm(TCONF, "eventfd support is not available in AIO subsystem");
-}
-#endif
-
-int opt_do_print_labels = 0;
-int opt_do_print_max_op_num = 0;
-int opt_do_print_descr = 0;
-char *op_num_arg = NULL;
-
-const char *descr = "";
-
-void usage(FILE *pout)
-{
-	fprintf(pout, "\neventfd01 [-L] [-N] [-l LABEL] [-n NUM] [-e] [-t]\n"
-"%s\n"
-"\n"
-"\t-L\tPrint the valid LABELs in order and exit.\n"
-"\t-l\tWait for checkpoint at LABEL.\n"
-"\t-i\tPrint one-line test description.\n"
-"\t-N\tPrint the maximum label number and exit.\n"
-"\t-n\tWait for checkpoint at NUM.\n"
-"\n"
-"You may only specify one LABEL or NUM and you may not specify both.\n"
-"Label numbers are integers in the range 0-%d\n"
-"Valid label numbers and their corresponding LABELs are:\n", descr,
-		num_labels - 1);
-	print_labels(pout);
-}
-
-void help(void)
-{
-	usage(stdout);
-}
-
-char *freezer = "1";
-
-option_t ckpt_opts[] = {
-	{
-		.option = "f:",
-		.flag	= NULL,
-		.arg	= freezer,
-	},
-	{
-		.option = "L",
-		.flag   = &opt_do_print_labels,
-		.arg    = NULL,
-	},
-	{
-		.option = "N",
-		.flag   = &opt_do_print_max_op_num,
-		.arg    = NULL,
-	},
-	{
-		.option = "l:",
-		.flag   = NULL,
-		.arg    = (char**)&ckpt_label,
-	},
-	{
-		.option = "n:",
-		.flag   = NULL,
-		.arg    = &op_num_arg,
-	},
-	{
-		.option = "D",
-		.flag   = &opt_do_print_descr,
-		.arg    = NULL,
-	},
-	{ NULL, NULL, NULL }
-};
-
-int main(int argc, char **argv)
-{
-	char *msg;		/* message returned from parse_opts */
-	int fd, ret;
-	uint64_t einit = 10;
-
-	/* parse standard options */
-	msg = parse_opts(argc, argv, ckpt_opts, help);
-	if (msg != NULL) {
-		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-		/* NOTREACHED */
-	}
-
-	if (opt_do_print_labels) {
-		print_labels(stdout);
-		exit(EXIT_SUCCESS);
-	} else if (opt_do_print_max_op_num) {
-		printf("%d\n", num_labels - 1);
-		exit(EXIT_SUCCESS);
-	} else if (opt_do_print_descr) {
-		printf("%s\n", descr);
-		exit(EXIT_SUCCESS);
-	}
-
-	if (op_num_arg) {
-		if ((sscanf(op_num_arg, "%d", &ckpt_op_num) < 1) ||
-		    (ckpt_op_num < 0) ||
-		    (ckpt_op_num >= num_labels)) {
-			fprintf(stderr, "Option -n requires an argument in the range 0-%d. Got %d\n", num_labels - 1, ckpt_op_num);
-			usage(stderr);
-			exit(EXIT_FAILURE);
-		}
-	}
-
-	setup();
-	/* FIXME eventually stdio streams should be harmless */
-	close(0);
-	logfp = fopen(LOG_FILE, "w+");
-	if (!logfp) {
-		perror("could not open logfile");
-		exit(1);
-	}
-	/* redirect stdout and stderr to the log file */
-	if (dup2(fileno(logfp), 1) < 0) {
-		log_error("dup2(logfp, 1)");
-		goto out;
-	}
-	if (dup2(fileno(logfp), 2) < 0) {
-		log_error("dup2(logfp, 2)");
-		goto out;
-	}
-	if (!move_to_cgroup("freezer", freezer, getpid())) {
-		log_error("move_to_cgroup");
-		goto out;
-	}
-
-
-	Tst_count = 0;
-
-	fd = myeventfd(einit, 0);
-	if (fd == -1)
-		tst_brkm(TBROK|TERRNO, cleanup, "error creating eventfd");
-label(fcntl_non_blocking,
-	ret, fcntl(fd, F_SETFL, O_NONBLOCK));
-	if (ret == -1)
-		tst_brkm(TBROK|TERRNO, cleanup, "error setting non-block mode");
-
-	read_test(fd, einit);
-	read_eagain_test(fd);
-	write_test(fd);
-	write_eagain_test(fd);
-	read_einval_test(fd);
-	write_einval_test(fd);
-	write_einval2_test(fd);
-	readfd_set_test(fd);
-	readfd_not_set_test(fd);
-	writefd_set_test(fd);
-	writefd_not_set_test(fd);
-	child_inherit_test(fd);
-	overflow_select_test(fd);
-	overflow_poll_test(fd);
-	overflow_read_test(fd);
-
-	close(fd);
-out:
-	cleanup();
-	/* NOT REACHED */
-
-	return 0;
-}
-
-/*
- * setup() - performs all ONE TIME setup for this test
- */
-static void setup(void)
-{
-	/* capture signals */
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	if (tst_kvercmp(2, 6, 22) < 0)
-		tst_brkm(TCONF, cleanup, "2.6.22 or greater kernel required");
-
-	/* Create a temporary directory & chdir there */
-	/*tst_tmpdir();*/
-	/* Pause if that option was specified
-	 * TEST_PAUSE contains the code to fork the test with the -c option.
-	TEST_PAUSE;
-	 */
-	ckpt_label = last_label;
-	ckpt_op_num = -1; /* or num_labels? */
-}
-
-/*
- * cleanup() - performs all ONE TIME cleanup for this test
- */
-static void cleanup(void)
-{
-	/*
-	 * print timing stats if that option was specified.
-	 * print errno log if that option was specified.
-	 */
-	TEST_CLEANUP;
-
-	/* tst_rmdir();*/
-	fclose(logfp);
-	/* exit with return code appropriate for results */
-	tst_exit();
- /*NOTREACHED*/}
-
-const char __attribute__((__section__(".LABELs"))) *last_label  = "<end>";
diff --git a/eventfd/libeptest.c b/eventfd/libeptest.c
index 073b596..ba55232 100644
--- a/eventfd/libeptest.c
+++ b/eventfd/libeptest.c
@@ -1,19 +1,3 @@
 #include <errno.h>
 
 #include "libeptest.h"
-
-FILE *logfp = NULL;
-
-void print_labels(FILE *pout)
-{
-	int i;
-
-	if (num_labels > 0)
-		fprintf(pout, "\tNUM\tLABEL\n");
-	for (i = 0; i < num_labels; i++)
-		fprintf(pout, "\t%d\t%s\n", i, labels(i));
-}
-
-/* The spot (LABEL or label number) where we should test checkpoint/restart */
-char const *ckpt_label;
-int ckpt_op_num = 0;
diff --git a/eventfd/libeptest.h b/eventfd/libeptest.h
index c2f327d..88b9f33 100644
--- a/eventfd/libeptest.h
+++ b/eventfd/libeptest.h
@@ -3,10 +3,6 @@
 #include <stdio.h>
 #include <unistd.h>
 
-#include <sys/epoll.h>
-
 #include "libcrtest/libcrtest.h"
 #include "libcrtest/labels.h"
 #include "libcrtest/log.h"
-
-extern FILE *logfp;
diff --git a/eventfd/module.mk b/eventfd/module.mk
new file mode 100644
index 0000000..54a8631
--- /dev/null
+++ b/eventfd/module.mk
@@ -0,0 +1,13 @@
+local_dir := eventfd
+local_progs := $(addprefix $(local_dir)/,rw)
+
+sources += $(addprefix $(local_dir)/,libeptest.c)
+progs += $(local_progs)
+test_clean += $(addprefix $(local_dir)/,*.o cr_eventfd*)
+
+$(local_progs): CFLAGS += $(ARCHOPTS)
+$(local_progs): CPPFLAGS += -I .
+$(local_progs): LDFLAGS += -Xlinker -dT -Xlinker libcrtest/labels.lds
+$(local_progs): libcrtest/libcrtest.a $(local_dir)/libeptest.o
+
+extra_clean += $(local_dir)/libeptest.o $(local_dir)/libeptest.a
diff --git a/eventfd/run.sh b/eventfd/run.sh
index 1f29bed..de01cd3 100755
--- a/eventfd/run.sh
+++ b/eventfd/run.sh
@@ -23,7 +23,7 @@ fi ) | grep -E '^[[:space:]]*CONFIG_EVENTFD=y' > /dev/null 2>&1
 	exit 1
 }
 
-TESTS=( eventfd01 )
+TESTS=( rw )
 
 #make ${TESTS[@]}
 
diff --git a/eventfd/rw.c b/eventfd/rw.c
new file mode 100644
index 0000000..9076f83
--- /dev/null
+++ b/eventfd/rw.c
@@ -0,0 +1,215 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <limits.h>
+#include <getopt.h>
+
+/* open() */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+/* waitpid() and W* status macros */
+#include <sys/wait.h>
+
+#include <sys/eventfd.h>
+#include <sys/time.h> /* itimers */
+
+#include "libeptest.h"
+
+#define LOG_FILE	"log.rw"
+
+void usage(FILE *pout, const char *prog)
+{
+	fprintf(pout, "\n%s [-L] [-N] [-h|--help] [-l LABEL] [-n NUM]\n"
+"Create an empty epoll set.\n"
+"\n"
+"\t-L\tPrint the valid LABELs in order and exit.\n"
+"\t-l\tWait for checkpoint at LABEL.\n"
+"\t-N\tPrint the maximum label number and exit.\n"
+"\t-n\tWait for checkpoint at NUM.\n"
+"\n"
+"You may only specify one LABEL or NUM and you may not specify both.\n"
+"Label numbers are integers in the range 0-%d\n"
+"Valid label numbers and their corresponding LABELs are:\n", prog,
+		num_labels - 1);
+	print_labels(pout);
+}
+
+const struct option long_options[] = {
+	{ "print-labels",	0, 0, 'L'},
+	{ "print-max-label-no",	0, 0, 'N'},
+	{ "help",		0, 0, 'h'},
+	{ "label",		1, 0, 'l'},
+	{ "num",		1, 0, 'n'},
+	{ "freezer",		1, 0, 'f'},
+	{0, 0, 0, 0},
+};
+
+char *freezer = "1";
+
+void parse_label_args(int argc, char **argv)
+{
+	ckpt_op_num = -1;
+	ckpt_label = NULL;
+	while (1) {
+		int c;
+		c = getopt_long(argc, argv, "f:LNhl:n:", long_options, NULL);
+		if (c == -1)
+			break;
+		switch(c) {
+			case 'f':
+				freezer = optarg;
+				printf("Will enter freezer cgroup %s\n", freezer);
+				break;
+			case 'L':
+				print_labels(stdout);
+				exit(EXIT_SUCCESS);
+				break;
+			case 'N':
+				printf("%d\n", num_labels - 1);
+				exit(EXIT_SUCCESS);
+				break;
+			case 'h':
+				usage(stdout, argv[0]);
+				exit(EXIT_SUCCESS);
+				break;
+			case 'l':
+				ckpt_label = optarg;
+				break;
+			case 'n':
+				if ((sscanf(optarg, "%d", &ckpt_op_num) < 1) ||
+				    (ckpt_op_num < 0) ||
+				    (ckpt_op_num >= num_labels)) {
+					fprintf(stderr, "Option -n requires an argument in the range 0-%d. Got %d\n", num_labels - 1, ckpt_op_num);
+					usage(stderr, argv[0]);
+					exit(EXIT_FAILURE);
+				}
+				break;
+			default: /* unknown option */
+				break;
+		}
+	}
+}
+
+void setup_test_output(const char *log_filename)
+{
+	/* FIXME eventually stdio streams should be harmless */
+	close(0);
+	logfp = fopen(log_filename, "w+");
+	if (!logfp) {
+		perror("could not open logfile");
+		exit(1);
+	}
+	/* redirect stdout and stderr to the log file */
+	if (dup2(fileno(logfp), 1) < 0) {
+		log_error("dup2(logfp, 1)");
+		exit(2);
+	}
+	if (dup2(fileno(logfp), 2) < 0) {
+		log_error("dup2(logfp, 2)");
+		exit(3);
+	}
+}
+
+static int evfd;
+
+void handler(int signo)
+{
+	u64 v;
+
+	/*
+	 * We don't actually do anything here -- just handle EINTR errnos
+	 * synchronously.
+	 */
+	log("INFO", "Received SIGLARM\n");
+	v = 1;
+	write(evfd, &v, sizeof(v));
+}
+
+int main (int argc, char **argv)
+{
+	struct itimerval one_second_timeout = {
+		.it_value = { .tv_sec = 1, .tv_usec = 0 },
+		.it_interval = { .tv_sec = 0, .tv_usec = 0 }
+	};
+	u64 v;
+	int ret = 0;
+	int op_num = 0;
+
+	parse_label_args(argc, argv);
+	setup_test_output(LOG_FILE);
+
+	if (!move_to_cgroup("freezer", freezer, getpid())) {
+		log_error("move_to_cgroup");
+		exit(4);
+	}
+	log("INFO", "entered cgroup %s\n", freezer);
+
+label(create_eventfd,
+	evfd, eventfd(0, EFD_CLOEXEC));
+	if (evfd < 0) {
+		log_error("eventfd(EFD_CLOEXEC)");
+		fclose(logfp);
+		exit(EXIT_FAILURE);
+	}
+
+	/* Set up a timer to bring us out of a blocking read */
+	signal(SIGALRM, handler);
+label(prepare_blocking_read_timeout,
+      ret, setitimer(ITIMER_REAL, &one_second_timeout, NULL));
+
+	/* Do the blocking read. */
+	log("INFO", "Doing blocking read. Quick! Somebody checkpoint me!\n");
+	ret = read(evfd, &v, sizeof(v));
+	if (v != 1) {
+		log("FAIL", "Expected event value %lld, got %lld\n",
+		    1ULL, v);
+		fclose(logfp);
+		exit(EXIT_FAILURE);
+	}
+
+	/* Write to the event counter and get the result. */
+	v = 31337;
+label(write_event1, ret, write(evfd, &v, sizeof(v)));
+	v = 0;
+label(read_event1, ret, read(evfd, &v, sizeof(v)));
+	if (v != 31337) {
+		log("FAIL", "Expected event value %lld, got %lld\n",
+		    31337ULL, v);
+		fclose(logfp);
+		exit(EXIT_FAILURE);
+	}
+
+	/* Now test non-blocking operation */
+label(set_nonblocking, ret, fcntl(evfd, F_SETFL, O_NONBLOCK));
+	ret = read(evfd, &v, sizeof(v));
+	if ((ret != -1) || (errno != EAGAIN)) {
+		log("FAIL", "Expected EAGAIN from non-blocking read.\n");
+		fclose(logfp);
+		exit(EXIT_FAILURE);
+	}
+
+	v = 1;
+label(write_event2, ret, write(evfd, &v, sizeof(v)));
+	v = 0;
+label(read_event2, ret, read(evfd, &v, sizeof(v)));
+	if (v != 1) {
+		log("FAIL", "Expected event value %lld, got %lld\n",
+		    1ULL, v);
+		fclose(logfp);
+		exit(EXIT_FAILURE);
+	}
+	ret = EXIT_SUCCESS;
+
+out:
+	if (close(evfd) < 0) {
+		perror("close()");
+		fclose(logfp);
+		exit(EXIT_FAILURE);
+	}
+	fclose(logfp);
+	exit(ret);
+}
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 10/10] cr_tests: eventfd: Run eventfd from runall.sh
       [not found]   ` <54f3b58880621b4bcf2ae094e755dcfa5c87390f.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-03-15 23:01     ` Matt Helsley
  0 siblings, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-15 23:01 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: Linux Containers

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 runall.sh |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/runall.sh b/runall.sh
index 6b07d17..3ed9720 100644
--- a/runall.sh
+++ b/runall.sh
@@ -112,6 +112,12 @@ bash runtest.sh
 update_totals $? taskfs
 popd
 
+echo "Running eventfd tests"
+pushd eventfd
+bash run.sh
+update_totals $? eventfd
+popd
+
 echo $passed out of $total test groups passed.
 echo "Failed tests:"
 for t in ${failed[@]}; do echo " $t"; done
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 02/10] cr_tests: fileio: Fix do_child(i) call
       [not found]   ` <39d445e0d6bb5b1420daf672aa48ebabf8648ffe.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  2010-03-15 23:00     ` [PATCH 03/10] cr_tests: libcrtest: Check for NULL checkpoint labels Matt Helsley
@ 2010-03-15 23:32     ` Nathan Lynch
       [not found]       ` <1268695929.4397.134.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  1 sibling, 1 reply; 18+ messages in thread
From: Nathan Lynch @ 2010-03-15 23:32 UTC (permalink / raw)
  To: Matt Helsley; +Cc: Linux Containers

On Mon, 2010-03-15 at 16:00 -0700, Matt Helsley wrote:
> do_child() does not have an i parameter yet main calls do_child(i).
> Clearly it's unused so just remove it.
> 
> Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> ---
>  fileio/fsetown1.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fileio/fsetown1.c b/fileio/fsetown1.c
> index a30e870..57f9bb6 100644
> --- a/fileio/fsetown1.c
> +++ b/fileio/fsetown1.c
> @@ -226,7 +226,7 @@ int main(int argc, char *argv[])
>  	 */
>  	pid = fork();
>  	if (pid == 0)
> -		do_child(i);
> +		do_child();

Change the definition of do_child from

void do_child()

to 

void do_child(void)

please?

wait_for_child and setup_test_data need the same treatment.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 04/10] cr_tests: Add dry-run
       [not found]   ` <15d3e6bcb9a476add53b72998b45dd62a529871d.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  2010-03-15 23:01     ` [PATCH 05/10] cr_tests: Factor out close_all_fds() Matt Helsley
@ 2010-03-15 23:32     ` Nathan Lynch
       [not found]       ` <1268695941.4397.135.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  1 sibling, 1 reply; 18+ messages in thread
From: Nathan Lynch @ 2010-03-15 23:32 UTC (permalink / raw)
  To: Matt Helsley; +Cc: Linux Containers

On Mon, 2010-03-15 at 16:01 -0700, Matt Helsley wrote:
> Make the cgroup freezer and do_ckpt() no-ops in order to do dry-runs of the
> tests. This allows us to establish a baseline for those tests that can do
> dry-runsi (i.e. have a dry-run option and use it to avoid restarting checkpoint
> images).

I like this idea and I think this will be useful.

However, is there a reason we shouldn't freeze and thaw as part of the
dry run?  I don't have strong feelings on this; just thinking we should
try to minimize the differences in behavior and code coverage.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 02/10] cr_tests: fileio: Fix do_child(i) call
       [not found]       ` <1268695929.4397.134.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2010-03-16  6:04         ` Matt Helsley
       [not found]           ` <20100316060410.GD3037-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
  2010-03-16  6:48         ` [PATCH 02/10] cr_tests: fileio: Fix do_child(i) call Matt Helsley
  1 sibling, 1 reply; 18+ messages in thread
From: Matt Helsley @ 2010-03-16  6:04 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: Linux Containers

On Mon, Mar 15, 2010 at 06:32:09PM -0500, Nathan Lynch wrote:
> On Mon, 2010-03-15 at 16:00 -0700, Matt Helsley wrote:
> > do_child() does not have an i parameter yet main calls do_child(i).
> > Clearly it's unused so just remove it.
> > 
> > Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> > ---
> >  fileio/fsetown1.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/fileio/fsetown1.c b/fileio/fsetown1.c
> > index a30e870..57f9bb6 100644
> > --- a/fileio/fsetown1.c
> > +++ b/fileio/fsetown1.c
> > @@ -226,7 +226,7 @@ int main(int argc, char *argv[])
> >  	 */
> >  	pid = fork();
> >  	if (pid == 0)
> > -		do_child(i);
> > +		do_child();
> 
> Change the definition of do_child from
> 
> void do_child()
> 
> to 
> 
> void do_child(void)
> 
> please?

Sure. I'll attach another copy of the patch with the change in a reply
to this.

> wait_for_child and setup_test_data need the same treatment.

OK.

Thanks!

Cheers,
	-Matt Helsley

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 04/10] cr_tests: Add dry-run
       [not found]       ` <1268695941.4397.135.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2010-03-16  6:25         ` Matt Helsley
  2010-03-16  6:54         ` Matt Helsley
  1 sibling, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-16  6:25 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: Linux Containers

On Mon, Mar 15, 2010 at 06:32:21PM -0500, Nathan Lynch wrote:
> On Mon, 2010-03-15 at 16:01 -0700, Matt Helsley wrote:
> > Make the cgroup freezer and do_ckpt() no-ops in order to do dry-runs of the
> > tests. This allows us to establish a baseline for those tests that can do
> > dry-runsi (i.e. have a dry-run option and use it to avoid restarting checkpoint
> > images).
> 
> I like this idea and I think this will be useful.
> 
> However, is there a reason we shouldn't freeze and thaw as part of the
> dry run?  I don't have strong feelings on this; just thinking we should
> try to minimize the differences in behavior and code coverage.

Well, honestly my main reason was lazyness :). Also, the goal was to make
those portions of the testcases which should be like no-ops actually be
no-ops. Then we know the test case is very likely testing the feature 
(e.g. eventfd) we want and not some prepatory step needed for checkpoint.

But your point is reasonable. We may want to know that the tests are frozen/
thawed correctly without doing checkpoint. It also probably requires fewer
changes so I think, at least as a first step I'll go with your suggestion.

Again, I'll reply with the changed patch rather than repost the series
unless someone tells me they'd prefer otherwise.

Cheers,
	-Matt Helsley

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 02/10] cr_tests: fileio: Fix do_child(i) call
       [not found]       ` <1268695929.4397.134.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2010-03-16  6:04         ` Matt Helsley
@ 2010-03-16  6:48         ` Matt Helsley
  1 sibling, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-16  6:48 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: Linux Containers

do_child() does not have an i parameter yet main calls do_child(i).
Clearly it's unused so just remove it.

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

diff --git a/fileio/fsetown1.c b/fileio/fsetown1.c
index a30e870..9d55e59 100644
--- a/fileio/fsetown1.c
+++ b/fileio/fsetown1.c
@@ -120,7 +120,7 @@ void test_owner(int fd, int exp_owner)
 	return;
 }
 
-void do_child()
+void do_child(void)
 {
 	int rc;
 	char buf[16];
@@ -226,7 +226,7 @@ int main(int argc, char *argv[])
 	 */
 	pid = fork();
 	if (pid == 0)
-		do_child(i);
+		do_child();
 
 	if (pid < 0) {
 		fprintf(logfp, "%d: fork() failed, error %s\n", getpid(),

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 11/10] cr_tests: fileio: Add missing voids
       [not found]           ` <20100316060410.GD3037-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
@ 2010-03-16  6:51             ` Matt Helsley
  0 siblings, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-16  6:51 UTC (permalink / raw)
  To: Matt Helsley; +Cc: Linux Containers, Nathan Lynch

On Mon, Mar 15, 2010 at 11:04:10PM -0700, Matt Helsley wrote:
> On Mon, Mar 15, 2010 at 06:32:09PM -0500, Nathan Lynch wrote:
> > 
> > Change the definition of do_child from
> > 
> > void do_child()
> > 
> > to 
> > 
> > void do_child(void)
> > 
> > please?

<done in separate, reposting of the patch>

> > wait_for_child and setup_test_data need the same treatment.

Below.

Cheers,
	-Matt Helsley
---

cr_tests: fileio: Fix style nit -- missing voids

Fill the voids with more void.

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

diff --git a/fileio/fsetown1.c b/fileio/fsetown1.c
index 56a97d5..59431a0 100644
--- a/fileio/fsetown1.c
+++ b/fileio/fsetown1.c
@@ -29,7 +29,7 @@ void iohandler(int sig)
 	got_sigio = 1;
 }
 
-static void wait_for_child()
+static void wait_for_child(void)
 {
 	int rc;
 	int status;
@@ -162,7 +162,7 @@ void do_child(void)
  * Create a pipe that the child will try to read from and parent will
  * write to.
  */
-void setup_test_data()
+void setup_test_data(void)
 {
 	int rc;

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 04/10] cr_tests: Add dry-run
       [not found]       ` <1268695941.4397.135.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2010-03-16  6:25         ` Matt Helsley
@ 2010-03-16  6:54         ` Matt Helsley
  1 sibling, 0 replies; 18+ messages in thread
From: Matt Helsley @ 2010-03-16  6:54 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: Linux Containers


cr_tests: Add dry-run

Make the cgroup freezer and do_ckpt() no-ops in order to do dry-runs of the
tests. This allows us to establish a baseline for those tests that can do
dry-runsi (i.e. have a dry-run option and use it to avoid restarting checkpoint
images).

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: Nathan Lynch <ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>

Changelog for v2:
	Removed hunk which short-circuited move_to_cgroup() as suggested
		by Nathan Lynch. (Oops, left a minor cleanup.)

diff --git a/libcrtest/common.c b/libcrtest/common.c
index 6cfc9a9..68f4de5 100644
--- a/libcrtest/common.c
+++ b/libcrtest/common.c
@@ -42,6 +42,9 @@ int test_checkpoint_done(void)
 {
 	int rc;
 
+	rc = access(CKPT_DRY_RUN, F_OK);
+	if (rc == 0)
+		return 1;
 	rc = access(CKPT_DONE, F_OK);
 	if (rc == 0)
 		return 1;
@@ -57,8 +60,11 @@ int test_checkpoint_done(void)
 
 void set_checkpoint_ready()
 {
-	int fd;
+	int fd, rc;
 
+	rc = access(CKPT_DRY_RUN, F_OK);
+	if (rc == 0)
+		return;
 	fd = creat(CKPT_READY, 0666);
 	if (fd < 0) {
 		fprintf(logfp, "creat(%s) failed, %s\n", CKPT_READY,
@@ -75,7 +81,7 @@ void do_ckpt(void)
 
 	set_checkpoint_ready();
 
-	rc = access(CKPT_SKIP, F_OK);
+	rc = access(CKPT_DRY_RUN, F_OK);
 	if (rc == 0)
 		return;
 	else if (errno != ENOENT)
@@ -340,9 +346,10 @@ static void create_cgroup(char *grp)
  */
 int move_to_cgroup(char *subsys, char *grp, int pid)
 {
+	char fname[MAXPATH];
+
 	if (strcmp(subsys, "freezer"))
 		return 0;
-	char fname[MAXPATH];
 	if (!freezer_mountpoint()) {
 		printf("freezer cgroup is not mounted.\n");
 		do_exit(1);
diff --git a/libcrtest/libcrtest.h b/libcrtest/libcrtest.h
index 7f8cfff..9723c74 100644
--- a/libcrtest/libcrtest.h
+++ b/libcrtest/libcrtest.h
@@ -3,7 +3,7 @@
 
 #define CKPT_READY		"checkpoint-ready"
 #define CKPT_DONE		"checkpoint-done"
-#define CKPT_SKIP		"checkpoint-skip"
+#define CKPT_DRY_RUN		"checkpoint-skip"
 #define TEST_DONE		"test-done"
 
 extern FILE *logfp;

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 01/10] cr_tests: Fix quote ordering typo in common.sh
       [not found] ` <69be886209c375c99b00b0745c1b0efdf334dcc3.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
                     ` (8 preceding siblings ...)
       [not found]   ` <15d3e6bcb9a476add53b72998b45dd62a529871d.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2010-03-16 14:13   ` Serge E. Hallyn
  9 siblings, 0 replies; 18+ messages in thread
From: Serge E. Hallyn @ 2010-03-16 14:13 UTC (permalink / raw)
  To: Matt Helsley; +Cc: Linux Containers

Quoting Matt Helsley (matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org):
> Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

all applied, thanks.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2010-03-16 14:13 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-15 23:00 [PATCH 01/10] cr_tests: Fix quote ordering typo in common.sh Matt Helsley
     [not found] ` <69be886209c375c99b00b0745c1b0efdf334dcc3.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-15 23:00   ` [PATCH 02/10] cr_tests: fileio: Fix do_child(i) call Matt Helsley
     [not found]   ` <39d445e0d6bb5b1420daf672aa48ebabf8648ffe.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-15 23:00     ` [PATCH 03/10] cr_tests: libcrtest: Check for NULL checkpoint labels Matt Helsley
2010-03-15 23:32     ` [PATCH 02/10] cr_tests: fileio: Fix do_child(i) call Nathan Lynch
     [not found]       ` <1268695929.4397.134.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-03-16  6:04         ` Matt Helsley
     [not found]           ` <20100316060410.GD3037-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2010-03-16  6:51             ` [PATCH 11/10] cr_tests: fileio: Add missing voids Matt Helsley
2010-03-16  6:48         ` [PATCH 02/10] cr_tests: fileio: Fix do_child(i) call Matt Helsley
     [not found]   ` <0c89f69bdb86538762c5e8a5e03fab71bb2e3963.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-15 23:01     ` [PATCH 04/10] cr_tests: Add dry-run Matt Helsley
     [not found]   ` <e3169d2bce6c54899bc9a7658d983ac14712583f.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-15 23:01     ` [PATCH 06/10] cr_tests: Factor log() and log_error() Matt Helsley
     [not found]   ` <5b1bb7d32f49f39912aceddc22139fdb342d699f.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-15 23:01     ` [PATCH 07/10] cr_tests: eventfd: run.sh: Remove checkpoint-ready Matt Helsley
     [not found]   ` <8bf27318f6f59bc4c03f21121f03995cbb4ce593.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-15 23:01     ` [PATCH 08/10] cr_tests: eventfd: rw: Fixup cgroup path sent to move_to_cgroup Matt Helsley
     [not found]   ` <9c200071918fda28567d801a2af825d36caa208a.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-15 23:01     ` [PATCH 09/10] cr_tests: eventfd: Entirely new eventfd testcase Matt Helsley
     [not found]   ` <54f3b58880621b4bcf2ae094e755dcfa5c87390f.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-15 23:01     ` [PATCH 10/10] cr_tests: eventfd: Run eventfd from runall.sh Matt Helsley
     [not found]   ` <15d3e6bcb9a476add53b72998b45dd62a529871d.1268694050.git.matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-15 23:01     ` [PATCH 05/10] cr_tests: Factor out close_all_fds() Matt Helsley
2010-03-15 23:32     ` [PATCH 04/10] cr_tests: Add dry-run Nathan Lynch
     [not found]       ` <1268695941.4397.135.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-03-16  6:25         ` Matt Helsley
2010-03-16  6:54         ` Matt Helsley
2010-03-16 14:13   ` [PATCH 01/10] cr_tests: Fix quote ordering typo in common.sh Serge E. Hallyn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.