dyld-750.5.tar.gz
[apple/dyld.git] / testing / test-cases / interpose-resolver.dtest / main.c
1
2 // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/libfoo.dylib -install_name $RUN_DIR/libfoo.dylib
3 // BUILD: $CC interposer.c -dynamiclib -o $BUILD_DIR/libmyinterpose.dylib -install_name $RUN_DIR/libmyinterpose.dylib $BUILD_DIR/libfoo.dylib
4 // BUILD: $CC main.c $BUILD_DIR/libfoo.dylib -o $BUILD_DIR/resolver-only.exe
5 // BUILD: $CC main.c $BUILD_DIR/libfoo.dylib -o $BUILD_DIR/interposed-resolver.exe -DINTERPOSED $BUILD_DIR/libmyinterpose.dylib
6
7 // RUN: ./resolver-only.exe
8 // RUN: ./interposed-resolver.exe
9
10
11 #include <stdio.h>
12 #include <stdlib.h>
13
14 #include "test_support.h"
15
16 extern int foo();
17 int (*pFoo)() = &foo;
18
19 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
20 #if INTERPOSED
21 if ( foo() != 11 )
22 FAIL("foo() != 11");
23 else if ( (*pFoo)() != 11 )
24 FAIL("*pFoo() != 11");
25 else
26 PASS("Success");
27 #else
28 if ( foo() != 10 )
29 FAIL(" foo() != 10");
30 else if ( (*pFoo)() != 10 )
31 FAIL(" *pFoo() != 10");
32 else
33 PASS("Success");
34 #endif
35 }