From: Garrett C. <yab...@us...> - 2010-01-31 07:38:32
|
Update of /cvsroot/ltp/ltp/testscripts/build In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv21131/testscripts/build Modified Files: build_test_function.sh Log Message: 1. Make CVSROOT parameterizable. 2. Fix sudo support. 3. Export compiler-specific variables to test_ltp process, properly. 4. Do proper work with $PATH, variable setting, etc. 5. Simplify mktemp -d logic with a little bit of reflection ala eval(1). Signed-off-by: Garrett Cooper <yan...@gm...> Index: build_test_function.sh =================================================================== RCS file: /cvsroot/ltp/ltp/testscripts/build/build_test_function.sh,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** build_test_function.sh 31 Jan 2010 01:51:59 -0000 1.6 --- build_test_function.sh 31 Jan 2010 07:38:24 -0000 1.7 *************** *** 28,55 **** testscript_dir=$(readlink -f "${0%/*}") unset vars ! if tmp_builddir=$(mktemp -d) ; then ! vars="$vars $tmp_builddir" ! else ! echo "${0##*/}: failed to create tmp_builddir"; ! false ! fi ! if tmp_destdir=$(mktemp -d) ; then ! vars="$vars $tmp_destdir" ! else ! echo "${0##*/}: failed to create tmp_destdir"; ! false ! fi ! if tmp_prefix=$(mktemp -d) ; then ! vars="$vars $tmp_prefix" ! else ! echo "${0##*/}: failed to create tmp_prefix"; ! false ! fi ! if tmp_srcdir=$(mktemp -d) ; then ! vars="$vars $tmp_srcdir" ! else ! echo "${0##*/}: failed to create tmp_srcdir"; ! false ! fi trap cleanup EXIT cat <<EOF --- 28,34 ---- testscript_dir=$(readlink -f "${0%/*}") unset vars ! for i in tmp_builddir tmp_destdir tmp_prefix tmp_srcdir; do ! eval "if $i=\$(mktemp -d) ; then vars=\"\$vars \$${i}\"; else echo ${0##*/}: failed to create temporary directory for $i; false; fi" ! done trap cleanup EXIT cat <<EOF *************** *** 71,75 **** # - 1 -> clean. cleanup() { ! if [ "x${CLEAN_TEMPFILES:-1}" = x1 ] ; then cd / trap '' EXIT --- 50,54 ---- # - 1 -> clean. cleanup() { ! if [ "x${CLEAN_TEMPFILES:-0}" = x1 -a "x${TEST_PASSED:-0}" = x1 ] ; then cd / trap '' EXIT *************** *** 81,88 **** cvs_pull() { ! export CVSROOT=:pserver:ano...@lt...:/cvsroot/ltp if ( [ -f ~/.cvspass ] || touch ~/.cvspass ) ; then ! cvs -d$CVSROOT login && cvs -z3 export -f -r HEAD ltp && srcdir="$PWD/ltp" fi --- 60,68 ---- cvs_pull() { ! export CVSROOT=${CVSROOT:=:pserver:ano...@lt...:/cvsroot/ltp} if ( [ -f ~/.cvspass ] || touch ~/.cvspass ) ; then ! echo "$CVSROOT" | grep -v '^:pserver:' || cvs -d$CVSROOT login ! cvs -z3 export -f -r HEAD ltp && srcdir="$PWD/ltp" fi *************** *** 135,139 **** autotools ! cd "$2" && "$1/configure" ${3:+--prefix=$("$abspath" $3)} } --- 115,119 ---- autotools ! cd "$2" && "$1/configure" ${3:+--prefix=$("$abspath" "$3")} } *************** *** 176,180 **** test_ltp() { ! test_ltp="${1:-.}/test_ltp.sh" # XXX (garrcoop): I haven't tracked down the root cause for the --- 156,161 ---- test_ltp() { ! installdir=$(readlink -f "${1:-.}") ! test_ltp="$installdir/test_ltp.sh" # XXX (garrcoop): I haven't tracked down the root cause for the *************** *** 183,208 **** # platforms when executing runltp. Thus, we should effectively close # /dev/stdin before executing runltp via execltp. ! echo "${1:-.}/bin/execltp < /dev/null" > "$test_ltp" ! if [ "x${1}" != x ] ; then ! export LTPROOT="$1" ! fi if [ "x$(id -ru)" != "x0" ] ; then ! if type su > /dev/null && groups | grep wheel ; then ! PRE_CMD="su -c" ! elif type sudo > /dev/null && sudo sh -c 'exit 0' ; then ! PRE_CMD="sudo --" fi ! if [ "x$PRE_CMD" != x ] ; then ! echo "chown -Rf $(id -ru) *" >> "$test_ltp" ! CMD="${PRE_CMD} '$test_ltp'" fi fi ! echo "${0##*/}: will execute test_ltp $CMD" chmod +x "$test_ltp" # XXX (garrcoop): uncommenting the following would work around a --- 164,209 ---- # platforms when executing runltp. Thus, we should effectively close # /dev/stdin before executing runltp via execltp. ! cat <<EOF > "$test_ltp" ! #!/bin/sh ! export AR="$AR" ! export ARFLAGS="$ARFLAGS" ! export CC="$CC" ! export CFLAGS="$CFLAGS" ! export CXX="$CXX" ! export CXXFLAGS="$CXXFLAGS" ! export LD="$LD" ! export LDFLAGS="$LDFLAGS" ! export NM="$NM" ! ! # Optional variables required for some of the testcases. ! for i in AR ARFLAGS CC CFLAGS CXX CXXFLAGS LD LDFLAGS NM; do ! eval "[ \"x\\\$\$i\" = x ] && unset \$i" ! done ! ! export LTPROOT="$LTPROOT" ! export PATH="\$PATH:$installdir/bin:$PATH" ! ! execltp -l "$installdir" -vv < /dev/null ! EOF ! ! pre_cmd= if [ "x$(id -ru)" != "x0" ] ; then ! # Make sure that environment is translated properly with sudo. ! if type sudo > /dev/null && sudo -- sh -c 'exit 0' ; then ! pre_cmd='sudo --' ! elif type su > /dev/null && groups | grep wheel ; then ! pre_cmd='su -c' fi ! if [ "x$pre_cmd" != x ] ; then ! echo "chown -Rf $(id -ru) \"$installdir\"" >> "$test_ltp" fi fi ! echo "${0##*/}: will execute test_ltp via ${pre_cmd:-$pre_cmd }$test_ltp" chmod +x "$test_ltp" # XXX (garrcoop): uncommenting the following would work around a *************** *** 212,217 **** # cat all output to a log, just tail -f it and enter in your password # when necessary. ! #${CMD} > /dev/tty 2>&1 ! ${CMD} } --- 213,218 ---- # cat all output to a log, just tail -f it and enter in your password # when necessary. ! #${pre_cmd} "${test_ltp}" > /dev/tty 2>&1 && TEST_PASSED=1 ! ${pre_cmd} "${test_ltp}" && TEST_PASSED=1 } |