Spdk/test/blobfs/blobfs.sh
Xiaodong Liu 6433c1037d blobfs: add blobfs_create RPC as mkfs
Following test/blobfs/mkfs case, add it as one RPC
method to let build a new blobfs on given block
device.

Change-Id: I0ffbb1add95dfbc8655e0238ed6f3cd519dd945b
Signed-off-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466485
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
2019-10-09 05:02:00 +00:00

96 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
SYSTEM=$(uname -s)
if [ $SYSTEM = "FreeBSD" ] ; then
echo "blobfs.sh cannot run on FreeBSD currently."
exit 0
fi
testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../..)
rpc_server=/var/tmp/spdk-blobfs.sock
rpc_py="$rootdir/scripts/rpc.py -s $rpc_server"
tmp_file=/tmp/blobfs_file
conf_file=/tmp/blobfs.conf
bdevname=BlobfsBdev
source $rootdir/test/common/autotest_common.sh
function on_error_exit() {
if [ -n "$blobfs_pid" ]; then
killprocess $blobfs_pid
fi
rm -f $tmp_file
rm -f $conf_file
print_backtrace
exit 1
}
function blobfs_start_app {
$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -c ${conf_file} &
blobfs_pid=$!
echo "Process blobfs pid: $blobfs_pid"
waitforlisten $blobfs_pid $rpc_server
}
function blobfs_detect_test() {
# Detect out there is no blobfs on test bdev
blobfs_start_app
result=$($rpc_py blobfs_detect ${bdevname})
if [ "${result}" != "False" ]; then
false
fi
killprocess $blobfs_pid
# Create blobfs on test bdev
$rootdir/test/blobfs/mkfs/mkfs ${conf_file} ${bdevname}
# Detect out there is a blobfs on test bdev
blobfs_start_app
result=$($rpc_py blobfs_detect ${bdevname})
if [ "${result}" != "True" ]; then
false
fi
killprocess $blobfs_pid
}
function blobfs_create_test() {
blobfs_start_app
# Create blobfs on test bdev
$rpc_py blobfs_create ${bdevname}
# Detect out there is a blobfs on test bdev
result=$($rpc_py blobfs_detect ${bdevname})
if [ "${result}" != "True" ]; then
false
fi
killprocess $blobfs_pid
}
timing_enter blobfs
trap 'on_error_exit;' ERR
# Create one temp file as test bdev
dd if=/dev/zero of=${tmp_file} bs=4k count=1M
echo "[AIO]" > ${conf_file}
echo "AIO ${tmp_file} ${bdevname} 4096" >> ${conf_file}
blobfs_detect_test
# Clear blobfs on temp file
dd if=/dev/zero of=${tmp_file} bs=4k count=1M
blobfs_create_test
rm -f $tmp_file
report_test_completion "blobfs"
timing_exit blobfs