]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-bad-file.dtest/main.c
2 // BUILD: cp bad.txt $BUILD_DIR/libnota.dylib
3 // BUILD: $CC main.c -o $BUILD_DIR/dlopen-bad-file.exe -DRUN_DIR="$RUN_DIR"
5 // RUN: ./dlopen-bad-file.exe
15 printf("[BEGIN] dlopen-bad-file\n");
17 // try to dlopen() a text file
18 void* handle
= dlopen(RUN_DIR
"/libnota.dylib", RTLD_FIRST
);
19 if ( handle
!= NULL
) {
20 printf("[FAIL] dlopen-bad-file should have failed on non-mach-o file %s\n", RUN_DIR
"/libnota.dylib");
23 const char* message
= dlerror();
24 if ( (strstr(message
, "mach-o") == NULL
) && (strstr(message
, "too short") == NULL
) ) {
25 printf("dlerror: %s\n", message
);
26 printf("[FAIL] dlopen-bad-file dlerror() message did not contain 'mach-o'\n");
30 // try to dlopen() a directory
31 handle
= dlopen(RUN_DIR
, RTLD_FIRST
);
32 if ( handle
!= NULL
) {
33 printf("[FAIL] dlopen-bad-file should have failed on dir %s\n", RUN_DIR
);
37 if ( strstr(message
, "not a file") == NULL
) {
38 printf("dlerror: %s\n", message
);
39 printf("[FAIL] dlopen-bad-file dlerror() message did not contain 'not a file'\n");
43 printf("[PASS] dlopen-bad-file\n");