]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/pmem/common.sh
1 BASE_DIR
=$
(readlink
-f $
(dirname $0))
2 [[ -z "$TEST_DIR" ]] && TEST_DIR
="$(cd $BASE_DIR/../../ && pwd)"
3 rpc_py
="$TEST_DIR/scripts/rpc.py "
5 source $TEST_DIR/test
/common
/autotest_common.sh
7 # Prints error message and return error code, closes vhost app and remove
9 # input: error message, error code
12 local error_code
=${2:-1}
15 echo "error code: $error_code"
22 # check if there is pool file & remove it
23 # input: path to pool file
24 # default: $TEST_DIR/test/pmem/pool_file
25 function pmem_clean_pool_file
()
27 local pool_file
=${1:-$TEST_DIR/test/pmem/pool_file}
29 if [ -f $pool_file ]; then
30 echo "Deleting old pool_file"
35 # create new pmem file
36 # input: path to pool file, size in MB, block_size
37 # default: $TEST_DIR/test/pmem/pool_file 32 512
38 function pmem_create_pool_file
()
40 local pool_file
=${1:-$TEST_DIR/test/pmem/pool_file}
42 local block_size
=${3:-512}
44 pmem_clean_pool_file
$pool_file
45 echo "Creating new pool file"
46 if ! $rpc_py create_pmem_pool
$pool_file $size $block_size; then
47 error
"Creating pool_file failed!"
50 if [ ! -f $pool_file ]; then
51 error
"Creating pool_file failed!"
55 function pmem_unmount_ramspace
57 if [ -d "$TEST_DIR/test/pmem/ramspace" ]; then
58 if mount |
grep -q "$TEST_DIR/test/pmem/ramspace"; then
59 umount
$TEST_DIR/test
/pmem
/ramspace
62 rm -rf $TEST_DIR/test
/pmem
/ramspace
66 function pmem_print_tc_name
69 echo "==============================================================="
70 echo "Now running: $1"
71 echo "==============================================================="
74 function vhost_start
()
78 $TEST_DIR/app
/vhost
/vhost
&
80 echo -e "ERROR: Failed to launch vhost!"
85 echo $vhost_pid > $TEST_DIR/test
/pmem
/vhost.pid
86 waitforlisten
$vhost_pid
91 local vhost_pid_file
="$TEST_DIR/test/pmem/vhost.pid"
92 local vhost_pid
="$(cat $vhost_pid_file)"
94 if [[ ! -f $TEST_DIR/test
/pmem
/vhost.pid
]]; then
95 echo -e "ERROR: No vhost pid file found!"
99 if ! kill -s INT
$vhost_pid; then
100 echo -e "ERROR: Failed to exit vhost / invalid pid!"