OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / libgo / testsuite / gotest
index 3511c52..208cbaf 100755 (executable)
@@ -30,8 +30,10 @@ gofiles=""
 pkgfiles=""
 loop=true
 keep=false
+pkgpath=
 prefix=
 dejagnu=no
+GOARCH=""
 timeout=240
 testname=""
 trace=false
@@ -55,6 +57,15 @@ while $loop; do
                basedir=`echo $1 | sed -e 's/^--basedir=//'`
                shift
                ;;
+       x--pkgpath)
+               pkgpath=$2
+               shift
+               shift
+               ;;
+       x--pkgpath=*)
+               pkgpath=`echo $1 | sed -e 's/^--pkgpath=//'`
+               shift
+               ;;
        x--prefix)
                prefix=$2
                shift
@@ -86,6 +97,15 @@ while $loop; do
                dejagnu=`echo $1 | sed -e 's/^--dejagnu=//'`
                shift
                ;;
+       x--goarch)
+               GOARCH=$2
+               shift
+               shift
+               ;;
+       x--goarch=*)
+               GOARCH=`echo $1 | sed -e 's/^--goarch=//'`
+               shift
+               ;;
        x--timeout)
                timeout=$2
                shift
@@ -126,18 +146,20 @@ rm -rf $DIR
 mkdir $DIR
 
 cd $DIR
+mkdir test
+cd test
 
 if test $keep = false; then
-  trap "cd ..; rm -rf $DIR" 0 1 2 3 14 15
+  trap "cd ../..; rm -rf $DIR" 0 1 2 3 14 15
 else
