-
Notifications
You must be signed in to change notification settings - Fork 63
/
runtests.sh
executable file
·117 lines (90 loc) · 3.49 KB
/
runtests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/sh
#
# Copyright 2011 Shinichiro Hamaji. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY Shinichiro Hamaji ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Shinichiro Hamaji OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
set -e
# Run small unit tests
for i in mach/*.bin; do
echo "Running $i"
./ld-mac ./$i
done
# Run regressions tests with real compilers
MAC_TOOL_DIR=/usr/i686-apple-darwin10
MAC_BIN_DIR=$MAC_TOOL_DIR/usr/bin
apple() {
gcc="$1"
shift
PATH=$MAC_BIN_DIR ./ld-mac $MAC_BIN_DIR/$gcc --sysroot=$MAC_TOOL_DIR "$@"
}
# Run GCC with ld-mac
echo "Running gcc -c mach/hello.c"
./ld-mac $MAC_BIN_DIR/gcc -c mach/hello.c
echo "Running gcc mach/hello.c"
./ld-mac $MAC_BIN_DIR/gcc mach/hello.c
echo "Running gcc -g mach/hello.c"
PATH=$MAC_BIN_DIR ./ld-mac $MAC_BIN_DIR/gcc -g mach/hello.c
# Run clang with ld-mac
echo "Running clang -c mach/hello.c"
./ld-mac $MAC_BIN_DIR/clang -c mach/hello.c
# Check dylib
echo "Running dylib tests"
apple gcc -g -dynamiclib mach/dylib/lib.c -o mach/dylib/lib.dylib
apple gcc -g mach/dylib/main.c mach/dylib/lib.dylib -o mach/dylib/main
echo "Running mach/dylib/main"
./ld-mac mach/dylib/main
echo "Running dylib tests"
apple gcc -g -dynamiclib mach/dylib/lib.c -o mach/dylib/lib.dylib
apple gcc -g mach/dylib/main.c mach/dylib/lib.dylib -o mach/dylib/main
echo "Running mach/dylib/main"
./ld-mac mach/dylib/main
apple gcc -g mach/dylib/dlfcn.c -o mach/dylib/dlfcn
echo "Running mach/dylib/dlfcn"
./ld-mac mach/dylib/dlfcn
# Check dylib with weak symbols
echo "Running dylib tests with a weak symbol"
apple g++ -g -fPIC -dynamiclib mach/dylib/weak_lib.cc -o mach/dylib/weak_lib.dylib
apple g++ -g -fPIC mach/dylib/weak_main.cc -o mach/dylib/weak_main mach/dylib/weak_lib.dylib
apple g++ -g -fPIC mach/dylib/weak_main.cc -o mach/dylib/weak_main-dl -DDL
echo "Running mach/dylib/weak_main"
./ld-mac mach/dylib/weak_main
echo "Running mach/dylib/weak_main-dl"
./ld-mac mach/dylib/weak_main-dl
# Compile and run unit tests with clang
# Need this file from Xcode 4
CLANG=$MAC_BIN_DIR/clang-137
if [ -x $CLANG ]; then
for i in mach/*.c; do
echo "Compiling $i with clang"
./ld-mac $CLANG -Wl,-syslibroot,$MAC_TOOL_DIR -isysroot $MAC_TOOL_DIR $i -o $i.clang.bin
echo "Running $i.clang.bin"
./ld-mac $i.clang.bin
done
else
echo "$CLANG not found, skipping some tests with it"
fi
echo
echo '*** ALL TESTS PASS ***'