2013-04-24 03:53:24 +08:00
|
|
|
#!/bin/sh
|
2010-05-12 03:42:16 +08:00
|
|
|
# //===--------------------------- testit ---------------------------------===//
|
|
|
|
# //
|
2010-05-12 05:36:01 +08:00
|
|
|
# // The LLVM Compiler Infrastructure
|
2010-05-12 03:42:16 +08:00
|
|
|
# //
|
|
|
|
# // This file is distributed under the University of Illinois Open Source
|
|
|
|
# // License. See LICENSE.TXT for details.
|
|
|
|
# //
|
|
|
|
# //===--------------------------------------------------------------------===//
|
|
|
|
|
2012-12-09 08:12:14 +08:00
|
|
|
currentpath=`pwd`
|
|
|
|
origpath=$currentpath
|
|
|
|
currentdir=`basename $currentpath`
|
|
|
|
while [ $currentdir != "test" ]; do
|
2013-07-04 23:11:10 +08:00
|
|
|
if [ $currentdir = "/" ]
|
2012-12-09 08:12:14 +08:00
|
|
|
then
|
|
|
|
echo "current directory must be in or under \"test\"."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
currentpath=`pwd`
|
|
|
|
currentdir=`basename $currentpath`
|
|
|
|
done
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
LIBCXX_ROOT=`pwd`
|
|
|
|
cd $origpath
|
|
|
|
|
2012-04-19 08:50:47 +08:00
|
|
|
if [ -z "$CC" ]
|
2010-05-12 03:42:16 +08:00
|
|
|
then
|
2012-02-22 08:20:30 +08:00
|
|
|
if which xcrun >/dev/null
|
|
|
|
then
|
|
|
|
CC="xcrun clang++"
|
|
|
|
else
|
|
|
|
CC=clang++
|
|
|
|
fi
|
2010-05-12 03:42:16 +08:00
|
|
|
fi
|
|
|
|
|
2014-01-15 01:00:40 +08:00
|
|
|
if [ -z "$CXX_LANG" ]
|
|
|
|
then
|
2014-01-15 01:04:06 +08:00
|
|
|
CXX_LANG=c++11
|
2014-01-15 01:00:40 +08:00
|
|
|
fi
|
2010-05-12 03:42:16 +08:00
|
|
|
if [ -z "$OPTIONS" ]
|
|
|
|
then
|
2014-01-15 01:00:40 +08:00
|
|
|
OPTIONS="-std=${CXX_LANG} -stdlib=libc++"
|
2010-05-12 03:42:16 +08:00
|
|
|
fi
|
2013-01-05 11:21:01 +08:00
|
|
|
OPTIONS="$OPTIONS -I$LIBCXX_ROOT/test/support"
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2012-12-09 08:12:14 +08:00
|
|
|
if [ -z "$HEADER_INCLUDE" ]
|
|
|
|
then
|
|
|
|
HEADER_INCLUDE="-I$LIBCXX_ROOT/include"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$SOURCE_LIB" ]
|
|
|
|
then
|
|
|
|
SOURCE_LIB="-L$LIBCXX_ROOT/lib"
|
|
|
|
fi
|
|
|
|
|
2011-10-01 23:34:27 +08:00
|
|
|
case $TRIPLE in
|
|
|
|
*-*-mingw* | *-*-cygwin* | *-*-win*)
|
|
|
|
TEST_EXE=test.exe
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
TEST_EXE=a.out
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2013-05-03 03:21:36 +08:00
|
|
|
case $(uname -s) in
|
|
|
|
NetBSD)
|
|
|
|
THREAD_FLAGS=-lpthread
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
FAIL=0
|
|
|
|
PASS=0
|
|
|
|
UNIMPLEMENTED=0
|
|
|
|
IMPLEMENTED_FAIL=0
|
|
|
|
IMPLEMENTED_PASS=0
|
|
|
|
|
2013-04-24 03:53:24 +08:00
|
|
|
afunc() {
|
2010-05-12 03:42:16 +08:00
|
|
|
fail=0
|
|
|
|
pass=0
|
2014-01-16 00:28:42 +08:00
|
|
|
if (ls ${TEST_PREFIX}*fail.cpp > /dev/null 2>&1)
|
2010-05-12 03:42:16 +08:00
|
|
|
then
|
2014-01-16 00:28:42 +08:00
|
|
|
for FILE in $(ls ${TEST_PREFIX}*fail.cpp); do
|
2013-04-24 03:53:24 +08:00
|
|
|
if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE > /dev/null 2>&1
|
2010-05-12 03:42:16 +08:00
|
|
|
then
|
2011-10-01 23:34:27 +08:00
|
|
|
rm ./$TEST_EXE
|
2010-05-12 03:42:16 +08:00
|
|
|
echo "$FILE should not compile"
|
2013-04-24 03:53:24 +08:00
|
|
|
fail=$(($fail+1))
|
2010-05-12 03:42:16 +08:00
|
|
|
else
|
2013-04-24 03:53:24 +08:00
|
|
|
pass=$(($pass+1))
|
2010-05-12 03:42:16 +08:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2010-08-22 09:04:38 +08:00
|
|
|
|
2014-01-16 00:28:42 +08:00
|
|
|
if (ls ${TEST_PREFIX}*pass.cpp > /dev/null 2>&1)
|
2010-05-12 03:42:16 +08:00
|
|
|
then
|
2014-01-16 00:28:42 +08:00
|
|
|
for FILE in $(ls ${TEST_PREFIX}*pass.cpp); do
|
2013-03-26 23:28:33 +08:00
|
|
|
if [ "$VERBOSE" ]
|
|
|
|
then
|
|
|
|
echo "Running test: " $FILE
|
|
|
|
fi
|
2013-05-03 03:21:36 +08:00
|
|
|
if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) -o ./$TEST_EXE
|
2010-05-12 03:42:16 +08:00
|
|
|
then
|
2011-10-01 23:34:27 +08:00
|
|
|
if ./$TEST_EXE
|
2010-05-12 03:42:16 +08:00
|
|
|
then
|
2011-10-01 23:34:27 +08:00
|
|
|
rm ./$TEST_EXE
|
2013-04-24 03:53:24 +08:00
|
|
|
pass=$(($pass+1))
|
2010-05-12 03:42:16 +08:00
|
|
|
else
|
2012-02-29 21:00:44 +08:00
|
|
|
echo "`pwd`/$FILE failed at run time"
|
2013-05-03 03:21:36 +08:00
|
|
|
echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS)
|
2013-04-24 03:53:24 +08:00
|
|
|
fail=$(($fail+1))
|
2011-10-01 23:34:27 +08:00
|
|
|
rm ./$TEST_EXE
|
2010-05-12 03:42:16 +08:00
|
|
|
fi
|
|
|
|
else
|
2012-02-29 21:00:44 +08:00
|
|
|
echo "`pwd`/$FILE failed to compile"
|
2013-05-03 03:21:36 +08:00
|
|
|
echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS)
|
2013-04-24 03:53:24 +08:00
|
|
|
fail=$(($fail+1))
|
2010-05-12 03:42:16 +08:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $fail -gt 0 ]
|
|
|
|
then
|
|
|
|
echo "failed $fail tests in `pwd`"
|
2013-04-24 03:53:24 +08:00
|
|
|
IMPLEMENTED_FAIL=$(($IMPLEMENTED_FAIL+1))
|
2010-05-12 03:42:16 +08:00
|
|
|
fi
|
|
|
|
if [ $pass -gt 0 ]
|
|
|
|
then
|
|
|
|
echo "passed $pass tests in `pwd`"
|
|
|
|
if [ $fail -eq 0 ]
|
|
|
|
then
|
2013-04-24 03:53:24 +08:00
|
|
|
IMPLEMENTED_PASS=$((IMPLEMENTED_PASS+1))
|
2010-05-12 03:42:16 +08:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ $fail -eq 0 -a $pass -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "not implemented: `pwd`"
|
2013-04-24 03:53:24 +08:00
|
|
|
UNIMPLEMENTED=$(($UNIMPLEMENTED+1))
|
2010-05-12 03:42:16 +08:00
|
|
|
fi
|
|
|
|
|
2013-04-24 03:53:24 +08:00
|
|
|
FAIL=$(($FAIL+$fail))
|
|
|
|
PASS=$(($PASS+$pass))
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
for FILE in *
|
|
|
|
do
|
|
|
|
if [ -d "$FILE" ];
|
|
|
|
then
|
|
|
|
cd $FILE
|
2013-05-03 03:21:36 +08:00
|
|
|
if [ $FILE = thread -o $1 = yes ]; then
|
|
|
|
afunc yes
|
|
|
|
else
|
|
|
|
afunc no
|
|
|
|
fi
|
2010-05-12 03:42:16 +08:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-05-03 03:21:36 +08:00
|
|
|
afunc no
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
echo "****************************************************"
|
|
|
|
echo "Results for `pwd`:"
|
|
|
|
echo "using `$CC --version`"
|
2011-02-15 02:06:10 +08:00
|
|
|
echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB"
|
2010-05-12 03:42:16 +08:00
|
|
|
echo "----------------------------------------------------"
|
|
|
|
echo "sections without tests : $UNIMPLEMENTED"
|
|
|
|
echo "sections with failures : $IMPLEMENTED_FAIL"
|
|
|
|
echo "sections without failures: $IMPLEMENTED_PASS"
|
|
|
|
echo " + ----"
|
|
|
|
echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))"
|
|
|
|
echo "----------------------------------------------------"
|
|
|
|
echo "number of tests failed : $FAIL"
|
|
|
|
echo "number of tests passed : $PASS"
|
|
|
|
echo " + ----"
|
|
|
|
echo "total number of tests : $(($FAIL+$PASS))"
|
|
|
|
echo "****************************************************"
|
|
|
|
|
|
|
|
exit $FAIL
|