Commit 012804eb authored by Darek Stojaczyk's avatar Darek Stojaczyk
Browse files

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: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458175


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent ae884c7c
Loading
Loading
Loading
Loading
+12 −18
Original line number Diff line number Diff line
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
+2 −0
Original line number Diff line number Diff line
@@ -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