-  trap "cd ..; echo Keeping $DIR" 0 1 2 3 14 15
+  trap "cd ../..; echo Keeping $DIR" 0 1 2 3 14 15
 fi
 
 case "$srcdir" in
        /*)
                ;;
        *)
-               srcdir="../$srcdir"
+               srcdir="../../$srcdir"
                 ;;
 esac
 
@@ -148,7 +170,7 @@ case "$basedir" in
        /*)
                ;;
        *)
-               basedir="../$basedir"
+               basedir="../../$basedir"
                 ;;
 esac
 
@@ -179,10 +201,10 @@ x)
                        b=`basename $f`
                        rm -f $b
                        cp $basedir/$f $b
-                   elif test -f ../$f; then
+                   elif test -f ../../$f; then
                        b=`basename $f`
                        rm -f $b
-                       cp ../$f $b
+                       cp ../../$f $b
                    else
                        echo "file $f not found" 1>&2
                        exit 1
@@ -214,10 +236,10 @@ x)
                        b=`basename $f`
                        rm -f $b
                        cp $basedir/$f $b
-                   elif test -f ../$f; then
+                   elif test -f ../../$f; then
                        b=`basename $f`
                        rm -f $b
-                       cp ../$f $b
+                       cp ../../$f $b
                    else
                        echo "file $f not found" 1>&2
                        exit 1
@@ -298,23 +320,28 @@ set -e
 
 package=`echo ${srcdir} | sed -e 's|^.*libgo/go/||'`
 
+pkgpatharg=
+xpkgpatharg=
 prefixarg=
-if test -n "$prefix"; then
+if test -n "$pkgpath"; then
+       pkgpatharg="-fgo-pkgpath=$pkgpath"
+       xpkgpatharg="-fgo-pkgpath=${pkgpath}_test"
+elif test -n "$prefix"; then
        prefixarg="-fgo-prefix=$prefix"
 fi
 
 if test "$trace" = "true"; then
-  echo $GC -g $prefixarg -c -I . -fno-toplevel-reorder -o _gotest_.o $gofiles $pkgbasefiles
+  echo $GC -g $pkgpatharg $prefixarg -c -I . -fno-toplevel-reorder -o _gotest_.o $gofiles $pkgbasefiles
 fi
-$GC -g $prefixarg -c -I . -fno-toplevel-reorder -o _gotest_.o $gofiles $pkgbasefiles
+$GC -g $pkgpatharg $prefixarg -c -I . -fno-toplevel-reorder -o _gotest_.o $gofiles $pkgbasefiles
 
 if $havex; then
        mkdir -p `dirname $package`
        cp _gotest_.o `dirname $package`/lib`basename $package`.a
        if test "$trace" = "true"; then
-           echo $GC -g -c -I . -fno-toplevel-reorder -o $xofile $xgofiles
+           echo $GC -g $xpkgpatharg -c -I . -fno-toplevel-reorder -o $xofile $xgofiles
        fi
-       $GC -g -c -I . -fno-toplevel-reorder -o $xofile $xgofiles
+       $GC -g $xpkgpatharg -c -I . -fno-toplevel-reorder -o $xofile $xgofiles
 fi
 
 # They all compile; now generate the code to call them.
@@ -326,24 +353,31 @@ localname() {
 }
 
 {
+       text="T"
+       case "$GOARCH" in
+       ppc64) text="D" ;;
+       esac
+
+       symtogo='sed -e s/_test/XXXtest/ -e s/.*_\([^_]*\.\)/\1/ -e s/XXXtest/_test/'
+
        # test functions are named TestFoo
        # the grep -v eliminates methods and other special names
        # that have multiple dots.
        pattern='Test([^a-z].*)?'
        # The -p option tells GNU nm not to sort.
        # The -v option tells Solaris nm to sort by value.
-       tests=$($NM -p -v _gotest_.o $xofile | egrep ' T .*\.'$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | sed 's/.* //' | sed 's/.*\.\(.*\.\)/\1/')
+       tests=$($NM -p -v _gotest_.o $xofile | egrep " $text .*\."$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | fgrep -v ' __go_' | sed 's/.* //' | $symtogo)
        if [ "x$tests" = x ]; then
                echo 'gotest: warning: no tests matching '$pattern in _gotest_.o $xofile 1>&2
                exit 2
        fi
        # benchmarks are named BenchmarkFoo.
        pattern='Benchmark([^a-z].*)?'
-       benchmarks=$($NM -p -v _gotest_.o $xofile | egrep ' T .*\.'$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | sed 's/.* //' | sed 's/.*\.\(.*\.\)/\1/')
+       benchmarks=$($NM -p -v _gotest_.o $xofile | egrep " $test .*\."$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | fgrep -v ' __go_' | sed 's/.* //' | $symtogo)
 
        # examples are named ExampleFoo
        pattern='Example([^a-z].*)?'
-       examples=$($NM -p -v _gotest_.o $xofile | egrep ' T .*\.'$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | sed 's/.* //' | sed 's/.*\.\(.*\.\)/\1/')
+       examples=$($NM -p -v _gotest_.o $xofile | egrep " $text .*\."$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | fgrep -v ' __go_' | sed 's/.* //' | $symtogo)
 
        # package spec
        echo 'package main'
@@ -440,27 +474,27 @@ xno)
        exit $status
        ;;
 xyes)
-       rm -rf ../testsuite/*.o
+       rm -rf ../../testsuite/*.o
        files=`echo *`
        for f in $files; do
                if test "$f" = "_obj" || test "$f" = "_test"; then
                        continue
                fi
-               rm -rf ../testsuite/$f
+               rm -rf ../../testsuite/$f
                if test -f $f; then
-                       cp $f ../testsuite/
+                       cp $f ../../testsuite/
                else
-                       ln -s ../$DIR/$f ../testsuite/
+                       ln -s ../$DIR/test/$f ../../testsuite/
                fi
        done
-       cd ../testsuite
+       cd ../../testsuite
        rm -rf _obj _test
        mkdir _obj _test
        if test "$testname" != ""; then
            GOTESTNAME="$testname"
            export GOTESTNAME
        fi
-       $MAKE check RUNTESTFLAGS="$RUNTESTFLAGS GOTEST_TMPDIR=$DIR"
+       $MAKE check RUNTESTFLAGS="$RUNTESTFLAGS GOTEST_TMPDIR=$DIR/test"
        # Useful when using make check-target-libgo
        cat libgo.log >> libgo-all.log
        cat libgo.sum >> libgo-all.sum