2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 # This file contains the global variables and common functions
5 # used in the posix test scripts.
7 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
8 . $LUSTRE/tests/test-framework.sh
9 #************************ Initialize Global Variables *************************#
10 export POSIX_SRC=${POSIX_SRC:-"/usr/src/posix"}
11 export POSIX_RUN=${POSIX_RUN:-"$POSIX_SRC/run_posix_suite.pl"}
12 export TEST_BIN="$POSIX_SRC/TESTROOT-gcc$(gcc -v 2>&1 | tail -1 | cut -d' ' -f3)-$(uname -m).tgz"
14 # Root directory of the POSIX test suite installation.
15 export INSTALL_DIR=${INSTALL_DIR:-"$POSIX_SRC/tet"}
17 # Root directory from which the testsets will be executed.
18 export TESTEXEC_DIR=${TESTEXEC_DIR:-"$POSIX_SRC/TESTROOT"}
20 # Test results directory.
21 export RESULT_DIR=${RESULT_DIR:-"$INSTALL_DIR/test_sets/results"}
23 # Test groups for POSIX compliance test suite.
24 USER_GROUPS="vsxg0,vsxg1,vsxg2"
25 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"
27 export GROUP_ID=${GROUP_ID:-"1000"}
28 export USER_ID=${USER_ID:-"1000"}
30 #***************************** Common Functions *******************************#
31 # Check and add a test group.
33 local node=${1:-$(hostname)}
38 if ! (do_nodes $node "
39 error() { set +x; echo Error: \\\$2: \\\$1; echo XXRETCODE:\\\$1; exit \\\$1; }
40 gid=\\\$(getent group $group_name | cut -d: -f3);
41 if [ \"x\\\$gid\" != \"x\" ]; then
42 [ \\\$gid -eq $group_id ] || \\
43 error 1 \\\"inconsistent group ID: new: $group_id, old: \\\$gid\\\";
45 groupadd -g $group_id $group_name
47 exit ${PIPESTATUS[0]})
55 # Check and add a test user.
57 local node=${1:-$(hostname)}
64 if [[ "$user_name" = "vsx0" ]]; then
65 home_dir=$INSTALL_DIR/test_sets
70 if ! (do_nodes $node "
71 error() { set +x; echo Error: \\\$2: \\\$1; echo XXRETCODE:\\\$1; exit \\\$1; }
72 SUPP_GROUPS=$SUPP_GROUPS;
73 uid=\\\$(getent passwd $user_name | cut -d: -f3);
74 if [ \"x\\\$uid\" != \"x\" ]; then
75 if [ \\\$uid -eq $user_id ]; then
76 dir=\\\$(getent passwd $user_name | cut -d: -f6)
77 if [ \"x\\\$dir\" != \"x$home_dir\" ]; then
79 usermod -d $home_dir $user_name
82 error 1 \\\"inconsistent user ID: new: $user_id, old: \\\$uid\\\"
86 if [ \"x$user_name\" = \"xvsx0\" ]; then
87 useradd -M -u $user_id -d $home_dir -g $group_name -G $SUPP_GROUPS $user_name
89 useradd -M -u $user_id -d $home_dir -g $group_name $user_name
92 exit ${PIPESTATUS[0]})
100 # Remove users and groups for running the POSIX test suite.
101 delete_posix_users() {
102 local node=${1:-$(hostname)}
108 for group in ${SUPP_GROUPS//,/ } ${USER_GROUPS//,/ }; do
110 done" 2>&1 | dshbak -c
111 return ${PIPESTATUS[0]}
114 # Setup users and groups for running the POSIX test suite.
115 setup_posix_users() {
116 local node=${1:-$(hostname)}
117 local gid=$((GROUP_ID + 1))
122 for group in ${USER_GROUPS//,/ } ${SUPP_GROUPS//,/ }; do
123 if ! add_group $node $gid $group; then
124 delete_posix_users $node
125 setup_posix_users $node
133 if ! add_user $node $uid $user $group; then
134 delete_posix_users $node
135 setup_posix_users $node
142 if [[ ! -d $POSIX_SRC ]]; then
143 echo "Missing POSIX testsuite source"
146 [[ -f $TEST_BIN ]] && rm -f $TEST_BIN
147 [[ -d $INSTALL_DIR ]] && rm -rf $INSTALL_DIR
149 rpm -q byacc > /dev/null || yum -y install byacc
150 if grep -q " 6." /etc/issue; then
151 rpm -q compat-glibc-headers > /dev/null || \
152 yum install -y compat-glibc-headers
154 [[ -d /usr/include/bits ]] || mkdir -p /usr/include/bits
155 [[ -d /usr/include/sys ]] || mkdir -p /usr/include/sys
156 [[ -s /usr/include/stropts.h ]] || \
157 ln -s /usr/lib/x86_64-redhat-linux5E/include/stropts.h \
158 /usr/include/stropts.h
159 [[ -s /usr/include/bits/stropts.h ]] || \
160 ln -s /usr/lib/x86_64-redhat-linux5E/include/bits/stropts.h \
161 /usr/include/bits/stropts.h
162 [[ -s /usr/include/bits/xtitypes.h ]] || \
163 ln -s /usr/lib/x86_64-redhat-linux5E/include/bits/xtitypes.h \
164 /usr/include/bits/xtitypes.h
165 [[ -s /usr/include/sys/stropts.h ]] || \
166 ln -s /usr/lib/x86_64-redhat-linux5E/include/sys/stropts.h \
167 /usr/include/sys/stropts.h
170 pushd $POSIX_SRC > /dev/null
172 if [[ -f install.sh ]]; then
173 [[ ! -x install.sh ]] && chmod +x install.sh
176 echo "install.sh does not exist in $POSIX_SRC."
184 pushd $POSIX_SRC > /dev/null
186 log "Installing POSIX test suite"
187 # Install the POSIX test suite source files
188 expect -f install-posix.exp $INSTALL_DIR $TESTEXEC_DIR
194 pushd $POSIX_SRC > /dev/null
196 log "Building POSIX test suite"
198 expect -f build-posix.exp $INSTALL_DIR $TESTEXEC_DIR $POSIX_SRC
204 if [[ -f $TEST_BIN ]]; then
206 echo "Install and build POSIX test suite successfully!"
209 echo "failed to build POSIX test suite."
221 [[ "x$COMPARE" != "x" ]] && compare="--compare-result"
222 # command to run posix test suite
223 cmd="TMP=/tmp/vsx0 TMPDIR=/tmp/vsx0 $POSIX_RUN --mountpt=$MNTPNT \
224 --posix-src=$POSIX_SRC --install-dir=$INSTALL_DIR \
225 --results-dir=$RESULT_DIR $compare 2>&1"
227 # run posix test suite
237 log "Setting up POSIX test suite from $POSIX_SRC"