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