]>
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: $CXX 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 #include "test_support.h"
21 bool gFoundLibrary
= false;
22 const char* gLibraryName
= NULL
;
24 bool wasImageLoaded(const char* libraryName
) {
25 gFoundLibrary
= false;
26 gLibraryName
= libraryName
;
27 _dyld_register_for_image_loads([](const mach_header
* mh
, const char* path
, bool unloadable
) {
28 if ( strstr(path
, gLibraryName
) != NULL
) {
33 FAIL("Expected insert to pass for '%s'", libraryName
);
37 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
38 if (!wasImageLoaded("libfoo.dylib") || !wasImageLoaded("libbar.dylib")) {