]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-basic.dtest/main.c
2 // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/test.dylib
3 // BUILD: $CC foo.c -bundle -o $BUILD_DIR/test.bundle
4 // BUILD: $CC main.c -DRUN_DIR="$RUN_DIR" -o $BUILD_DIR/dlopen-basic.exe
6 // RUN: ./dlopen-basic.exe
11 #include "test_support.h"
13 static void tryImage(const char* path
)
15 void* handle
= dlopen(path
, RTLD_LAZY
);
16 if ( handle
== NULL
) {
17 FAIL("dlopen(\"%s\"), dlerror()=%s", path
, dlerror());
20 void* sym
= dlsym(handle
, "foo");
22 FAIL("dlsym(\"foo\") for \"%s\" returned NULL, dlerror()=%s", path
, dlerror());
25 int result
= dlclose(handle
);
27 FAIL("dlclose(\"%s\") returned %d, dlerror()=%s", path
, result
, dlerror());
33 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
34 tryImage(RUN_DIR
"/test.bundle");
35 tryImage(RUN_DIR
"/test.dylib");