OSDN Git Service

2002-06-18 Phil Edwards <pme@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / mkcheck.in
index 4289c23..c856b05 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/env bash
 
-
 # Script to do automated testing and data collection for various test
 # files, so that we don't have to do this by hand on every test file.
 # It attempts to collect some diagnostic info about size and speed that
@@ -9,15 +8,7 @@
 # has been enabled.
 
 # Invocation 
-# mkcheck [01] (path to build) (path to src) (path to install)
-
-### XXX There are a lot of tests in here for OS-specific stuff.  If we
-###     move to a 'configure.target' method of determining those extra
-###     flags and whatnot, we can take out all those things and source
-###     that file from here.  (Write that file with this in mind...)
-
-### XXX Note that breaking out of this with ^C will not work.  Dunno why.
-
+# mkcheck [01] 
 
 # 1: variables
 #
 # (0) testing the build binary and headers, or
 # (1) testing the installed binary and headers, or
 WHICH=$1
-if [ "$WHICH"x = 0x ] && [ $# -eq 3 ]; then
+if [ "$WHICH"x = 0x ]; then
   echo "running mkcheck"
   echo "$0: testing the build directory"
-  query="--built-library"
-elif [ "$WHICH"x = 1x ] && [ $# -eq 4 ]; then
+elif [ "$WHICH"x = 1x ]; then
   echo "running mkcheck"
-  echo "$0: testing the install directory $4"
-  query="--installed-library"
+  echo "$0: testing the install directory"
 else
-  echo 'Usage: mkcheck 0 (path to build) (path to src)'
-  echo '       mkcheck 1 (path to build) (path to src) (path to install)'
+  echo 'Usage: mkcheck 0    /* test the build directory    */'
+  echo '       mkcheck 1    /* test the install directory  */'
   exit 1;
 fi
 
@@ -49,28 +38,35 @@ case $BASH_VERSION in
     *)   ;;   # ??
 esac
 
-# Compute the flags necessary to run the testsuite.
-saved_ifs=$IFS
-IFS=':'
-set `./tests_flags ${query} $*` || exit 1
-BUILD_DIR=$1; SRC_DIR=$2; PREFIX_DIR=$3; LTCXX=$4; LIBS=$5; LTEXE=$6; CXX=$7; CXXFLAGS=$8;
-IFS=$saved_ifs
+BUILD_DIR=@glibcpp_builddir@
+SRC_DIR=@glibcpp_srcdir@
+PREFIX_DIR=@glibcpp_prefixdir@
+if [ "$WHICH"x = 0x ]; then
+  CXX=`$BUILD_DIR/testsuite_flags --build-cxx`
+  INCLUDES=`$BUILD_DIR/testsuite_flags --build-includes`
+else
+  CXX=`$BUILD_DIR/testsuite_flags --install-cxx`
+  INCLUDES=`$BUILD_DIR/testsuite_flags --install-includes`
+fi
+CXXFLAGS=`$BUILD_DIR/testsuite_flags --cxxflags`
+LIBTOOL="$BUILD_DIR/libtool"
+LTEXE="$LIBTOOL --mode=execute"
+#LTCXX="$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $INCLUDES"
+LTCXX="$CXX $CXXFLAGS $INCLUDES"
 
-# specific libtool flag(s) to force the use of shared libraries, if any
-SH_FLAG=
+# specific libtool flag(s) to use shared libraries, if any
+SH_FLAG="-Wl,--rpath -Wl,$BUILD_DIR/../../gcc -Wl,--rpath -Wl,$BUILD_DIR/src/.libs"
 
-# specific libtool flag(s) to force the use of static libraries, if any
+# specific libtool flag(s) to use static libraries, if any
 ST_FLAG="-static"
 #ST_FLAG="-all-static"
 
 # Set up the testing directory, which should be in a directory called
 # "testsuite" in the root level of the build directory.
-TEST_DIR="`pwd`/testsuite"
-if [ ! -d "$TEST_DIR" ]; then
-    echo "making directory $TEST_DIR"
-    mkdir $TEST_DIR
-    mkdir $TEST_DIR/.libs    # help libtool keep quiet
-    chmod u+w $TEST_DIR
+TEST_DIR="$BUILD_DIR/testsuite"
+# help libtool keep quiet
+if [ ! -d ${TEST_DIR}/.libs ]; then
+    mkdir $TEST_DIR/.libs    
 fi
 
 # the name of the file that will collect and hold all this useful data:
@@ -82,9 +78,6 @@ LOG_FILE="$TEST_DIR/$(date +%Y%m%d)-mkchecklog.txt"
 # the names of the specific test files to be run
 TESTS_FILE="$TEST_DIR/$(date +%Y%m%d)-mkcheckfiles.txt"
 
-# the heap size limit for testsuite binaries; start with a 2MB limit as per
-# http://gcc.gnu.org/ml/libstdc++/2000-10/msg00029.html
-MAX_MEM_USAGE=3072
 
 #
 # 2: clean, make files, append general test info
@@ -92,6 +85,7 @@ MAX_MEM_USAGE=3072
 
 # Remove old executables.
 rm -rf "$TEST_DIR"/*exe
+rm -rf "$TEST_DIR"/compile.out
 
 # Remove old core files (which now get left in cwd, not $TEST_DIR).
 rm -rf ./*core*
@@ -187,9 +181,9 @@ setup_size_command()
     function size_command()
     {
       case $1 in
-        TEXT)  TEXT=$(size -A $EXENAME | grep ^.text | awk '{print $2}')  ;;
-        DATA)  DATA=$(size -A $EXENAME | grep -w ^.data | awk '{print $2}')  ;;
-        SIZE)  SIZE=$(size -A $EXENAME | grep otal | awk '{print $2}')  ;;
+        TEXT)  TEXT=$(size -B $EXENAME | tail -1 | awk '{print $1}')  ;;
+        DATA)  DATA=$(size -B $EXENAME | tail -1 | awk '{print $2}')  ;;
+        SIZE)  SIZE=$(size -B $EXENAME | tail -1 | awk '{print $4}')  ;;
       esac
     }
   else
@@ -207,6 +201,16 @@ setup_size_command()
           esac
         }
         ;;
+      *hpux*)
+        function size_command()
+        {
+          case $1 in
+            TEXT)  TEXT=$(size  $EXENAME | awk '{print $1}')  ;;
+            DATA)  DATA=$(size  $EXENAME | awk '{print $3}')  ;;
+            SIZE)  SIZE=$(size  $EXENAME | awk '{print $7}')  ;;
+          esac
+        }
+        ;;
       *irix*)
         function size_command()
         {
@@ -261,9 +265,9 @@ test_for_output()
     # this is the name of the resulting diff file, if any
     DIFF_FILE="`echo $TEST_NAME | sed 's/cc$/diff/'`"
     # construct wildcard names, ie for $NAME=filebuf.cc, makes "filebuf*.tst"
-    DATA_FILES="`echo $NAME | sed 's/\.cc/\*\.tst/g'`"
+    DATA_FILES="`echo $TEST_NAME | sed 's/\.cc/\*\.tst/g'`"
     # make sure there is at least one, then go
-    ST_E="`echo $NAME | sed 's/\.cc/\-1\.tst/g'`"
+    ST_E="`echo $TEST_NAME | sed 's/\.cc/\-1\.tst/g'`"
     if [ -f $ST_E ]; then
         # list of actual files that match the wildcard above, ie
         # "filebuf-1.tst"
@@ -275,7 +279,6 @@ test_for_output()
             diff $ST_OUT_FILE $i > $DIFF_FILE
             if [ -s $DIFF_FILE ]; then
                 RESULT="-r"
-                echo "$ST_OUT_FILE has some problems, dude"
             else
                 RESULT="+"
             fi
@@ -311,7 +314,9 @@ test_file()
     # and harder as we try compiling at, say, top of the hour; we would
     # eventually have to calculate time_t anyhow.  Or 3) just grab two
     # time_t's (no more overhead than grabbing two date(1)'s).
-    compiler_invocation="$LTCXX $S_FLAG $SRC_NAME -o $EXENAME $LIBS"
+    our_libs="-L$TEST_DIR -lv3test"
+    compiler_invocation="$LTCXX $S_FLAG $SRC_NAME -o $EXENAME $our_libs"
+    echo $compiler_invocation >> compile.out 2>&1
     COMP_TIME_START=$($TIMER_COMMAND)
     $compiler_invocation >> compile.out 2>&1
     COMP_TIME_END=$($TIMER_COMMAND)
@@ -323,7 +328,7 @@ test_file()
     fi
 
     if [ -f $EXENAME ]; then
-        rm compile.out
+#        rm compile.out
         size_command TEXT
         size_command DATA
         size_command SIZE
@@ -332,17 +337,12 @@ test_file()
         # printed by the executable will be lost and cannot be redirected,
         # because we need to capture the output of 'time'.  Bummer.
         TIMEFORMAT='timemark %R'
-        E_TIME_TEXT="$(exec 2>&1; ulimit -d $MAX_MEM_USAGE; \
-                     time $LTEXE $EXENAME)"
+        E_TIME_TEXT="$(exec 2>&1; time $LTEXE $EXENAME)"
         E_ABNORMAL_TERMINATION=$?
-        E_TIME="$(echo $E_TIME_TEXT | awk '{print $2}')"
-        # joining those two commands does not work due to quoting problems:
-        #E_TIME="$(exec 2>&1; time $EXENAME | awk '{print $2}')"
-        # this will work as a fallback on certain systems...?
-        #E_TIME=$(exec 2>&1; time $EXENAME | cut -d ' ' -f 2)
  
         if [ "$E_ABNORMAL_TERMINATION" -ne 0 ]; then
             RESULT='-r'
+           E_TIME="0"
             rm -f ./*core
             # sometimes you want to save all core files for review:
             #mv ./core $EXENAME.core
@@ -351,10 +351,13 @@ test_file()
             #mv ./core* $EXENAME.core
         else
             test_for_output
+           # XXX This doesn't always result in a number.
+           # E_TIME="$(echo $E_TIME_TEXT | awk '{print $2}')"
+           E_TIME="0"
         fi
 
         # sometimes you want to save all failing exe files for review:
-        if [ "$RESULT" = "+" ]; then
+        if [ "$RESULT" = '+' ]; then
             rm "$EXENAME"
         fi
     else
@@ -385,8 +388,7 @@ test_file()
 
     printf "%s\t" "$RESULT"
     printf "%-2s %d\t%.3f\t%s\t%s\t%s\t%s %s\n"   \
-        "$RESULT" $C_TIME $E_TIME $TEXT $DATA $SIZE $NAME "$S_FLAG"    \
-        >> $RESULTS_FILE
+        "$RESULT" $C_TIME $E_TIME $TEXT $DATA $SIZE $NAME >> $RESULTS_FILE
 }
 
 setup_size_command
@@ -429,7 +431,7 @@ TEST_TIME_END=$($TIMER_COMMAND)
 # grep can count faster than we can...
 total_failures=`expr ${shared_fail} + ${static_fail}`
 total_successes=`expr ${shared_pass} + ${static_pass}`
-resultstext="pass/fail results:  ${shared_pass}/${shared_fail} shared + ${static_pass}/${static_fail} static = ${total_successes}/${total_failures} total"
+resultstext="pass/fail results:  ${static_pass}/${static_fail} static + ${shared_pass}/${shared_fail} shared = ${total_successes}/${total_failures} total"
 if [ $total_failures -eq 0 ]; then
     resultstext="${resultstext}, WIN WIN"
 fi
@@ -444,5 +446,3 @@ if [ $TEST_TIME_START -lt $TEST_TIME_END ]; then
 fi
 
 exit 0
-
-