]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dyld-insert-library-double.dtest/main.cpp
2 // BOOT_ARGS: dyld_flags=2
4 // BUILD: $CC main.cpp -std=c++11 -o $BUILD_DIR/double_insert_main.exe
5 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/libfoo.dylib
6 // BUILD: $CC bar.c -dynamiclib -install_name $RUN_DIR/libbar.dylib -o $BUILD_DIR/libbar.dylib
7 // BUILD: $DYLD_ENV_VARS_ENABLE $BUILD_DIR/double_insert_main.exe
9 // Load foo and bar at the same time to ensure that paths separated by ':'' are working
11 // RUN: DYLD_INSERT_LIBRARIES="$RUN_DIR/libfoo.dylib:$RUN_DIR/libbar.dylib" ./double_insert_main.exe
17 #include <mach-o/dyld_priv.h>
19 bool gFoundLibrary
= false;
20 const char* gLibraryName
= NULL
;
22 bool wasImageLoaded(const char* libraryName
) {
23 gFoundLibrary
= false;
24 gLibraryName
= libraryName
;
25 _dyld_register_for_image_loads([](const mach_header
* mh
, const char* path
, bool unloadable
) {
26 if ( strstr(path
, gLibraryName
) != NULL
) {
31 printf("[FAIL] dyld-insert-library-double: expected insert to pass for '%s'\n", libraryName
);
37 printf("[BEGIN] dyld-insert-library-double\n");
39 if (!wasImageLoaded("libfoo.dylib") || !wasImageLoaded("libbar.dylib")) {
43 printf("[PASS] dyld-insert-library-double\n");