test/pmem: cleanup common.sh

This file is meant to be just sourced somewhere, so
don't include autotest_common.sh inside. Also, don't
hardcode the default pool file path. Expect
$default_pool_file to be defined already. We'll define
`set -u` soon, so that we'll get a clear error if it's
not defined.

Change-Id: Ie9bb86f8a65d05c9fb2d3e56b8682cab8dd569d6
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458175
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Darek Stojaczyk 2019-06-15 20:47:53 +02:00
parent ae884c7c41
commit 012804ebcf
2 changed files with 14 additions and 18 deletions

View File

@ -1,9 +1,3 @@
BASE_DIR=$(readlink -f $(dirname $0))
[[ -z "$TEST_DIR" ]] && TEST_DIR="$(cd $BASE_DIR/../../ && pwd)"
rpc_py="$TEST_DIR/scripts/rpc.py "
source $TEST_DIR/test/common/autotest_common.sh
# Prints error message and return error code, closes vhost app and remove
# pmem pool file
# input: error message, error code
@ -21,10 +15,10 @@ function error()
# check if there is pool file & remove it
# input: path to pool file
# default: $TEST_DIR/test/pmem/pool_file
# default: $default_pool_file
function pmem_clean_pool_file()
{
local pool_file=${1:-$TEST_DIR/test/pmem/pool_file}
local pool_file=${1:-$default_pool_file}
if [ -f $pool_file ]; then
echo "Deleting old pool_file"
@ -34,10 +28,10 @@ function pmem_clean_pool_file()
# create new pmem file
# input: path to pool file, size in MB, block_size
# default: $TEST_DIR/test/pmem/pool_file 32 512
# default: $default_pool_file 32 512
function pmem_create_pool_file()
{
local pool_file=${1:-$TEST_DIR/test/pmem/pool_file}
local pool_file=${1:-$default_pool_file}
local size=${2:-32}
local block_size=${3:-512}
@ -54,12 +48,12 @@ function pmem_create_pool_file()
function pmem_unmount_ramspace
{
if [ -d "$TEST_DIR/test/pmem/ramspace" ]; then
if mount | grep -q "$TEST_DIR/test/pmem/ramspace"; then
umount $TEST_DIR/test/pmem/ramspace
if [ -d "$testdir/ramspace" ]; then
if mount | grep -q "$testdir/ramspace"; then
umount $testdir/ramspace
fi
rm -rf $TEST_DIR/test/pmem/ramspace
rm -rf $testdir/ramspace
fi
}
@ -75,23 +69,23 @@ function vhost_start()
{
local vhost_pid
$TEST_DIR/app/vhost/vhost &
$rootdir/app/vhost/vhost &
if [ $? != 0 ]; then
echo -e "ERROR: Failed to launch vhost!"
return 1
fi
vhost_pid=$!
echo $vhost_pid > $TEST_DIR/test/pmem/vhost.pid
echo $vhost_pid > $testdir/vhost.pid
waitforlisten $vhost_pid
}
function vhost_kill()
{
local vhost_pid_file="$TEST_DIR/test/pmem/vhost.pid"
local vhost_pid_file="$testdir/vhost.pid"
local vhost_pid="$(cat $vhost_pid_file)"
if [[ ! -f $TEST_DIR/test/pmem/vhost.pid ]]; then
if [[ ! -f $vhost_pid_file ]]; then
echo -e "ERROR: No vhost pid file found!"
return 1
fi

View File

@ -5,6 +5,8 @@ rootdir=$(readlink -f $testdir/../..)
source $rootdir/test/common/autotest_common.sh
source $rootdir/test/pmem/common.sh
rpc_py="$rootdir/scripts/rpc.py "
enable_script_debug=false
test_info=false
test_create=false