5 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
6 . $LUSTRE/tests/test-framework.sh
8 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
11 POSIX_DIR=${POSIX_DIR:-"$LUSTRE/tests/posix"}
12 POSIX_SRC=${POSIX_SRC:-"/usr/src/posix"}
13 BASELINE_FS=${BASELINE_FS:-"ext4"}
15 # SLES does not support read-write access to an ext4 file system by default
16 [[ -e /etc/SuSE-release ]] && BASELINE_FS=ext3
18 if [[ $(facet_fstype $SINGLEMDS) = zfs ]]; then
20 ! which $ZFS $ZPOOL >/dev/null 2>&1 &&
21 skip_env "need $ZFS and $ZPOOL commands" && exit 0
23 POSIX_ZPOOL=$FSNAME-posix
24 POSIX_ZFS=$POSIX_ZPOOL/${POSIX_ZPOOL##$FSNAME-}
27 check_and_setup_lustre
35 # if we only have 1 arg, we will search for dev
37 dev=$(losetup -a | grep "$mnt" | cut -d: -f1)
38 [[ -n $dev ]] && losetup -d $dev
39 else # we need all args
40 [[ -z $mnt ]] || [[ -z $dev ]] || [[ -z $file ]] &&
41 error "Can't cleanup loop device"
43 losetup -d $dev && rm -rf $mnt
47 [[ $BASELINE_FS != zfs ]] || destroy_zpool client $POSIX_ZPOOL
56 echo "Make a loop file system with $file on $dev"
57 dd if=/dev/zero of=$file bs=1024k count=500 > /dev/null
58 if ! losetup $dev $file; then
60 echo "can't set up $dev for $file"
64 if [[ $BASELINE_FS = zfs ]]; then
65 create_zpool client $POSIX_ZPOOL $dev || return ${PIPESTATUS[0]}
66 create_zfs client $POSIX_ZFS || return ${PIPESTATUS[0]}
69 elif ! eval mkfs.$BASELINE_FS $dev; then
71 echo "mkfs.$BASELINE_FS on $dev failed"
75 if ! mount -t $BASELINE_FS $dev $mnt; then
77 echo "mount $BASELINE_FS failed"
85 local allnodes="$(comma_list $(nodes_list))"
86 local tfile="$TMP/$BASELINE_FS-file"
87 local mntpnt=$POSIX_SRC/$BASELINE_FS
92 # We start at loop1 because posix build uses loop0
93 [ -b /dev/loop/1 ] && loopbase=/dev/loop/
94 [ -b /dev/loop1 ] && loopbase=/dev/loop
95 [ -z "$loopbase" ] && error "/dev/loop/1 and /dev/loop1 gone?"
97 for i in `seq 1 7`; do
98 losetup $loopbase$i > /dev/null 2>&1 && continue || true
103 [ -z "$loopdev" ] && error "Can not find loop device"
105 if ! setup_loop_dev $mntpnt $loopdev $tfile; then
106 cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
107 error "Setup loop device failed"
110 # copy the source over to ext mount point
111 if ! cp -af ${POSIX_SRC}/*.* $mntpnt; then
112 cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
113 error "Copy POSIX test suite failed"
115 export POSIX_SRC=$mntpnt
116 . $POSIX_DIR/posix.cfg
118 setup_posix_users $allnodes
119 if ! setup_posix; then
120 delete_posix_users $allnodes
121 cleanup_loop_dev "$POSIX_SRC"
122 cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
123 error "Setup POSIX test suite failed"
126 log "Run POSIX test against lustre filesystem"
127 run_posix $MOUNT compare || \
128 error_noexit "Run POSIX testsuite on $MOUNT failed"
130 [[ -d "$MOUNT/TESTROOT" ]] && rm -fr $MOUNT/TESTROOT
131 delete_posix_users $allnodes
132 cleanup_loop_dev "$POSIX_SRC"
133 cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
135 run_test 1 "install, build, run posix on $BASELINE_FS and lustre, then compare"
138 check_and_cleanup_lustre