Skip to content

HTTPS clone URL

Subversion checkout URL

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