]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/weak-def-unload.dtest/main.c
dyld-832.7.1.tar.gz
[apple/dyld.git] / testing / test-cases / weak-def-unload.dtest / main.c
1 // BUILD_ONLY: MacOSX
2
3 // BUILD: $CC bar.c -dynamiclib -install_name $RUN_DIR/libmissing.dylib -o $BUILD_DIR/libbar.dylib
4 // BUILD: $CC foo.c -dynamiclib $BUILD_DIR/libbar.dylib -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/libfoo.dylib
5 // BUILD: $CC main.c -o $BUILD_DIR/MATLAB -DRUN_DIR="$RUN_DIR"
6
7 // RUN: ./MATLAB
8
9 // libfoo.dylib was weak-def exported symbols. This tests that it can fail to load cleanly.
10
11 #include <stdio.h>
12 #include <dlfcn.h>
13
14 #include "test_support.h"
15
16
17
18 int main(int argc, const char* argv[])
19 {
20 // force weak-def table to be generated
21 void* handle = dlopen("/usr/lib/libc++.dylib", 0);
22 if ( handle == NULL ) {
23 FAIL("weak-def-unload, expected dlopen(libc++.dylib) to succeed");
24 }
25
26 // try to dlopen something with weak symbols that fails to load
27 handle = dlopen(RUN_DIR "/libfoo.dylib", 0);
28 if ( handle != NULL ) {
29 FAIL("weak-def-unload, expected dlopen to fail");
30 }
31
32 PASS("weak-def-unload");
33 }
34