]>
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
11 #include "test_support.h"
13 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
14 // try to dlopen() a text file
15 void* handle
= dlopen(RUN_DIR
"/libnota.dylib", RTLD_FIRST
);
16 if ( handle
!= NULL
) {
17 FAIL("Should have failed on non-mach-o file %s", RUN_DIR
"/libnota.dylib");
19 const char* message
= dlerror();
20 if ( (strstr(message
, "mach-o") == NULL
) && (strstr(message
, "too short") == NULL
) ) {
21 FAIL("dlerror() message '%s' did not contain 'mach-o'", message
);
24 // try to dlopen() a directory
25 handle
= dlopen(RUN_DIR
, RTLD_FIRST
);
26 if ( handle
!= NULL
) {
27 FAIL("Should have failed on dir %s", RUN_DIR
);
30 if ( strstr(message
, "not a file") == NULL
) {
31 FAIL("dlerror() message '%s' did not contain 'not a file", message
);