]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/interpose-resolver.dtest/main.c
dyld-733.6.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 extern int foo();
15 int (*pFoo)() = &foo;
16
17 int main()
18 {
19 #if INTERPOSED
20 printf("[BEGIN] interpose-resolver\n");
21 if ( foo() != 11 )
22 printf("[FAIL] interpose-resolver: foo() != 11\n");
23 else if ( (*pFoo)() != 11 )
24 printf("[FAIL] interpose-resolver: *pFoo() != 11\n");
25 else
26 printf("[PASS] interpose-resolver\n");
27 #else
28 printf("[BEGIN] resolver-only\n");
29 if ( foo() != 10 )
30 printf("[FAIL] resolver-only: foo() != 10\n");
31 else if ( (*pFoo)() != 10 )
32 printf("[FAIL] resolver-only: *pFoo() != 10\n");
33 else
34 printf("[PASS] resolver-only\n");
35 #endif
36 return 0;
37 }