]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/pmem/common.sh
1 # Prints error message and return error code, closes vhost app and remove
3 # input: error message, error code
5 local error_code
=${2:-1}
8 echo "error code: $error_code"
15 # check if there is pool file & remove it
16 # input: path to pool file
17 # default: $default_pool_file
18 function pmem_clean_pool_file
() {
19 local pool_file
=${1:-$default_pool_file}
21 if [ -f $pool_file ]; then
22 echo "Deleting old pool_file"
27 # create new pmem file
28 # input: path to pool file, size in MB, block_size
29 # default: $default_pool_file 32 512
30 function pmem_create_pool_file
() {
31 local pool_file
=${1:-$default_pool_file}
33 local block_size
=${3:-512}
35 pmem_clean_pool_file
$pool_file
36 echo "Creating new pool file"
37 if ! $rpc_py bdev_pmem_create_pool
$pool_file $size $block_size; then
38 error
"Creating pool_file failed!"
41 if [ ! -f $pool_file ]; then
42 error
"Creating pool_file failed!"
46 function pmem_unmount_ramspace
() {
47 if [ -d "$testdir/ramspace" ]; then
48 if mount |
grep -q "$testdir/ramspace"; then
49 umount
$testdir/ramspace
52 rm -rf $testdir/ramspace
56 function pmem_print_tc_name
() {
58 echo "==============================================================="
59 echo "Now running: $1"
60 echo "==============================================================="
63 function vhost_start
() {
69 echo $vhost_pid > $testdir/vhost.pid
70 waitforlisten
$vhost_pid
73 function vhost_kill
() {
74 local vhost_pid_file
="$testdir/vhost.pid"
76 vhost_pid
="$(cat $vhost_pid_file)"
78 if [[ ! -f $vhost_pid_file ]]; then
79 echo -e "ERROR: No vhost pid file found!"
83 if ! kill -s INT
$vhost_pid; then
84 echo -e "ERROR: Failed to exit vhost / invalid pid!"