]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-RTLD_NOLOAD.dtest/main.c
2 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/libfoo.dylib
3 // BUILD: $CC main.c $BUILD_DIR/libfoo.dylib -o $BUILD_DIR/dlopen-RTLD_NOLOAD-basic.exe
4 // BUILD: cd $BUILD_DIR && ln -s libfoo.dylib libfoo-sym.dylib
6 // RUN: ./dlopen-RTLD_NOLOAD-basic.exe
16 printf("[BEGIN] dlopen-RTLD_NOLOAD-basic\n");
19 /// This tests that RTLD_NOLOAD finds existing dylib statically linked
21 void* handle
= dlopen("libfoo.dylib", RTLD_NOLOAD
);
22 if ( handle
== NULL
) {
23 printf("[FAIL] dlopen-RTLD_NOLOAD-basic: dlopen(libfoo.dylib, RTLD_NOLOAD) failed but it should have worked: %s\n", dlerror());
26 void* sym
= dlsym(handle
, "foo");
28 printf("[FAIL] dlopen-RTLD_NOLOAD-basic: dlsym(handle, \"foo\") failed but it should have worked: %s\n", dlerror());
33 /// This tests that RTLD_NOLOAD verifies that non-existant dylib returns NULL
35 void* handle2
= dlopen("libfobbulate.dylib", RTLD_NOLOAD
);
36 if ( handle2
!= NULL
) {
37 printf("[FAIL] dlopen-RTLD_NOLOAD-basic: dlopen(libfobbulate.dylib, RTLD_NOLOAD) succeeded but it should have failed\n");
43 /// This tests that RTLD_NOLOAD finds symlink to existing dylib
45 void* handle3
= dlopen("libfoo-sym.dylib", RTLD_NOLOAD
);
46 if ( handle3
== NULL
) {
47 printf("[FAIL] dlopen-RTLD_NOLOAD-basic: dlopen(libfoo-sym.dylib, RTLD_NOLOAD) failed but it should have worked: %s\n", dlerror());
51 printf("[PASS] dlopen-RTLD_NOLOAD-basic\n");