3 # This file contains the global variables and common functions
4 # used in the posix test scripts.
7 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/../..; echo $PWD)}
8 . $LUSTRE/tests/test-framework.sh
10 #************************ Initialize Global Variables *************************#
11 export POSIX_SRC=${POSIX_SRC:-"/usr/src/posix"}
12 export POSIX_RUN=${POSIX_RUN:-"$POSIX_SRC/run_posix_suite.pl"}
13 export TEST_BIN="$POSIX_SRC/TESTROOT-gcc$(gcc -v 2>&1 | tail -1 |
14 cut -d' ' -f3)-$(uname -m).tgz"
16 # Root directory of the POSIX test suite installation.
17 export INSTALL_DIR=${INSTALL_DIR:-"$POSIX_SRC/tet"}
19 # Root directory from which the testsets will be executed.
20 export TESTEXEC_DIR=${TESTEXEC_DIR:-"$POSIX_SRC/TESTROOT"}
22 # Test results directory.
23 export RESULT_DIR=${RESULT_DIR:-"$INSTALL_DIR/test_sets/results"}
25 # Test groups for POSIX compliance test suite.
26 USER_GROUPS="vsxg0,vsxg1,vsxg2"
28 for i in $(seq 31); do
29 SUPP_GROUPS="$SUPP_GROUPS,supp$i"
31 SUPP_GROUPS=${SUPP_GROUPS#,}
33 export GROUP_ID=${GROUP_ID:-"2000000000"}
34 export USER_ID=${USER_ID:-"2000000000"}
36 #***************************** Common Functions *******************************#
37 # Remove users and groups for running the POSIX test suite.
38 delete_posix_users() {
39 local node=${1:-$(hostname)}
45 for group in ${SUPP_GROUPS//,/ } ${USER_GROUPS//,/ }; do
47 done" 2>&1 | dshbak -c
48 return ${PIPESTATUS[0]}
51 # Setup users and groups for running the POSIX test suite.
53 local node=${1:-$HOSTNAME}
54 # consistent with install.sh in LSB Test Suite
55 local gid=$((GROUP_ID + 1))
62 for group in ${USER_GROUPS//,/ } ${SUPP_GROUPS//,/ }; do
63 if ! do_rpc_nodes $node add_group $gid $group; then
64 delete_posix_users $node
74 if [[ "$user" = "vsx0" ]]; then
75 home=$INSTALL_DIR/test_sets
76 opts="-G $SUPP_GROUPS"
82 if ! do_rpc_nodes $node add_user $uid $user $group $home $opts
84 delete_posix_users $node
94 if [[ ! -d $POSIX_SRC ]]; then
95 echo "Missing POSIX testsuite source"
98 [[ -f $TEST_BIN ]] && rm -f $TEST_BIN
99 [[ -d $INSTALL_DIR ]] && rm -rf $INSTALL_DIR
101 if grep -q " 6." /etc/issue; then
102 [[ -d /usr/include/bits ]] || mkdir -p /usr/include/bits
103 [[ -d /usr/include/sys ]] || mkdir -p /usr/include/sys
104 [[ -s /usr/include/stropts.h ]] || \
105 ln -s /usr/lib/x86_64-redhat-linux5E/include/stropts.h \
106 /usr/include/stropts.h
107 [[ -s /usr/include/bits/stropts.h ]] || \
108 ln -s /usr/lib/x86_64-redhat-linux5E/include/bits/stropts.h \
109 /usr/include/bits/stropts.h
110 [[ -s /usr/include/bits/xtitypes.h ]] || \
111 ln -s /usr/lib/x86_64-redhat-linux5E/include/bits/xtitypes.h \
112 /usr/include/bits/xtitypes.h
113 [[ -s /usr/include/sys/stropts.h ]] || \
114 ln -s /usr/lib/x86_64-redhat-linux5E/include/sys/stropts.h \
115 /usr/include/sys/stropts.h
118 pushd $POSIX_SRC > /dev/null
120 if [[ -f install.sh ]]; then
121 [[ ! -x install.sh ]] && chmod +x install.sh
124 echo "install.sh does not exist in $POSIX_SRC."
132 pushd $POSIX_SRC > /dev/null
134 log "Installing POSIX test suite"
135 # Install the POSIX test suite source files
136 expect -f install-posix.exp $INSTALL_DIR $TESTEXEC_DIR
142 pushd $POSIX_SRC > /dev/null
144 log "Building POSIX test suite"
146 expect -f build-posix.exp $INSTALL_DIR $TESTEXEC_DIR $POSIX_SRC
152 if [[ -f $TEST_BIN ]]; then
154 echo "Install and build POSIX test suite successfully!"
157 echo "failed to build POSIX test suite."
169 [[ "x$COMPARE" != "x" ]] && compare="--compare-result"
170 # command to run posix test suite
171 cmd="TMP=/tmp/vsx0 TMPDIR=/tmp/vsx0 $POSIX_RUN --mountpt=$MNTPNT \
172 --posix-src=$POSIX_SRC --install-dir=$INSTALL_DIR \
173 --results-dir=$RESULT_DIR $compare 2>&1"
175 # run posix test suite
185 log "Setting up POSIX test suite from $POSIX_SRC"