]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/interpose-weak.dtest/main.c
1 // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/libfoo.dylib -install_name $RUN_DIR/libfoo.dylib
2 // BUILD: $CC main.c $BUILD_DIR/libfoo.dylib -o $BUILD_DIR/interpose-weak-present.exe
3 // BUILD: $DYLD_ENV_VARS_ENABLE $BUILD_DIR/interpose-weak-present.exe
4 // BUILD: $CC interposer.c -dynamiclib $BUILD_DIR/libfoo.dylib -o $BUILD_DIR/libinterposer.dylib -install_name libinterposer.dylib
6 // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/foo34/libfoo2.dylib -install_name $RUN_DIR/libfoo2.dylib
7 // BUILD: $CC foo.c -DNO_FOO34 -dynamiclib -o $BUILD_DIR/libfoo2.dylib -install_name $RUN_DIR/libfoo2.dylib
8 // BUILD: $CC main.c -DNO_FOO34 $BUILD_DIR/foo34/libfoo2.dylib -o $BUILD_DIR/interpose-weak-missing.exe
9 // BUILD: $DYLD_ENV_VARS_ENABLE $BUILD_DIR/interpose-weak-missing.exe
10 // BUILD: $CC interposer.c -dynamiclib $BUILD_DIR/foo34/libfoo2.dylib -o $BUILD_DIR/libinterposer2.dylib -install_name libinterposer.dylib
12 // BUILD: $SKIP_INSTALL $BUILD_DIR/foo34/libfoo2.dylib
14 // RUN: DYLD_INSERT_LIBRARIES=libinterposer.dylib ./interpose-weak-present.exe
15 // RUN: DYLD_INSERT_LIBRARIES=libinterposer2.dylib ./interpose-weak-missing.exe
23 #include "test_support.h"
27 extern int foo3() __attribute__((weak_import
));
28 extern int foo4() __attribute__((weak_import
));
31 #define MODE "present"
33 #define MODE "missing"
36 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
38 FAIL(MODE
", foo1() != 1");
42 FAIL(MODE
", foo2() != 12");
47 FAIL(MODE
", foo3() != 3");
51 FAIL(MODE
", foo4() != 14");
54 if ( &foo3
!= NULL
) {
55 FAIL(MODE
", &foo3 != NULL");
58 if ( &foo4
!= NULL
) {
59 FAIL(MODE
", &foo4 != NULL");