diff options
author | Colin Patrick McCabe <cmccabe@alumni.cmu.edu> | 2010-10-22 11:48:35 -0700 |
---|---|---|
committer | Colin Patrick McCabe <cmccabe@alumni.cmu.edu> | 2010-10-22 11:50:25 -0700 |
commit | 242b5992f3075ee073bf53e7a88b16f028879c8e (patch) | |
tree | d474a99c5389aad08e2e08116ac6b0f9ecba9fc0 /src/test | |
parent | 55fcbc649c42f029ca63a1f36acc5244beacf705 (diff) | |
download | ceph-242b5992f3075ee073bf53e7a88b16f028879c8e.tar.gz |
test_lost.sh: put common functions in test_common
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
Diffstat (limited to 'src/test')
-rwxr-xr-x | src/test/test_common.sh | 38 | ||||
-rwxr-xr-x | src/test/test_lost.sh | 41 |
2 files changed, 44 insertions, 35 deletions
diff --git a/src/test/test_common.sh b/src/test/test_common.sh new file mode 100755 index 00000000000..0df86b3404f --- /dev/null +++ b/src/test/test_common.sh @@ -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 & +} diff --git a/src/test/test_lost.sh b/src/test/test_lost.sh index f66344b9192..baba361435b 100755 --- a/src/test/test_lost.sh +++ b/src/test/test_lost.sh @@ -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 |