]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-fail-cleanly.dtest/main.c
ceee099ebc6f791f491f9b8666be0d744c615240
2 // BUILD: $CC c.c -dynamiclib -o $TEMP_DIR/libcextra.dylib -install_name $RUN_DIR/libc.dylib -DEXTRA_SYMBOL=1
3 // BUILD: $CC c.c -dynamiclib -o $BUILD_DIR/libc.dylib -install_name $RUN_DIR/libc.dylib
4 // BUILD: $CC b.m -dynamiclib -o $BUILD_DIR/libb.dylib -install_name $RUN_DIR/libb.dylib $TEMP_DIR/libcextra.dylib -framework Foundation
5 // BUILD: $CC a.c -dynamiclib -o $BUILD_DIR/liba.dylib -install_name $RUN_DIR/liba.dylib $BUILD_DIR/libb.dylib
6 // BUILD: $CC main.c -DRUN_DIR="$RUN_DIR" -o $BUILD_DIR/dlopen-fail-cleanly.exe
8 // RUN: ./dlopen-fail-cleanly.exe
13 #include <mach-o/dyld.h>
18 printf("[BEGIN] dlopen-fail-cleanly\n");
20 // dlopen dylib chain that should fail
21 void* handle
= dlopen(RUN_DIR
"/liba.dylib", RTLD_NOW
);
22 if ( handle
!= NULL
) {
23 printf("[FAIL] dlopen-fail-cleanly dlopen(liba.dylib) expected to fail but did not\n");
27 // iterate loaded images and make sure no residue from failed dlopen
28 const char* foundPath
= NULL
;
29 int count
= _dyld_image_count();
30 for (int i
=0; i
< count
; ++i
) {
31 const char* path
= _dyld_get_image_name(i
);
32 //printf("path[%2d]=%s\n", i, path);
33 if ( strstr(path
, RUN_DIR
"/lib") != NULL
) {
34 printf("[FAIL] dlopen-fail-cleanly: found unexpected loaded image: %s\n", path
);
39 printf("[PASS] dlopen-fail-cleanly\n");