6 LUSTRE=${LUSTRE:-$(dirname $0)/..}
7 . $LUSTRE/tests/test-framework.sh
11 ALWAYS_EXCEPT="$POSIX_EXCEPT"
14 POSIX_DIR=${POSIX_DIR:-"$LUSTRE/tests/posix"}
15 POSIX_SRC=${POSIX_SRC:-"/usr/src/posix"}
16 BASELINE_FS=${BASELINE_FS:-"ext4"}
18 # SLES does not support read-write access to an ext4 file system by default
19 [[ -e /etc/SuSE-release ]] && BASELINE_FS=ext3
21 if [[ "$mds1_FSTYPE" = zfs ]]; then
23 ! which $ZFS $ZPOOL >/dev/null 2>&1 &&
24 skip_env "need $ZFS and $ZPOOL commands"
26 POSIX_ZPOOL=$FSNAME-posix
27 POSIX_ZFS=$POSIX_ZPOOL/${POSIX_ZPOOL##$FSNAME-}
30 check_and_setup_lustre
37 # if we only have 1 arg, we will search for dev
39 dev=$(losetup -a | grep "$mnt" | cut -d: -f1)
40 [[ -n $dev ]] && losetup -d $dev
41 else # we need all args
42 [[ -z $mnt ]] || [[ -z $dev ]] || [[ -z $file ]] &&
43 error "Can't cleanup loop device"
45 losetup -d $dev && rm -rf $mnt
49 [[ $BASELINE_FS != zfs ]] || destroy_zpool client $POSIX_ZPOOL
58 echo "Make a loop file system with $file on $dev"
59 dd if=/dev/zero of=$file bs=1024k count=500 > /dev/null
60 if ! losetup $dev $file; then
62 echo "can't set up $dev for $file"
66 if [[ $BASELINE_FS = zfs ]]; then
67 create_zpool client $POSIX_ZPOOL $dev || return ${PIPESTATUS[0]}
68 create_zfs client $POSIX_ZFS || return ${PIPESTATUS[0]}
71 elif ! eval mkfs.$BASELINE_FS $dev; then
73 echo "mkfs.$BASELINE_FS on $dev failed"
77 if ! mount -t $BASELINE_FS $dev $mnt; then
79 echo "mount $BASELINE_FS failed"
87 local allnodes="$(comma_list $(nodes_list))"
88 local tfile="$TMP/$BASELINE_FS-file"
89 local mntpnt=$POSIX_SRC/$BASELINE_FS
94 # We start at loop1 because posix build uses loop0
95 [ -b /dev/loop/1 ] && loopbase=/dev/loop/
96 [ -b /dev/loop1 ] && loopbase=/dev/loop
97 if [ -z "$loopbase" ]; then
98 # there is no /dev/loop by default on EL7, LU-6707.
99 load_module loop max_loop=8 || error "load loop module failed"
103 for i in $(seq 1 7); do
104 losetup $loopbase$i > /dev/null 2>&1 && continue || true
109 [ -z "$loopdev" ] && error "Can not find loop device"
111 if ! setup_loop_dev $mntpnt $loopdev $tfile; then
112 cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
113 error "Setup loop device failed"
116 # copy the source over to ext mount point
117 if ! cp -af ${POSIX_SRC}/*.* $mntpnt; then
118 cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
119 error "Copy POSIX test suite failed"
121 export POSIX_SRC=$mntpnt
122 . $POSIX_DIR/posix.cfg
124 setup_posix_users $allnodes
125 if ! setup_posix; then
126 delete_posix_users $allnodes
127 cleanup_loop_dev "$POSIX_SRC"
128 cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
129 error "Setup POSIX test suite failed"
132 log "Run POSIX test against lustre filesystem"
133 run_posix $MOUNT $MGSNID $FSNAME compare ||
134 error_noexit "Run POSIX testsuite on $MOUNT failed"
136 [[ -d "$MOUNT/TESTROOT" ]] && rm -fr $MOUNT/TESTROOT
137 delete_posix_users $allnodes
138 cleanup_loop_dev "$POSIX_SRC"
139 cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
141 run_test 1 "install, build, run posix on $BASELINE_FS and lustre, then compare"
144 check_and_cleanup_lustre