Linux Container Development
 help / color / mirror / Atom feed
From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org
Cc: Containers
	<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
Subject: [PATCH 04/11] Rename run-filelock1 to run-fcntltests.sh
Date: Fri, 29 Jan 2010 12:42:10 -0800	[thread overview]
Message-ID: <20100129204210.GC26721@us.ibm.com> (raw)
In-Reply-To: <20100129202842.GA25490-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>


From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Date: Mon, 25 Jan 2010 18:26:57 -0800
Subject: [PATCH 04/11] Rename run-filelock1 to run-fcntltests.sh

run-filelock1 wrapper could share lot of code with other fcntl tests.
Remove hardcoded names, rename it run-fcntltests.sh and pass in
test_case name as an argument.

Signed-off-by: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
---
 fileio/run-fcntltests.sh |  236 ++++++++++++++++++++++++++++++++++++++++++++++
 fileio/run-filelock1.sh  |  223 +-------------------------------------------
 fileio/runtests.sh       |    2 +-
 3 files changed, 238 insertions(+), 223 deletions(-)
 create mode 100755 fileio/run-fcntltests.sh

diff --git a/fileio/run-fcntltests.sh b/fileio/run-fcntltests.sh
new file mode 100755
index 0000000..0b168e9
--- /dev/null
+++ b/fileio/run-fcntltests.sh
@@ -0,0 +1,236 @@
+#!/bin/bash
+
+source ../common.sh
+
+if [ $# -ne 1 ]; then
+	echo "Usage: $0 <test-case>";
+	exit 1;
+fi
+
+test_case=$1;
+
+if [ ! -x $test_case ]; then
+	echo "$0: Test case \'$test_case\' does not exist / not executable ?"
+	exit 1;
+fi
+
+dir=`mktemp -p . -d -t cr_${test_case}_XXXXXXX` || (echo "mktemp failed"; exit 1)
+
+# NOTE: As of ckpt-v15-dev, the --container option to 'ckpt' causes this
+#	test to fail with "container not isolated" message due to the
+#	log-file being shared between the application threads.
+#
+CHECKPOINT="`which checkpoint` --container"
+RESTART=`which restart`
+ECHO="/bin/echo -e"
+
+TEST_CMD="../$test_case"
+TEST_ARGS=""
+TEST_LOG="logs.d/log.${test_case}"
+SCRIPT_LOG="logs.d/log.run-${test_case}"
+TEST_PID_FILE="pid.${test_case}";
+
+SNAPSHOT_DIR="snap1.d"
+
+TEST_DONE="test-done"
+CHECKPOINT_FILE="checkpoint-${test_case}";
+CHECKPOINT_READY="checkpoint-ready"
+CHECKPOINT_DONE="checkpoint-done"
+
+LOGS_DIR="logs.d"
+DATA_DIR="data.d"
+
+NS_EXEC="../../ns_exec"
+NS_EXEC_ARGS="-cgpuimP $TEST_PID_FILE"
+
+checkpoint()
+{
+	local pid=$1
+
+	$ECHO "\t- Checkpoint: $CHECKPOINT $pid \> $CHECKPOINT_FILE"
+	$CHECKPOINT $pid > $CHECKPOINT_FILE
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		$ECHO "***** FAIL: Checkpoint of $pid failed"
+		ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
+		exit 1;
+	fi
+}
+
+function check_for_failure()
+{
+	grep --binary-files=text FAIL $PWD/$TEST_LOG > /dev/null 2>&1
+	if [ $? -eq 0 ]; then
+		$ECHO "\t***** Application FAILED after restart" >> $SCRIPT_LOG
+		$ECHO "\t***** See $TEST_LOG for details" >> $SCRIPT_LOG
+
+		$ECHO "\t***** Application FAILED after restart"
+		$ECHO "\tSee $PWD/$TEST_LOG for details"
+		exit 1;
+	fi
+}
+
+function wait_for_checkpoint_ready()
+{
+	# Wait for test to finish setup
+	while [ ! -f $CHECKPOINT_READY ]; do
+		$ECHO "\t- Waiting for $CHECKPOINT_READY"
+		check_for_failure;
+		sleep 1;
+	done;
+}
+
+function create_container()
+{
+	local pid;
+
+	cmdline="$NS_EXEC $NS_EXEC_ARGS -- $TEST_CMD $TEST_ARGS"
+
+	$ECHO "\t- Creating container:"
+	$ECHO "\t- $cmdline"
+
+	$cmdline &
+
+	wait_for_checkpoint_ready;
+
+	# Find global pid of container-init
+	pid=`cat $TEST_PID_FILE`;
+	if [  "x$pid" == "x" ]; then
+		$ECHO "***** FAIL: Invalid container-init pid $pid"
+		ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
+		exit 1
+	fi
+	$ECHO "Created container with pid $pid" >> $SCRIPT_LOG
+}
+
+function restart_container
+{
+	local ret;
+
+	cmdline="$RESTART --pids --pidns --wait"
+	$ECHO "\t- $cmdline"
+
+	sleep 1
+
+	$cmdline < $CHECKPOINT_FILE >> $SCRIPT_LOG 2>&1 &
+	ret=$?
+
+	if [ $ret -ne 0 ]; then
+		$ECHO "***** FAIL: Restart of $pid failed"
+		ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
+		exit 1;
+	fi
+
+}
+
+function create_fs_snapshot()
+{
+	# Prepare for snapshot
+	if [ -d $SNAPSHOT_DIR ]; then
+		rm -rf ${SNAPSHOT_DIR}.prev
+		mv $SNAPSHOT_DIR ${SNAPSHOT_DIR}.prev
+		mkdir $SNAPSHOT_DIR
+	fi
+
+	# Snapshot the log files
+	cp ${LOGS_DIR}/* $SNAPSHOT_DIR
+}
+
+function restore_fs_snapshot()
+{
+	# Restore the snapshot after the main process has been killed
+	/bin/cp ${SNAPSHOT_DIR}/* $LOGS_DIR
+}
+
+cd $dir
+echo "Current directory: `pwd`"
+
+if [ ! -d $LOGS_DIR ]; then
+	mkdir $LOGS_DIR
+fi
+
+if [ ! -d $DATA_DIR ]; then
+	mkdir $DATA_DIR
+fi
+
+if [ ! -d $SNAPSHOT_DIR ]; then
+	mkdir $SNAPSHOT_DIR
+fi
+
+if [ ! -f $INPUT_DATA ]; then
+	$FILEIO -C $INPUT_DATA
+fi
+
+# Make sure no stray test-case process from another run is still going
+killall $TEST_CMD > $SCRIPT_LOG 2>&1
+
+> $SCRIPT_LOG;
+cnt=1
+while [ $cnt -lt 20 ]; do
+	$ECHO "===== Iteration $cnt"
+
+	# Remove any 'state' files, start the app and let it tell us
+	# when it is ready
+	rm -f $CHECKPOINT_READY $TEST_DONE $TEST_PID_FILE
+
+	create_container
+	wait_for_checkpoint_ready
+
+	pid=`cat $TEST_PID_FILE`
+
+	$ECHO "\t- Done creating container, cinit-pid $pid"
+
+	ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
+
+	# override default freezerdir
+	if [ -d $freezerdir ]; then
+		rmdir $freezerdir
+	fi
+	freezerdir=$freezermountpoint/$pid
+	freeze_pid $pid
+
+	num_pids1=`ps -efL |grep $TEST_CMD | wc -l`
+
+	create_fs_snapshot
+
+	checkpoint $pid
+
+	touch $CHECKPOINT_DONE
+
+	killall -9 `basename $TEST_CMD`
+
+	thaw
+
+	sleep 3
+
+	restore_fs_snapshot
+
+	restart_container
+
+	sleep 3;
+
+	num_pids2=`ps -efL |grep $TEST_CMD | wc -l`
+	ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
+	$ECHO "\t- num_pids1 $num_pids1, num_pids2 $num_pids2";
+
+	# ns_exec pid is parent-pid of restarted-container-init
+	nspid=`pidof restart`
+
+	if [ "x$nspid" == "x" ]; then
+		$ECHO "***** FAIL: Can't find pid of $RESTART"
+		exit 1;
+	fi
+
+	# End test gracefully
+	touch $TEST_DONE
+
+	$ECHO "\t- Waiting for restarted container to exit (gloabl-pid $nspid)"
+	wait $nspid;
+	ret=$?
+
+	check_for_failure;
+
+	$ECHO "\t- Container exited, status $ret"
+
+	cnt=$((cnt+1))
+done
diff --git a/fileio/run-filelock1.sh b/fileio/run-filelock1.sh
index b4bbaec..554c24a 100755
--- a/fileio/run-filelock1.sh
+++ b/fileio/run-filelock1.sh
@@ -1,224 +1,3 @@
 #!/bin/bash
 
-source ../common.sh
-
-dir=`mktemp -p . -d -t cr_filelock1_XXXXXXX` || (echo "mktemp failed"; exit 1)
-
-# NOTE: As of ckpt-v15-dev, the --container option to 'ckpt' causes this
-#	test to fail with "container not isolated" message due to the
-#	log-file being shared between the application threads.
-#
-CHECKPOINT="`which checkpoint` --container"
-RESTART=`which restart`
-ECHO="/bin/echo -e"
-
-TEST_CMD="../filelock1"
-TEST_ARGS=""
-TEST_LOG="logs.d/log.filelock1"
-SCRIPT_LOG="logs.d/log.run-filelock1"
-TEST_PID_FILE="pid.filelock1";
-
-SNAPSHOT_DIR="snap1.d"
-
-TEST_DONE="test-done"
-CHECKPOINT_FILE="checkpoint-filelock1";
-CHECKPOINT_READY="checkpoint-ready"
-CHECKPOINT_DONE="checkpoint-done"
-
-LOGS_DIR="logs.d"
-DATA_DIR="data.d"
-
-NS_EXEC="../../ns_exec"
-NS_EXEC_ARGS="-cgpuimP $TEST_PID_FILE"
-
-checkpoint()
-{
-	local pid=$1
-
-	$ECHO "\t- Checkpoint: $CHECKPOINT $pid \> $CHECKPOINT_FILE"
-	$CHECKPOINT $pid > $CHECKPOINT_FILE
-	ret=$?
-	if [ $ret -ne 0 ]; then
-		$ECHO "***** FAIL: Checkpoint of $pid failed"
-		ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
-		exit 1;
-	fi
-}
-
-function check_for_failure()
-{
-	grep --binary-files=text FAIL $PWD/$TEST_LOG > /dev/null 2>&1
-	if [ $? -eq 0 ]; then
-		$ECHO "\t***** Application FAILED after restart" >> $SCRIPT_LOG
-		$ECHO "\t***** See $TEST_LOG for details" >> $SCRIPT_LOG
-
-		$ECHO "\t***** Application FAILED after restart"
-		$ECHO "\tSee $PWD/$TEST_LOG for details"
-		exit 1;
-	fi
-}
-
-function wait_for_checkpoint_ready()
-{
-	# Wait for test to finish setup
-	while [ ! -f $CHECKPOINT_READY ]; do
-		$ECHO "\t- Waiting for $CHECKPOINT_READY"
-		check_for_failure;
-		sleep 1;
-	done;
-}
-
-function create_container()
-{
-	local pid;
-
-	cmdline="$NS_EXEC $NS_EXEC_ARGS -- $TEST_CMD $TEST_ARGS"
-
-	$ECHO "\t- Creating container:"
-	$ECHO "\t- $cmdline"
-
-	$cmdline &
-
-	wait_for_checkpoint_ready;
-
-	# Find global pid of container-init
-	pid=`cat $TEST_PID_FILE`;
-	if [  "x$pid" == "x" ]; then
-		$ECHO "***** FAIL: Invalid container-init pid $pid"
-		ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
-		exit 1
-	fi
-	$ECHO "Created container with pid $pid" >> $SCRIPT_LOG
-}
-
-function restart_container
-{
-	local ret;
-
-	cmdline="$RESTART --pids --pidns --wait"
-	$ECHO "\t- $cmdline"
-
-	sleep 1
-
-	$cmdline < $CHECKPOINT_FILE >> $SCRIPT_LOG 2>&1 &
-	ret=$?
-
-	if [ $ret -ne 0 ]; then
-		$ECHO "***** FAIL: Restart of $pid failed"
-		ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
-		exit 1;
-	fi
-
-}
-
-function create_fs_snapshot()
-{
-	# Prepare for snapshot
-	if [ -d $SNAPSHOT_DIR ]; then
-		rm -rf ${SNAPSHOT_DIR}.prev
-		mv $SNAPSHOT_DIR ${SNAPSHOT_DIR}.prev
-		mkdir $SNAPSHOT_DIR
-	fi
-
-	# Snapshot the log files
-	cp ${LOGS_DIR}/* $SNAPSHOT_DIR
-}
-
-function restore_fs_snapshot()
-{
-	# Restore the snapshot after the main process has been killed
-	/bin/cp ${SNAPSHOT_DIR}/* $LOGS_DIR
-}
-
-cd $dir
-echo "Current directory: `pwd`"
-
-if [ ! -d $LOGS_DIR ]; then
-	mkdir $LOGS_DIR
-fi
-
-if [ ! -d $DATA_DIR ]; then
-	mkdir $DATA_DIR
-fi
-
-if [ ! -d $SNAPSHOT_DIR ]; then
-	mkdir $SNAPSHOT_DIR
-fi
-
-if [ ! -f $INPUT_DATA ]; then
-	$FILEIO -C $INPUT_DATA
-fi
-
-# Make sure no stray filelock1 process from another run is still going
-killall $TEST_CMD > $SCRIPT_LOG 2>&1
-
-> $SCRIPT_LOG;
-cnt=1
-while [ $cnt -lt 20 ]; do
-	$ECHO "===== Iteration $cnt"
-
-	# Remove any 'state' files, start the app and let it tell us
-	# when it is ready
-	rm -f $CHECKPOINT_READY $TEST_DONE $TEST_PID_FILE
-
-	create_container
-	wait_for_checkpoint_ready
-
-	pid=`cat $TEST_PID_FILE`
-
-	$ECHO "\t- Done creating container, cinit-pid $pid"
-
-	ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
-
-	# override default freezerdir
-	if [ -d $freezerdir ]; then
-		rmdir $freezerdir
-	fi
-	freezerdir=$freezermountpoint/$pid
-	freeze_pid $pid
-
-	num_pids1=`ps -efL |grep $TEST_CMD | wc -l`
-
-	create_fs_snapshot
-
-	checkpoint $pid
-
-	touch $CHECKPOINT_DONE
-
-	killall -9 `basename $TEST_CMD`
-
-	thaw
-
-	sleep 3
-
-	restore_fs_snapshot
-
-	restart_container
-
-	sleep 3;
-
-	num_pids2=`ps -efL |grep $TEST_CMD | wc -l`
-	ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
-	$ECHO "\t- num_pids1 $num_pids1, num_pids2 $num_pids2";
-
-	# ns_exec pid is parent-pid of restarted-container-init
-	nspid=`pidof restart`
-
-	if [ "x$nspid" == "x" ]; then
-		$ECHO "***** FAIL: Can't find pid of $RESTART"
-		exit 1;
-	fi
-
-	# End test gracefully
-	touch $TEST_DONE
-
-	$ECHO "\t- Waiting for restarted container to exit (gloabl-pid $nspid)"
-	wait $nspid;
-	ret=$?
-
-	check_for_failure;
-
-	$ECHO "\t- Container exited, status $ret"
-
-	cnt=$((cnt+1))
-done
+./run-fcntltests.sh filelock1
diff --git a/fileio/runtests.sh b/fileio/runtests.sh
index 3e3e495..d674311 100755
--- a/fileio/runtests.sh
+++ b/fileio/runtests.sh
@@ -8,4 +8,4 @@ echo
 echo
 echo "****** $0: Running test: filelock1"
 echo
-./run-filelock1.sh
+./run-fcntltests.sh filelock1
-- 
1.6.0.4

  parent reply	other threads:[~2010-01-29 20:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-29 20:28 [PATCH 01/11] runtests.sh: Make test bit more generic Sukadev Bhattiprolu
     [not found] ` <20100129202842.GA25490-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-01-29 20:37   ` [PATCH 02/11] Make runtests.sh a wrapper for fileio tests Sukadev Bhattiprolu
2010-01-29 20:38   ` [PATCH 03/11] Check for failure while waiting for checkpoint-ready Sukadev Bhattiprolu
2010-01-29 20:42   ` Sukadev Bhattiprolu [this message]
2010-01-29 20:42   ` [PATCH 05/11] Move event-notifications to libcrtest/common.c Sukadev Bhattiprolu
     [not found]     ` <20100129204228.GD26721-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-01-30  2:44       ` Serge E. Hallyn
2010-01-29 20:42   ` [PATCH 06/11] filelease1: Test restore of file leases Sukadev Bhattiprolu
2010-01-29 20:43   ` [PATCH 07/11] fsetown1: Test async I/O notification after restart Sukadev Bhattiprolu
2010-01-29 20:43   ` [PATCH 08/11] filelock1: Extend for mandatory locks Sukadev Bhattiprolu
2010-01-29 20:43   ` [PATCH 09/11] pthread1: Don't close stderr() before opening log Sukadev Bhattiprolu
2010-01-29 20:44   ` [PATCH 10/11] filelock2: Test restart of process in F_GETLK Sukadev Bhattiprolu
2010-01-29 20:44   ` [PATCH 11/11] filelease2: Test C/R during lease-break-interval Sukadev Bhattiprolu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100129204210.GC26721@us.ibm.com \
    --to=sukadev-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox