]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/env-DYLD_LIBRARY_PATH-cache.dtest/main.c
dyld-750.5.tar.gz
[apple/dyld.git] / testing / test-cases / env-DYLD_LIBRARY_PATH-cache.dtest / main.c
1
2 // 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
3 // 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
4 // 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
5 // BUILD: $CC main.c -o $BUILD_DIR/env-DYLD_LIBRARY_PATH-cache.exe -lz
6 // BUILD: $DYLD_ENV_VARS_ENABLE $BUILD_DIR/env-DYLD_LIBRARY_PATH-cache.exe
7
8 // RUN: ./env-DYLD_LIBRARY_PATH-cache.exe
9 // RUN: DYLD_LIBRARY_PATH=$RUN_DIR/override/ ./env-DYLD_LIBRARY_PATH-cache.exe
10 // RUN: DYLD_LIBRARY_PATH=$RUN_DIR/re-export-override/ ./env-DYLD_LIBRARY_PATH-cache.exe
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <zlib.h>
16 #include <stdbool.h>
17 #include <mach-o/dyld_priv.h>
18
19 #include "test_support.h"
20
21 // The test here is to override libz.1.dylib which is in the dyld cache with our own implementation.
22
23 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
24 bool expectMyDylib = (getenv("DYLD_LIBRARY_PATH") != NULL) && !_dyld_shared_cache_optimized();
25
26 bool usingMyDylib = (strcmp(zlibVersion(), "my") == 0);
27
28 if ( usingMyDylib == expectMyDylib )
29 PASS("Succes");
30 else
31 FAIL("Expected %s, got %s", expectMyDylib ? "my" : "os", expectMyDylib ? "os" : "my");
32 }
33