summaryrefslogtreecommitdiff
path: root/test/Unit/test
blob: e5f540e94409b48a24eefb1d04db6f227548bfb6 (plain)
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
#!/usr/bin/env bash

ARCHS='<host>'
if test `uname` = "Darwin"; then
  ARCHS="i386 x86_64 ppc"
  LIBS="-lSystem"
else
  LIBS="-lc -lm"
fi

for ARCH in $ARCHS; do
  CFLAGS="-Os -nodefaultlibs"
  if test "$ARCH" != '<host>'; then
    CFLAGS="-arch $ARCH $CFLAGS"
  fi
  for FILE in $(ls *.c); do
    # Use -nodefaultlibs to avoid using libgcc.a
    # Use -lSystem to link with libSystem.dylb.
    # Note -lSystem is *after* libcompiler_rt.Optimized.a so that linker will 
    # prefer our implementation over the ones in libSystem.dylib
    EXTRA=
    if test $FILE = gcc_personality_test.c
    then
      # the gcc_personality_test.c requires a helper C++ program
      EXTRA="-fexceptions gcc_personality_test_helper.cxx -lstdc++ /usr/lib/libgcc_s.1.dylib"
      # the libgcc_s.1.dylib use at the end is a hack until libSystem contains _Unwind_Resume
    fi
    if test $FILE = trampoline_setup_test.c
    then
      # this test requires an extra compiler option
      EXTRA="-fnested-functions"
    fi
    if gcc $CFLAGS $FILE ../../Release/libcompiler_rt.Optimized.a $LIBS $EXTRA
    then
      echo "Testing $FILE for $ARCH"
      if ./a.out
      then
        rm ./a.out
      else
        echo "fail"
        exit 1
      fi
    else
      echo "$FILE failed to compile"
      exit 1
    fi
  done
done
echo "pass"
exit