+
+############################################################
+# PIOS
+#
+
+iterpr_KMGT () {
+ local str=$1
+ local num=${str:0:${#str}-1}
+ case ${str:${#str}-1} in
+ k|K ) num=$((num << 10));; #
+ m|M ) num=$((num << 20));; # emacs is confsued by the << and
+ g|G ) num=$((num << 30));; # these comments help it out.
+ t|T ) num=$((num << 40));; #
+ * ) num=$str;;
+ esac
+ echo $num
+}
+
+space_check () {
+ # space estimation
+ # /* Adding 10% to total test size for filesystem overhead */
+ # size = size + (double)(size) * (double) (0.1);
+ #
+ # total_test_size = runarg->stream[n - 1].max_offset +
+ # runarg->regionsize;
+
+ local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
+ local size=$(($(iterpr_KMGT $pios_REGIONCOUNT) * \
+ $(iterpr_KMGT $pios_OFFSET) + \
+ $(iterpr_KMGT $pios_REGIONSIZE) ))
+ size=$(( size + size / 10 ))
+ if [ $((space * 1024)) -le $size ]; then
+ echo "Need free space atleast $size, have $((space * 1024))"
+ return 10
+ fi
+}
+
+pios_setup() {
+ local testdir=$DIR/$tdir
+ mkdir -p $testdir
+
+ stripes=1
+ [ "$1" == "--stripe" ] && stripes=-1
+ $LFS setstripe $testdir -c $stripes
+ echo "Test directory stripe count: $stripes"
+}
+
+pios_cleanup() {
+ local rc=$1
+ local testdir=$DIR/$tdir
+ [ $rc = 0 ] && rm -rf $testdir
+}
+
+run_pios () {
+ local testdir=$DIR/$tdir
+ local cmd="$PIOSBIN -t $pios_THREADCOUNT -n $pios_REGIONCOUNT \
+ -c $pios_CHUNKSIZE -s $pios_REGIONSIZE \
+ -o $pios_OFFSET $@ -p $testdir"
+
+ if [ ! -d $testdir ]; then
+ error "No test directory created, setup_pios must have failed"
+ return 20
+ fi
+
+ log "$cmd"
+
+ local rc=0
+ eval $cmd
+ rc=$?
+
+ return $rc
+}
+
+test_pios_ssf() {
+ if [ -z "$PIOSBIN" ]; then
+ skip_env "$0 : pios not found PIOSBIN=$PIOSBIN"
+ return
+ fi
+
+ local rc=0
+ space_check || { skip_env "not enough space" && return 0; }
+ pios_setup --stripe || return
+ run_pios || return
+ run_pios --verify || rc=$?
+ pios_cleanup $rc
+ return $rc
+}
+run_test pios_ssf "pios shared single file"
+
+test_pios_fpp() {
+ if [ -z "$PIOSBIN" ]; then
+ skip_env "pios not found PIOSBIN=$PIOSBIN"
+ return
+ fi
+
+ local rc=0
+ space_check || { skip_env "not enough space" && return 0; }
+ pios_setup || return
+ run_pios -L fpp || return
+ run_pios -L fpp --verify || rc=$?
+ pios_cleanup $rc
+ return $rc
+}
+run_test pios_fpp "pios file per process"
+