Whamcloud - gitweb
r=zab,phil
[fs/lustre-release.git] / lustre / tests / oos.sh
1 #!/bin/bash
2
3 export NAME=${NAME:-local}
4 export OSTSIZE=10000
5
6 MOUNT=${MOUNT:-/mnt/lustre}
7 TMP=${TMP:-/tmp}
8
9 echo "mnt.."
10 sh llmount.sh
11 echo "done"
12
13 SUCCESS=1
14
15 FREESPACE=`df |grep $MOUNT|tr -s ' '|cut -d ' ' -f4`
16
17 rm -f $TMP/oosfile
18 dd if=/dev/zero of=$MOUNT/oosfile count=$[$FREESPACE + 1] bs=1k 2>$TMP/oosfile
19
20 RECORDSOUT=`grep "records out" $TMP/oosfile|cut -d + -f1`
21
22 [ -z "`grep "No space left on device" $TMP/oosfile`" ] && \
23         echo "failed:dd not return ENOSPC" && SUCCESS=0
24
25 REMAINEDFREE=`df |grep $MOUNT|tr -s ' '|cut -d ' ' -f4`
26 [ $[$FREESPACE - $REMAINEDFREE ] -lt $RECORDSOUT ] && \
27         echo "failed:the space written by dd not equal to available space" && \
28         SUCCESS=0 && echo "$FREESPACE - $REMAINEDFREE $RECORDSOUT"
29
30 [ $REMAINEDFREE -gt 100 ] && \
31         echo "failed:too many space left $REMAINEDFREE and -ENOSPC returned" &&\
32         SUCCESS=0
33
34 FILESIZE=`ls -l $MOUNT/oosfile|tr -s ' '|cut -d ' ' -f5`
35 [ $RECORDSOUT -ne $[$FILESIZE/1024] ] && \
36         echo "failed:the space written by dd not equal to the size of file" && \
37         SUCCESS=0
38
39 [ $SUCCESS -eq 1 ] && echo "Success!"
40
41 rm -f $MOUNT/oosfile*
42 rm -f $TMP/oosfile
43
44 echo ""
45 echo "cln.."
46 sh llmountcleanup.sh