[PATCH 2/9] cr_tests: fs: Add a do_ckpt utility

Matt Helsley matthltc at us.ibm.com
Fri Feb 19 18:18:50 PST 2010


Makes ./checkpoint-ready, waits for ./checkpoint-done, and exits.
This utility will be useful in a python test script to ensure that
we're not testing the checkpointability of python scripts and
instead we're checkpointing simple C tasks.

Signed-off-by: Matt Helsley <matthltc at us.ibm.com>
---
 fs/do_ckpt.c |   34 ++++++++++++++++++++++++++++++++++
 fs/module.mk |    2 +-
 2 files changed, 35 insertions(+), 1 deletions(-)
 create mode 100644 fs/do_ckpt.c

diff --git a/fs/do_ckpt.c b/fs/do_ckpt.c
new file mode 100644
index 0000000..6c96cae
--- /dev/null
+++ b/fs/do_ckpt.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <getopt.h>
+
+/* open() */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define LOG_FILE	"log.do_ckpt"
+#include "libfstest.h"
+
+int main(int argc, char** argv)
+{
+	/* 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);
+	if (!move_to_cgroup("freezer", "1", getpid())) {
+		log_error("move_to_cgroup");
+		exit(2);
+	}
+
+	do_ckpt();
+	exit(EXIT_SUCCESS);
+}
diff --git a/fs/module.mk b/fs/module.mk
index d0a9f26..1af5815 100644
--- a/fs/module.mk
+++ b/fs/module.mk
@@ -1,5 +1,5 @@
 local_dir := fs
-local_progs := $(addprefix $(local_dir)/, file dir)
+local_progs := $(addprefix $(local_dir)/, file dir do_ckpt)
 
 sources += $(addprefix $(local_dir)/,libeptest.c)
 progs += $(local_progs)
-- 
1.6.3.3



More information about the Containers mailing list