[Devel] [PATCH 04/10] cr_tests: Add dry-run

Matt Helsley matthltc at us.ibm.com
Mon Mar 15 23:54:17 PDT 2010


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 at us.ibm.com>
Cc: Nathan Lynch <ntl at pobox.com>

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;
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list