]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test_lost.sh: put common functions in test_common
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 22 Oct 2010 18:48:35 +0000 (11:48 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 22 Oct 2010 18:50:25 +0000 (11:50 -0700)
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/test/test_common.sh [new file with mode: 0755]
src/test/test_lost.sh

diff --git a/src/test/test_common.sh b/src/test/test_common.sh
new file mode 100755 (executable)
index 0000000..0df86b3
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash -x
+
+#
+# test_common.sh
+#
+# Common routines for tests
+#
+
+# Functions
+cleanup() {
+        rm -rf "${TEMPDIR}"
+}
+
+setup_tempdir() {
+        TEMPDIR=`mktemp -d`
+        trap cleanup INT TERM EXIT
+}
+
+die() {
+        echo $@
+        exit 1
+}
+
+stop_osd() {
+        osd_index=$1
+        pidfile="out/osd.$osd_index.pid"
+        if [ -e $pidfile ]; then
+                kill `cat $pidfile` && return 0
+        else
+                echo "cosd process $osd_index is not running"
+        fi
+        return 1
+}
+
+restart_osd() {
+        osd_index=$1
+        ./cosd -i $osd_index -c ceph.conf &
+}
index f66344b9192c89899bfe1e1b71fcac3f8e48e144..baba361435bff425faaa736c2fa8476ec5e2672e 100755 (executable)
@@ -4,44 +4,15 @@
 # Simple test of recovery logic
 #
 
+# Includes
+dir=`dirname $0`
+source $dir/test_common.sh
+setup_tempdir
+cd $dir/..
+
 # Constants
 MAX_OBJS=50
 OBJ_SIZE=1000000
-TEMPDIR=`mktemp -d`
-SDIR=`dirname $0`/..
-
-# Initialization
-cd $SDIR
-[ -e "/dev/urandom" ] || die "need /dev/urandom"
-trap cleanup INT TERM EXIT
-rm -rf $TEMPDIR
-mkdir -p $TEMPDIR || die "failed to make tempdir"
-
-# Functions
-cleanup() {
-        rm -rf "${TEMPDIR}"
-}
-
-die() {
-        echo $@
-        exit 1
-}
-
-stop_osd() {
-        osd_index=$1
-        pidfile="out/osd.$osd_index.pid"
-        if [ -e $pidfile ]; then
-                kill `cat $pidfile` && return 0
-        else
-                echo "cosd process $osd_index is not running" 
-        fi
-        return 1
-}
-
-restart_osd() {
-        osd_index=$1
-        ./cosd -i $osd_index -c ceph.conf &
-}
 
 write_objects() {
         start_ver=$1