]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/env-DYLD_LIBRARY_PATH-cache.dtest/main.c
2 // BUILD: mkdir -p $BUILD_DIR/override
3 // BUILD: mkdir -p $BUILD_DIR/re-export-override
4 // BUILD: $CC myzlib.c -dynamiclib -o $BUILD_DIR/override/libz.1.dylib -install_name /usr/lib/libz.1.dylib -compatibility_version 1.0 -framework CoreFoundation
5 // BUILD: $CC reexported-myzlib.c -dynamiclib -o $BUILD_DIR/re-export-override/reexported.dylib -compatibility_version 1.0 -framework CoreFoundation -install_name $RUN_DIR/re-export-override/reexported.dylib
6 // BUILD: $CC reexporter.c -dynamiclib -o $BUILD_DIR/re-export-override/libz.1.dylib -install_name /usr/lib/libz.1.dylib -compatibility_version 1.0 -Wl,-reexport_library,$BUILD_DIR/re-export-override/reexported.dylib -Wl,-debug_variant
7 // BUILD: $CC main.c -o $BUILD_DIR/env-DYLD_LIBRARY_PATH-cache.exe -lz
8 // BUILD: $DYLD_ENV_VARS_ENABLE $BUILD_DIR/env-DYLD_LIBRARY_PATH-cache.exe
10 // RUN: ./env-DYLD_LIBRARY_PATH-cache.exe
11 // RUN: DYLD_LIBRARY_PATH=$RUN_DIR/override/ ./env-DYLD_LIBRARY_PATH-cache.exe
12 // RUN: DYLD_LIBRARY_PATH=$RUN_DIR/re-export-override/ ./env-DYLD_LIBRARY_PATH-cache.exe
19 #include <mach-o/dyld_priv.h>
21 // The test here is to override libz.1.dylib which is in the dyld cache with our own implementation.
25 bool expectMyDylib
= (getenv("DYLD_LIBRARY_PATH") != NULL
) && !_dyld_shared_cache_optimized();
27 printf("[BEGIN] env-DYLD_LIBRARY_PATH-cache, %s\n", expectMyDylib
? "my" : "os");
29 bool usingMyDylib
= (strcmp(zlibVersion(), "my") == 0);
31 if ( usingMyDylib
== expectMyDylib
)
32 printf("[PASS] env-DYLD_LIBRARY_PATH-cache, %s\n", expectMyDylib
? "my" : "os");
34 printf("[FAIL] env-DYLD_LIBRARY_PATH-cache, %s\n", expectMyDylib
? "my" : "os");