]> git.saurik.com Git - apple/libc.git/blob - tests/runtests
Libc-1082.50.1.tar.gz
[apple/libc.git] / tests / runtests
1 #!/bin/bash -e
2 # Copyright 2009-2014 Apple Inc. All rights reserved.
3
4 BINDIR="%%BINDIR%%"
5 BINDIR="${BINDIR/%%*%%/.}"
6
7 # If not already set by bsdtesttool
8 if [ -z "$BSDTESTS_TMPDIR" ]; then
9 BSDTESTS_TMPDIR="$(mktemp -d -t bsdtests)/"
10 export BSDTESTS_TMPDIR
11 echo "Using temp dir $BSDTESTS_TMPDIR"
12 fi
13
14 function dotest {
15 T="\"$BINDIR\"/bsdtestharness ./$1"
16 LOG="${BSDTESTS_TMPDIR}$1${2:+.$2}"
17 SEP="\n**** %-40s ****\n"
18
19 if [ -n "$BSDTESTS_STRESS" ]; then
20 x=0
21 while (( x < BSDTESTS_STRESS )); do
22 printf "$SEP" "$1 $2 stress $x"
23 eval $ENVIRON $T 2>&1 | tee -a "$LOG.$x.testlog"
24 let x+=1
25 done
26 else
27 printf "$SEP" "$1 $2"
28 eval $ENVIRON $T 2>&1 | tee -a "$LOG.testlog"
29 if [ -z "$BSDTESTS_PREBUILD" ]; then
30 printf "$SEP" "$1 debug $2"
31 eval $ENVIRON DYLD_IMAGE_SUFFIX=_debug $T 2>&1 | tee -a "$LOG.debuglog"
32 fi
33 fi
34 }
35
36 function runtest {
37 echo; echo " Libc test: $1 ..."
38 ENVIRON="LIBDISPATCH_LOG=NO"
39 dotest "$1"
40 if [ -n "$(lipo -info /usr/lib/libSystem.dylib 2>&- | grep i386)" \
41 -a "$(sysctl -n hw.optional.x86_64 2>&-)" = "1" ]; then
42 ENVIRON="$ENVIRON BSDTEST_ARCH=i386"
43 dotest "$1" "i386"
44 fi
45 }
46
47 cd $(dirname $0)
48 rm -f "${BSDTESTS_TMPDIR}"*.{test,debug,gctest,gcdebug,leaks}log
49
50 if [ "$1" == "--nosummary" ]; then
51 NOSUMMARY=1; shift
52 fi
53
54 if [ "$#" -gt 0 ]; then
55 if [ "$1" == "--help" ]; then
56 echo "Usage: $0 [--nosummary] [<test>|<test>|...]";
57 echo " --nosummary run all tests but do not summarize results at the end"
58 exit 0;
59 fi
60 for T in "$@"; do runtest $T; done
61 else
62 for T in $(cat test_list.txt); do runtest $T; done
63 fi
64
65 if [ -z "$NOSUMMARY" -a -x "$BINDIR"/bsdtestsummarize ]; then
66 shopt -s nullglob
67 cat "${BSDTESTS_TMPDIR}"*.{test,debug,gctest,gcdebug}log | "$BINDIR"/bsdtestsummarize
68 fi
69