--- /dev/null
+#!/bin/bash
+#set -vx
+set -e
+
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+. $LUSTRE/tests/test-framework.sh
+init_test_env $@
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+init_logging
+
+build_test_filter
+check_and_setup_lustre
+
+POSIX_DIR=${POSIX_DIR:-"$LUSTRE/tests/posix"}
+POSIX_SRC=${POSIX_SRC:-"/usr/src/posix"}
+
+cleanup_loop_dev() {
+ local mnt=$1
+ local dev=$2
+ local file=$3
+
+ # if we only have 1 arg, we will search for dev
+ if [[ $# = 1 ]]; then
+ dev=$(losetup -a | grep "$mnt" | cut -d: -f1)
+ [[ -n $dev ]] && losetup -d $dev
+ else # we need all args
+ [[ -z $mnt ]] || [[ -z $dev ]] || [[ -z $file ]] &&
+ error "Can't cleanup loop device"
+ umount -f $mnt
+ losetup -d $dev && rm -rf $mnt
+ rm -f $file
+ fi
+}
+
+setup_loop_dev() {
+ local mnt=$1
+ local dev=$2
+ local file=$3
+ local rc=0
+
+ echo "Make a loop file system with $file on $dev"
+ dd if=/dev/zero of=$file bs=1024k count=500 > /dev/null
+ if ! losetup $dev $file; then
+ rc=$?
+ echo "can't set up $dev for $file"
+ return $rc
+ fi
+ if ! mkfs.ext4 $dev; then
+ rc=$?
+ echo "mkfs.ext4 on $dev failed"
+ return $rc
+ fi
+ mkdir -p ${mnt}
+ if ! mount -t ext4 $dev $mnt; then
+ rc=$?
+ echo "mount ext4 failed"
+ return $rc
+ fi
+ echo
+ return $rc
+}
+
+test_1() {
+ local allnodes="$(comma_list $(nodes_list))"
+ local tfile="$TMP/ext4-file"
+ local mntpnt=$POSIX_SRC/ext4
+ local loopbase
+ local loopdev
+ local rc=0
+
+ # We start at loop1 because posix build uses loop0
+ [ -b /dev/loop/1 ] && loopbase=/dev/loop/
+ [ -b /dev/loop1 ] && loopbase=/dev/loop
+ [ -z "$loopbase" ] && error "/dev/loop/1 and /dev/loop1 gone?"
+
+ for i in `seq 1 7`; do
+ losetup $loopbase$i > /dev/null 2>&1 && continue || true
+ loopdev=$loopbase$i
+ break
+ done
+
+ [ -z "$loopdev" ] && error "Can not find loop device"
+
+ if ! setup_loop_dev $mntpnt $loopdev $tfile; then
+ cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
+ error "Setup loop device failed"
+ fi
+
+ # copy the source over to ext mount point
+ if ! cp -af ${POSIX_SRC}/*.* $mntpnt; then
+ cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
+ error "Copy POSIX test suite failed"
+ fi
+ export POSIX_SRC=$mntpnt
+ . $POSIX_DIR/posix.cfg
+
+ setup_posix_users $allnodes
+ if ! setup_posix; then
+ delete_posix_users $allnodes
+ cleanup_loop_dev "$POSIX_SRC"
+ cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
+ error "Setup POSIX test suite failed"
+ fi
+
+ log "Run POSIX test against lustre filesystem"
+ run_posix $MOUNT compare || \
+ error_noexit "Run POSIX testsuite on $MOUNT failed"
+
+ [[ -d "$MOUNT/TESTROOT" ]] && rm -fr $MOUNT/TESTROOT
+ delete_posix_users $allnodes
+ cleanup_loop_dev "$POSIX_SRC"
+ cleanup_loop_dev "$mntpnt" "$loopdev" "$tfile"
+}
+run_test 1 "build, install, run posix on ext4 and lustre, then compare"
+
+complete $(basename $0) $SECONDS
+check_and_cleanup_lustre
+exit_status
--- /dev/null
+#!/bin/bash
+# vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
+#
+# This file contains the global variables and common functions
+# used in the posix test scripts.
+set -e
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+. $LUSTRE/tests/test-framework.sh
+#************************ Initialize Global Variables *************************#
+export POSIX_SRC=${POSIX_SRC:-"/usr/src/posix"}
+export POSIX_RUN=${POSIX_RUN:-"$POSIX_SRC/run_posix_suite.pl"}
+export TEST_BIN="$POSIX_SRC/TESTROOT-gcc$(gcc -v 2>&1 | tail -1 | cut -d' ' -f3)-$(uname -m).tgz"
+
+# Root directory of the POSIX test suite installation.
+export INSTALL_DIR=${INSTALL_DIR:-"$POSIX_SRC/tet"}
+
+# Root directory from which the testsets will be executed.
+export TESTEXEC_DIR=${TESTEXEC_DIR:-"$POSIX_SRC/TESTROOT"}
+
+# Test results directory.
+export RESULT_DIR=${RESULT_DIR:-"$INSTALL_DIR/test_sets/results"}
+
+# Test groups for POSIX compliance test suite.
+USER_GROUPS="vsxg0,vsxg1,vsxg2"
+SUPP_GROUPS="supp1,supp2,supp3,supp4,supp5,supp6,supp7,supp8,supp9,supp10,supp11,supp12,supp13,supp14,supp15,supp16,supp17,supp18,supp19,supp20,supp21,supp22,supp23,supp24,supp25,supp26,supp27,supp28,supp29,supp30,supp31"
+
+export GROUP_ID=${GROUP_ID:-"1000"}
+export USER_ID=${USER_ID:-"1000"}
+
+#***************************** Common Functions *******************************#
+# Check and add a test group.
+add_group() {
+ local node=${1:-$(hostname)}
+ local group_id=$2
+ local group_name=$3
+ local rc=0
+
+ if ! (do_nodes $node "
+ error() { set +x; echo Error: \\\$2: \\\$1; echo XXRETCODE:\\\$1; exit \\\$1; }
+ gid=\\\$(getent group $group_name | cut -d: -f3);
+ if [ \"x\\\$gid\" != \"x\" ]; then
+ [ \\\$gid -eq $group_id ] || \\
+ error 1 \\\"inconsistent group ID: new: $group_id, old: \\\$gid\\\";
+ else
+ groupadd -g $group_id $group_name
+ fi;" 2>&1 | dshbak -c
+ exit ${PIPESTATUS[0]})
+ then
+ rc=${PIPESTATUS[0]}
+ fi
+
+ return $rc
+}
+
+# Check and add a test user.
+add_user() {
+ local node=${1:-$(hostname)}
+ local user_id=$2
+ local user_name=$3
+ local group_name=$4
+ local home_dir
+ local rc=0
+
+ if [[ "$user_name" = "vsx0" ]]; then
+ home_dir=$INSTALL_DIR/test_sets
+ else
+ home_dir=$INSTALL_DIR
+ fi
+
+ if ! (do_nodes $node "
+ error() { set +x; echo Error: \\\$2: \\\$1; echo XXRETCODE:\\\$1; exit \\\$1; }
+ SUPP_GROUPS=$SUPP_GROUPS;
+ uid=\\\$(getent passwd $user_name | cut -d: -f3);
+ if [ \"x\\\$uid\" != \"x\" ]; then
+ if [ \\\$uid -eq $user_id ]; then
+ dir=\\\$(getent passwd $user_name | cut -d: -f6)
+ if [ \"x\\\$dir\" != \"x$home_dir\" ]; then
+ mkdir -p $home_dir
+ usermod -d $home_dir $user_name
+ fi
+ else
+ error 1 \\\"inconsistent user ID: new: $user_id, old: \\\$uid\\\"
+ fi
+ else
+ mkdir -p $home_dir
+ if [ \"x$user_name\" = \"xvsx0\" ]; then
+ useradd -M -u $user_id -d $home_dir -g $group_name -G $SUPP_GROUPS $user_name
+ else
+ useradd -M -u $user_id -d $home_dir -g $group_name $user_name
+ fi
+ fi" 2>&1 | dshbak -c
+ exit ${PIPESTATUS[0]})
+ then
+ rc=${PIPESTATUS[0]}
+ fi
+
+ return $rc
+}
+
+# Remove users and groups for running the POSIX test suite.
+delete_posix_users() {
+ local node=${1:-$(hostname)}
+
+ do_nodes $node "
+ for i in 0 1 2; do
+ userdel vsx\\\$i;
+ done;
+ for group in ${SUPP_GROUPS//,/ } ${USER_GROUPS//,/ }; do
+ groupdel \\\$group;
+ done" 2>&1 | dshbak -c
+ return ${PIPESTATUS[0]}
+}
+
+# Setup users and groups for running the POSIX test suite.
+setup_posix_users() {
+ local node=${1:-$(hostname)}
+ local gid=$((GROUP_ID + 1))
+ local uid=$USER_ID
+ local user group
+ local i
+
+ for group in ${USER_GROUPS//,/ } ${SUPP_GROUPS//,/ }; do
+ if ! add_group $node $gid $group; then
+ delete_posix_users $node
+ setup_posix_users $node
+ fi
+ gid=$(( gid + 1 ))
+ done
+
+ for i in 0 1 2; do
+ user=vsx$i
+ group=vsxg$i
+ if ! add_user $node $uid $user $group; then
+ delete_posix_users $node
+ setup_posix_users $node
+ fi
+ uid=$(( uid + 1 ))
+ done
+}
+
+prep() {
+ if [[ ! -d $POSIX_SRC ]]; then
+ echo "Missing POSIX testsuite source"
+ return 1
+ fi
+ [[ -f $TEST_BIN ]] && rm -f $TEST_BIN
+ [[ -d $INSTALL_DIR ]] && rm -rf $INSTALL_DIR
+
+ rpm -q byacc > /dev/null || yum -y install byacc
+ if grep -q " 6." /etc/issue; then
+ rpm -q compat-glibc-headers > /dev/null || \
+ yum install -y compat-glibc-headers
+
+ [[ -d /usr/include/bits ]] || mkdir -p /usr/include/bits
+ [[ -d /usr/include/sys ]] || mkdir -p /usr/include/sys
+ [[ -s /usr/include/stropts.h ]] || \
+ ln -s /usr/lib/x86_64-redhat-linux5E/include/stropts.h \
+ /usr/include/stropts.h
+ [[ -s /usr/include/bits/stropts.h ]] || \
+ ln -s /usr/lib/x86_64-redhat-linux5E/include/bits/stropts.h \
+ /usr/include/bits/stropts.h
+ [[ -s /usr/include/bits/xtitypes.h ]] || \
+ ln -s /usr/lib/x86_64-redhat-linux5E/include/bits/xtitypes.h \
+ /usr/include/bits/xtitypes.h
+ [[ -s /usr/include/sys/stropts.h ]] || \
+ ln -s /usr/lib/x86_64-redhat-linux5E/include/sys/stropts.h \
+ /usr/include/sys/stropts.h
+ fi
+
+ pushd $POSIX_SRC > /dev/null
+
+ if [[ -f install.sh ]]; then
+ [[ ! -x install.sh ]] && chmod +x install.sh
+ else
+ popd > /dev/null
+ echo "install.sh does not exist in $POSIX_SRC."
+ return 1
+ fi
+
+ popd > /dev/null
+}
+
+install() {
+ pushd $POSIX_SRC > /dev/null
+
+ log "Installing POSIX test suite"
+ # Install the POSIX test suite source files
+ expect -f install-posix.exp $INSTALL_DIR $TESTEXEC_DIR
+
+ popd > /dev/null
+}
+
+build() {
+ pushd $POSIX_SRC > /dev/null
+
+ log "Building POSIX test suite"
+ # Build testsets
+ expect -f build-posix.exp $INSTALL_DIR $TESTEXEC_DIR $POSIX_SRC
+
+ popd > /dev/null
+}
+
+cleanup() {
+ if [[ -f $TEST_BIN ]]; then
+ rm -fr $TESTEXEC_DIR
+ echo "Install and build POSIX test suite successfully!"
+ return 0
+ else
+ echo "failed to build POSIX test suite."
+ return 1
+ fi
+}
+
+run_posix() {
+ local MNTPNT=$1
+ local COMPARE=${2}
+ local compare=""
+ local rc=0
+ local cmd
+
+ [[ "x$COMPARE" != "x" ]] && compare="--compare-result"
+ # command to run posix test suite
+ cmd="TMP=/tmp/vsx0 TMPDIR=/tmp/vsx0 $POSIX_RUN --mountpt=$MNTPNT \
+ --posix-src=$POSIX_SRC --install-dir=$INSTALL_DIR \
+ --results-dir=$RESULT_DIR $compare 2>&1"
+
+ # run posix test suite
+ echo $cmd
+ if ! eval $cmd; then
+ rc=${PIPESTATUS[0]}
+ fi
+
+ return $rc
+}
+
+setup_posix() {
+ log "Setting up POSIX test suite from $POSIX_SRC"
+ prep || return $?
+ install
+ build
+ cleanup
+}