2000-04-21 22:33:34 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
|
|
|
|
# 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
|
|
|
|
# should be useful in the future as the library gets tuned for size
|
|
|
|
# and speed. In addition, it tests static and shared linkage, iff each
|
|
|
|
# has been enabled.
|
2000-05-18 06:41:24 +02:00
|
|
|
|
|
|
|
# Invocation
|
2000-06-27 20:01:32 +02:00
|
|
|
# mkcheck [012] (path to build) (path to src) (path to install)
|
2000-04-21 22:33:34 +02:00
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
### 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.
|
|
|
|
|
|
|
|
|
2000-04-21 22:33:34 +02:00
|
|
|
#
|
|
|
|
# 1: variables
|
|
|
|
#
|
2000-06-27 20:01:32 +02:00
|
|
|
# WHICH determines if you are
|
|
|
|
# (0) testing the build binary and headers, or
|
|
|
|
# (1) testing the installed binary and headers, or
|
|
|
|
# (2) testing under dejagnu (just print the standard flags needed).
|
2000-04-21 22:33:34 +02:00
|
|
|
WHICH=$1
|
2000-06-27 20:01:32 +02:00
|
|
|
if [ "$WHICH"x = 0x ] && [ $# -eq 3 ]; then
|
|
|
|
echo "running mkcheck"
|
2000-04-21 22:33:34 +02:00
|
|
|
echo "$0: testing the build directory"
|
2000-06-27 20:01:32 +02:00
|
|
|
elif [ "$WHICH"x = 1x ] && [ $# -eq 4 ]; then
|
|
|
|
echo "running mkcheck"
|
2000-05-26 21:59:46 +02:00
|
|
|
echo "$0: testing the install directory $4"
|
2000-06-27 20:01:32 +02:00
|
|
|
elif [ "$WHICH"x = 2x ] && [ $# -eq 3 ]; then
|
|
|
|
true
|
|
|
|
else
|
|
|
|
echo 'Usage: mkcheck 0 (path to build) (path to src)'
|
|
|
|
echo ' mkcheck 1 (path to build) (path to src) (path to install)'
|
|
|
|
echo ' mkcheck 2 (path to build) (path to src)'
|
|
|
|
exit 1;
|
2000-04-21 22:33:34 +02:00
|
|
|
fi
|
2000-06-27 20:01:32 +02:00
|
|
|
|
2000-04-21 22:33:34 +02:00
|
|
|
BUILD_DIR=$2
|
|
|
|
if [ ! -d "$BUILD_DIR" ]; then
|
|
|
|
echo "build directory $BUILD_DIR not found, exiting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
SRC_DIR=$3
|
|
|
|
if [ ! -d "$SRC_DIR" ]; then
|
|
|
|
echo "source directory $SRC_DIR not found, exiting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $WHICH -eq 1 ]; then
|
|
|
|
PREFIX_DIR=$4
|
|
|
|
if [ ! -d "$PREFIX_DIR" ]; then
|
|
|
|
echo "install directory $PREFIX_DIR not found, exiting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
# This is LIBTOOL=@LIBTOOL@ piped through a bit of sanity that we can
|
|
|
|
# assume for this script (by the time we run this).
|
|
|
|
LIBTOOL="$BUILD_DIR/libtool"
|
|
|
|
chmod u+x $LIBTOOL
|
|
|
|
|
2000-04-21 22:33:34 +02:00
|
|
|
# INC_PATH == include path to new headers for use on gcc command-line
|
2000-10-26 09:28:25 +02:00
|
|
|
top_srcdir=@top_srcdir@
|
2000-10-12 13:45:23 +02:00
|
|
|
C_DIR="`basename @C_INCLUDE_DIR@`"
|
2000-04-21 22:33:34 +02:00
|
|
|
if [ $WHICH != "1" ]; then
|
2000-10-31 02:26:06 +01:00
|
|
|
INC_PATH="-nostdinc++ @CSHADOW_FLAGS@ -I$BUILD_DIR/include \
|
2000-10-12 13:45:23 +02:00
|
|
|
-I$SRC_DIR/include/std -I$SRC_DIR/include/$C_DIR \
|
2000-10-19 01:26:22 +02:00
|
|
|
-I$SRC_DIR/include -I$SRC_DIR/libsupc++ -I$SRC_DIR/libio \
|
2000-10-06 09:13:29 +02:00
|
|
|
-I$SRC_DIR/testsuite"
|
2000-04-21 22:33:34 +02:00
|
|
|
elif [ $WHICH -eq 1 ]; then
|
2000-11-14 00:49:41 +01:00
|
|
|
INC_PATH="-I$SRC_DIR/testsuite"
|
2000-04-21 22:33:34 +02:00
|
|
|
fi
|
|
|
|
|
2000-06-27 20:01:32 +02:00
|
|
|
if [ $WHICH -eq 2 ]; then
|
2000-10-26 09:28:25 +02:00
|
|
|
echo $INC_PATH -I$SRC_DIR/include/backward -I$SRC_DIR/include/ext
|
2000-06-27 20:01:32 +02:00
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
|
2000-11-16 02:03:20 +01:00
|
|
|
# This has been true all along. Found out about it the hard way...
|
|
|
|
case $BASH_VERSION in
|
|
|
|
1*) echo 'You need bash 2.x to run mkcheck. Exiting.'; exit 1 ;;
|
|
|
|
*) ;; # ??
|
|
|
|
esac
|
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
# It's not dejagnu; we need to do things ourselves. Pick up any extra
|
|
|
|
# settings for this target.
|
|
|
|
. ${top_srcdir}/configure.target
|
|
|
|
|
|
|
|
# LIB_PATH == where to find the build libraries for libtool's use
|
|
|
|
# CXX == how to call the compiler
|
|
|
|
if [ $WHICH -eq 0 ]; then
|
|
|
|
LIB_PATH="$BUILD_DIR/src"
|
2000-10-24 19:00:59 +02:00
|
|
|
CXX="$BUILD_DIR/../../gcc/g++ -B$BUILD_DIR/../../gcc/"
|
2000-04-21 22:33:34 +02:00
|
|
|
elif [ $WHICH -eq 1 ]; then
|
2000-06-01 04:55:30 +02:00
|
|
|
LIB_PATH="$PREFIX_DIR/lib"
|
2000-04-21 22:33:34 +02:00
|
|
|
CXX="$PREFIX_DIR/bin/g++"
|
|
|
|
fi
|
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
# gcc compiler flags (maybe use glibcpp_cxxflags from configure.target,
|
|
|
|
# but thst's really meant for building the library itself, not using it)
|
|
|
|
CXX_FLAG="-ggdb3 -DDEBUG_ASSERT @SECTION_FLAGS@ @SECTION_LDFLAGS@"
|
2000-04-21 22:33:34 +02:00
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
# specific libtool flag(s) to force the use of shared libraries, if any
|
2000-05-18 06:41:24 +02:00
|
|
|
SH_FLAG=""
|
2000-04-21 22:33:34 +02:00
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
# specific libtool flag(s) to force the use of static libraries, if any
|
|
|
|
#ST_FLAG="-static"
|
|
|
|
ST_FLAG="-all-static"
|
|
|
|
|
|
|
|
# LTCXX == how to call libtool when creating an executable
|
|
|
|
# LTEXE == how to call libtool when running an executable
|
|
|
|
# LIBS == any extra needed -l switches, etc (may need more libs, lose lose)
|
|
|
|
if [ $WHICH -eq 0 ]; then
|
|
|
|
LTCXX="$LIBTOOL --tag=CXX --mode=link \
|
|
|
|
$CXX $CXX_FLAG $INC_PATH \
|
|
|
|
$LIB_PATH/../libsupc++/libsupc++.la $LIB_PATH/libstdc++.la \
|
|
|
|
-no-install"
|
|
|
|
LTEXE="$LIBTOOL --mode=execute"
|
|
|
|
LIBS="-nodefaultlibs -lc -lgcc -lc"
|
|
|
|
elif [ $WHICH -eq 1 ]; then
|
|
|
|
# For the installed version, we really only need to use libtool and
|
|
|
|
# the .la file to get correct rpaths.
|
|
|
|
LTCXX="$LIBTOOL --tag=CXX --mode=link \
|
|
|
|
$CXX $CXX_FLAG $INC_PATH -L$LIB_PATH \
|
|
|
|
$LIB_PATH/libstdc++.la -no-install -rpath $LIB_PATH"
|
|
|
|
LTEXE="$LIBTOOL --mode=execute"
|
|
|
|
LIBS=
|
|
|
|
fi
|
2000-04-21 22:33:34 +02:00
|
|
|
|
|
|
|
# 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
|
2000-11-14 00:49:41 +01:00
|
|
|
mkdir $TEST_DIR/.libs # help libtool keep quiet
|
|
|
|
chmod u+w $TEST_DIR
|
2000-04-21 22:33:34 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# the name of the file that will collect and hold all this useful data:
|
|
|
|
RESULTS_FILE="$TEST_DIR/$(date +%Y%m%d)-mkcheck.txt"
|
|
|
|
|
|
|
|
# the name of the log file that will append compiler diagnostics:
|
|
|
|
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"
|
|
|
|
|
2000-10-25 14:48:34 +02:00
|
|
|
# the heap size limit for testsuite binaries; start with a 2MB limit as per
|
|
|
|
# http://sources.redhat.com/ml/libstdc++/2000-10/msg00029.html
|
|
|
|
MAX_MEM_USAGE=3072
|
2000-04-21 22:33:34 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# 2: clean, make files, append general test info
|
|
|
|
#
|
|
|
|
if [ -f $RESULTS_FILE ]; then
|
|
|
|
rm $RESULTS_FILE
|
|
|
|
fi
|
|
|
|
if [ -f $LOG_FILE ]; then
|
|
|
|
rm $LOG_FILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make a list of the files we're going to run, or use an old one if it exists.
|
|
|
|
if [ ! -f "$TESTS_FILE" ]; then
|
|
|
|
echo "making file $TESTS_FILE"
|
|
|
|
for LONG_NAME in $SRC_DIR/testsuite/*/*.cc
|
|
|
|
do
|
2000-11-14 00:49:41 +01:00
|
|
|
DIR_NAME=$(dirname $LONG_NAME)
|
|
|
|
SHORT_NAME="`basename $DIR_NAME`/`basename $LONG_NAME`"
|
|
|
|
echo "$SHORT_NAME" >> $TESTS_FILE
|
2000-04-21 22:33:34 +02:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Nasty solution to replace GNU date(1)'s %s time_t output function.
|
|
|
|
if [ ! -x "$TEST_DIR/printnow" ]; then
|
|
|
|
echo "making utility $TEST_DIR/printnow"
|
|
|
|
gcc -o "$TEST_DIR/printnow" "$SRC_DIR/testsuite/printnow.c"
|
|
|
|
strip "$TEST_DIR/printnow"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Remove old executables.
|
2000-04-30 18:12:56 +02:00
|
|
|
rm -rf "$TEST_DIR"/*exe
|
|
|
|
|
|
|
|
# Remove old core files (which now get left in cwd, not $TEST_DIR).
|
2000-11-14 00:49:41 +01:00
|
|
|
rm -rf ./*core*
|
2000-04-21 22:33:34 +02:00
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
# Copy over the data files for filebufs
|
2000-04-21 22:33:34 +02:00
|
|
|
cp $SRC_DIR/testsuite/27_io/*.txt $TEST_DIR
|
|
|
|
cp $SRC_DIR/testsuite/27_io/*.tst $TEST_DIR
|
2000-06-26 20:58:19 +02:00
|
|
|
chmod u+w $TEST_DIR/*.txt
|
|
|
|
chmod u+w $TEST_DIR/*.tst
|
2000-04-21 22:33:34 +02:00
|
|
|
|
|
|
|
# Emit useful info about compiler and platform
|
|
|
|
echo "host: $(uname -mrsv)" >> $RESULTS_FILE
|
2000-07-08 03:08:44 +02:00
|
|
|
echo "compiler: $($CXX -v 2>&1 | tail -1)" >> $RESULTS_FILE
|
2000-11-14 00:49:41 +01:00
|
|
|
echo "$($CXX -v 2>&1 | grep ^Configured)" >> $RESULTS_FILE
|
2000-05-18 06:41:24 +02:00
|
|
|
echo "compiler flags: $CXX_FLAG" >> $RESULTS_FILE
|
2000-04-21 22:33:34 +02:00
|
|
|
echo "date: $(date +%Y%m%d)" >> $RESULTS_FILE
|
|
|
|
echo "" >> $RESULTS_FILE
|
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
explanation='+: pass, -b: build failure, -r: run failure, x: disabled'
|
|
|
|
printf "%s\n %s\n" 'p == pass/fail execution test' "$explanation" \
|
|
|
|
>> $RESULTS_FILE
|
2000-04-21 22:33:34 +02:00
|
|
|
echo "ctime == time to compile and link" >> $RESULTS_FILE
|
2000-05-18 06:41:24 +02:00
|
|
|
echo "etime == time for executable to run" >> $RESULTS_FILE
|
2000-04-21 22:33:34 +02:00
|
|
|
echo "text == size of the executable text section" >> $RESULTS_FILE
|
|
|
|
echo "data == size of the executable data section" >> $RESULTS_FILE
|
|
|
|
echo "total == size of the executable" >> $RESULTS_FILE
|
|
|
|
echo "" >> $RESULTS_FILE
|
2000-05-26 21:59:46 +02:00
|
|
|
echo "(First static, then shared.)" >> $RESULTS_FILE
|
2000-04-21 22:33:34 +02:00
|
|
|
|
|
|
|
echo "p" | awk '{printf("%s ", $1)}' >> $RESULTS_FILE
|
|
|
|
echo "ctime" "etime" | awk '{printf("%s\t%s\t", $1, $2)}' >> $RESULTS_FILE
|
|
|
|
echo "text" "data" | awk '{printf("%s\t%s\t", $1, $2)}' >> $RESULTS_FILE
|
|
|
|
echo "total" "name" | awk '{printf("%s\t%s\t", $1, $2)}' >> $RESULTS_FILE
|
|
|
|
echo "" >> $RESULTS_FILE
|
2000-11-14 00:49:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# 2.5: support functions
|
|
|
|
#
|
|
|
|
|
|
|
|
# Figure out how to extract size information from binaries. We take
|
|
|
|
# the text of the value we want as an argument, and leave the size in
|
|
|
|
# the appropriate variable.
|
|
|
|
#
|
|
|
|
# We discover what kind of size(1) we are using *once* and build a shell
|
|
|
|
# function named 'size_command' to wrap it. (The "function" keyword is
|
|
|
|
# redundant here, but helps me read it, so there.) Previously we were
|
|
|
|
# re-discovering the size(1) arguments three times for each test; sloooow.
|
|
|
|
#
|
|
|
|
# It is VERY IMPORTANT not to compare these numbers across platforms.
|
|
|
|
# Different size(1)'s extract section information differently. For
|
|
|
|
# example, using the native Sun size(1) and GNU size(1) built for Suns
|
|
|
|
# on the exact same binary will give very different numbers, due to all
|
|
|
|
# the variance in command-line options and arbitrary names of ELF sections.
|
|
|
|
#
|
|
|
|
# and suddenly we go to 2-space indentations...
|
|
|
|
setup_size_command()
|
|
|
|
{
|
|
|
|
if size --version 2> /dev/null | grep -c GNU > /dev/null;
|
|
|
|
then # Then we're using a GNU size(1) built for this platform.
|
|
|
|
# We lose .rodata and .data1 and who knows what else... kludge.
|
|
|
|
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}') ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
else
|
|
|
|
# Not using GNU size; check for platform. These numbers seem to match
|
|
|
|
# up to text/data/total, although their meanings seem to be different.
|
|
|
|
# THIS TABLE IS SORTED. KEEP IT THAT WAY.
|
|
|
|
case @host_os@ in
|
|
|
|
*aix*)
|
|
|
|
function size_command()
|
|
|
|
{
|
|
|
|
case $1 in
|
|
|
|
TEXT) TEXT=$(size -X32_64 $EXENAME | awk '{print $2}') ;;
|
|
|
|
DATA) DATA=$(size -X32_64 $EXENAME | awk '{print $4}') ;;
|
|
|
|
SIZE) SIZE=$(size -X32_64 $EXENAME | awk '{print $12}') ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
;;
|
2000-11-15 21:08:59 +01:00
|
|
|
*irix*)
|
|
|
|
function size_command()
|
|
|
|
{
|
|
|
|
case $1 in
|
|
|
|
TEXT) TEXT=$(size -4 $EXENAME | awk '{print $1}') ;;
|
|
|
|
DATA) DATA=$(size -4 $EXENAME | awk '{print $3}') ;;
|
|
|
|
SIZE) SIZE=$(size -4 $EXENAME | awk '{print $7}') ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
;;
|
2000-11-14 00:49:41 +01:00
|
|
|
*solaris*)
|
|
|
|
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
|
|
|
|
}
|
|
|
|
;;
|
|
|
|
*)
|
2000-11-14 17:38:02 +01:00
|
|
|
echo ' * Warning! Skipping section sizes!' 1>&2
|
2000-11-14 00:49:41 +01:00
|
|
|
function size_command()
|
|
|
|
{
|
|
|
|
case $1 in
|
2000-11-14 17:38:02 +01:00
|
|
|
TEXT) TEXT=0 ;;
|
|
|
|
DATA) DATA=0 ;;
|
|
|
|
SIZE) SIZE=0 ;;
|
2000-11-14 00:49:41 +01:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test for file output
|
|
|
|
test_for_output()
|
|
|
|
{
|
|
|
|
# This checks for emitted output files, which is useful when
|
|
|
|
# testing file-related output. The rules for this working are as
|
|
|
|
# follows: the emitted file must have the ".txt" extension, and be
|
|
|
|
# based on the actual *.cc file's name. For example, 27/filbuf.cc
|
|
|
|
# currently outputs files named 27/filebuf-2.txt and 27/filebuf-3.txt.
|
|
|
|
# Also, the first emitted file must be in the form $NAME-1.txt.
|
|
|
|
# The control file must follow the same constraints, but have a
|
|
|
|
# ".tst" extension. Thus, you have 27/filebuf-2.tst, etc.
|
|
|
|
|
|
|
|
# NAME contains the source name, like 27/filebuf.cc
|
|
|
|
# From that NAME, we want to generate some possible names, using
|
|
|
|
# ls on MATCH, a pattern description generated with sed.
|
|
|
|
|
|
|
|
# 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'`"
|
|
|
|
# make sure there is at least one, then go
|
|
|
|
ST_E="`echo $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"
|
|
|
|
ST_MATCH_LIST="`ls $DATA_FILES`"
|
|
|
|
for i in $ST_MATCH_LIST; do
|
|
|
|
# ST_OUT_FILE is generated in the build directory.
|
|
|
|
PRE_NAME2="$TEST_DIR/`basename $i`"
|
|
|
|
ST_OUT_FILE="`echo $PRE_NAME2 | sed 's/tst$/txt/'`"
|
|
|
|
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
|
|
|
|
rm $DIFF_FILE
|
|
|
|
done
|
|
|
|
else
|
|
|
|
# the file does no output, and didn't abnormally
|
|
|
|
# terminate, so assume passed.
|
|
|
|
RESULT="+"
|
|
|
|
fi
|
|
|
|
}
|
2000-04-21 22:33:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# 3: compile, link, execute, time
|
|
|
|
#
|
2000-05-18 06:41:24 +02:00
|
|
|
# Abstract out the common code for compiling, linking, executing and printing.
|
|
|
|
test_file()
|
|
|
|
{
|
|
|
|
# NB: S_FLAG has to be last argument because it may be null, and
|
|
|
|
# error checking hasn't been invented yet.
|
2000-06-13 01:56:56 +02:00
|
|
|
NAME=$1
|
2000-05-18 06:41:24 +02:00
|
|
|
EXENAME=$2
|
|
|
|
S_FLAG=$3
|
2000-04-21 22:33:34 +02:00
|
|
|
|
2000-06-13 01:56:56 +02:00
|
|
|
SRC_NAME="$SRC_DIR/testsuite/$1"
|
|
|
|
TEST_NAME="$TEST_DIR/`basename $NAME`"
|
|
|
|
|
2000-04-21 22:33:34 +02:00
|
|
|
# This would be deliciously easy if GNU date's %s were always around.
|
|
|
|
# There are three ways to do this: 1) use the builtin 'time' like we
|
|
|
|
# do later; then getting compiler errors into LOG_FILE is a nightmare.
|
|
|
|
# 2) Grab the output of a formatted date(1) and do the math; harder
|
|
|
|
# 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).
|
2000-11-14 00:49:41 +01:00
|
|
|
compiler_invocation="$LTCXX $S_FLAG $SRC_NAME -o $EXENAME $LIBS"
|
|
|
|
# Why the leading weird character, like a colon? That way you can
|
|
|
|
# 'grep -v ^: *mkchecklog.txt' and just see the errors.
|
|
|
|
#printf "\n: " >> $LOG_FILE
|
|
|
|
printf "\n" >> $LOG_FILE
|
2000-04-21 22:33:34 +02:00
|
|
|
COMP_TIME_START=$($TEST_DIR/printnow)
|
2000-11-14 00:49:41 +01:00
|
|
|
$compiler_invocation >> $LOG_FILE 2>&1
|
2000-04-21 22:33:34 +02:00
|
|
|
COMP_TIME_END=$($TEST_DIR/printnow)
|
|
|
|
|
|
|
|
if [ $COMP_TIME_START -lt $COMP_TIME_END ]; then
|
2000-11-14 00:49:41 +01:00
|
|
|
C_TIME=$[ $COMP_TIME_END - $COMP_TIME_START ]
|
2000-04-21 22:33:34 +02:00
|
|
|
else
|
2000-11-14 00:49:41 +01:00
|
|
|
C_TIME="0"
|
2000-04-21 22:33:34 +02:00
|
|
|
fi
|
|
|
|
|
2000-05-18 06:41:24 +02:00
|
|
|
if [ -f $EXENAME ]; then
|
2000-11-14 00:49:41 +01:00
|
|
|
size_command TEXT
|
|
|
|
size_command DATA
|
|
|
|
size_command SIZE
|
2000-04-21 22:33:34 +02:00
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
# Actually run the executable and time it. Note that output
|
|
|
|
# printed by the executable will be lost and cannot be redirected,
|
|
|
|
# because we need to capture the output of 'time'. Bummer.
|
2000-04-21 22:33:34 +02:00
|
|
|
TIMEFORMAT='timemark %R'
|
2000-11-14 00:49:41 +01:00
|
|
|
E_TIME_TEXT="$(exec 2>&1; ulimit -d $MAX_MEM_USAGE; \
|
|
|
|
time $LTEXE $EXENAME)"
|
|
|
|
E_ABNORMAL_TERMINATION=$?
|
2000-04-21 22:33:34 +02:00
|
|
|
E_TIME="$(echo $E_TIME_TEXT | awk '{print $2}')"
|
|
|
|
# joining those two commands does not work due to quoting problems:
|
2000-05-18 06:41:24 +02:00
|
|
|
#E_TIME="$(exec 2>&1; time $EXENAME | awk '{print $2}')"
|
2000-04-21 22:33:34 +02:00
|
|
|
# this will work as a fallback on certain systems...?
|
2000-05-18 06:41:24 +02:00
|
|
|
#E_TIME=$(exec 2>&1; time $EXENAME | cut -d ' ' -f 2)
|
2000-04-21 22:33:34 +02:00
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
if [ "$E_ABNORMAL_TERMINATION" -ne 0 ]; then
|
|
|
|
RESULT='-r'
|
|
|
|
rm -f ./*core
|
|
|
|
# sometimes you want to save all core files for review:
|
|
|
|
#mv ./core $EXENAME.core
|
|
|
|
# sometimes the OS allows you to name core files yourself:
|
|
|
|
#mv ./*core $EXENAME.core
|
|
|
|
#mv ./core* $EXENAME.core
|
|
|
|
else
|
|
|
|
test_for_output
|
|
|
|
fi
|
|
|
|
|
|
|
|
# sometimes you want to save all failing exe files for review:
|
|
|
|
if [ "$RESULT" = "+" ]; then
|
|
|
|
rm "$EXENAME"
|
|
|
|
fi
|
2000-04-21 22:33:34 +02:00
|
|
|
else
|
2000-11-14 00:49:41 +01:00
|
|
|
# the file did not compile/link.
|
|
|
|
RESULT="-b"
|
|
|
|
TEXT="0"
|
|
|
|
DATA="0"
|
|
|
|
SIZE="0"
|
2000-04-21 22:33:34 +02:00
|
|
|
fi
|
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
printf "%s\t" "$RESULT"
|
|
|
|
printf "%-2s %d\t%.3f\t%s\t%s\t%s\t%s\n" \
|
|
|
|
"$RESULT" $C_TIME $E_TIME $TEXT $DATA $SIZE $NAME >> $RESULTS_FILE
|
|
|
|
}
|
2000-05-18 06:41:24 +02:00
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
setup_size_command
|
|
|
|
echo ""
|
|
|
|
echo "Detailed test results in .${RESULTS_FILE/$BUILD_DIR}"
|
|
|
|
echo $explanation
|
2000-05-18 06:41:24 +02:00
|
|
|
echo "------------------------------------------------------------------------"
|
2000-11-14 00:49:41 +01:00
|
|
|
printf "static\tshared\ttest\n"
|
2000-05-18 06:41:24 +02:00
|
|
|
echo "------------------------------------------------------------------------"
|
|
|
|
|
|
|
|
TEST_TIME_START=$($TEST_DIR/printnow)
|
2000-11-14 17:38:02 +01:00
|
|
|
for NAME in `cat $TESTS_FILE`
|
2000-05-18 06:41:24 +02:00
|
|
|
do
|
|
|
|
PRE_NAME="$TEST_DIR/`basename $NAME`"
|
|
|
|
ST_NAME="`echo $PRE_NAME | sed 's/cc$/st-exe/'`"
|
|
|
|
SH_NAME="`echo $PRE_NAME | sed 's/cc$/sh-exe/'`"
|
|
|
|
|
2000-11-14 00:49:41 +01:00
|
|
|
if test @enable_static@ = yes; then
|
|
|
|
test_file $NAME $ST_NAME $ST_FLAG
|
|
|
|
else
|
|
|
|
printf "x\t"
|
|
|
|
printf "static skipped\n" >> $RESULTS_FILE
|
|
|
|
fi
|
|
|
|
if test @enable_shared@ = yes; then
|
|
|
|
test_file $NAME $SH_NAME $SH_FLAG
|
|
|
|
else
|
|
|
|
printf "x\t"
|
|
|
|
printf "shared skipped\n" >> $RESULTS_FILE
|
|
|
|
fi
|
|
|
|
printf "%s\n" "$NAME"
|
2000-04-21 22:33:34 +02:00
|
|
|
|
|
|
|
echo "" >> $RESULTS_FILE
|
|
|
|
done
|
2000-05-18 06:41:24 +02:00
|
|
|
TEST_TIME_END=$($TEST_DIR/printnow)
|
2000-04-21 22:33:34 +02:00
|
|
|
|
2000-05-18 06:41:24 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# 4: summary
|
|
|
|
#
|
2000-04-21 22:33:34 +02:00
|
|
|
# grep can count faster than we can...
|
|
|
|
total_failures=$(egrep -c "^\-" $RESULTS_FILE)
|
|
|
|
total_successes=$(egrep -c "^\+" $RESULTS_FILE)
|
|
|
|
resultstext="pass/fail results: ${total_successes}/${total_failures}"
|
|
|
|
if [ $total_failures -eq 0 ]; then
|
|
|
|
resultstext="${resultstext}, WIN WIN"
|
|
|
|
fi
|
|
|
|
sed -e "/^date:/a\\
|
|
|
|
$resultstext" $RESULTS_FILE > ${RESULTS_FILE}.tmp
|
|
|
|
mv ${RESULTS_FILE}.tmp $RESULTS_FILE
|
|
|
|
|
2000-05-18 06:41:24 +02:00
|
|
|
if [ $TEST_TIME_START -lt $TEST_TIME_END ]; then
|
|
|
|
TEST_TIME=$[ $TEST_TIME_END - $TEST_TIME_START ]
|
2000-11-14 00:49:41 +01:00
|
|
|
echo "testrun == $TEST_TIME seconds"
|
|
|
|
echo "testrun == $TEST_TIME seconds" >> $RESULTS_FILE
|
2000-05-18 06:41:24 +02:00
|
|
|
fi
|
|
|
|
|
2000-04-21 22:33:34 +02:00
|
|
|
exit 0
|
|
|
|
|
2000-10-25 14:48:34 +02:00
|
|
|
|