]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-signing.dtest/main.c
dyld-851.27.tar.gz
[apple/dyld.git] / testing / test-cases / dlopen-signing.dtest / main.c
1 // BUILD: $CC dylib.c -dynamiclib -o $BUILD_DIR/signed.dylib
2 // BUILD: $CC dylib.c -dynamiclib -o $BUILD_DIR/unsigned.dylib
3 // BUILD: $CC main.c -o $BUILD_DIR/dlopen-signed.exe
4 // BUILD: $CC main.c -o $BUILD_DIR/dlopen-unsigned.exe
5
6 // FIXME: add builds that sign the executable and the dylib in in various ways
7 // At this time we don't have a way to do that, so this test must be run
8 // manually.
9
10 #include <stdio.h>
11 #include <dlfcn.h>
12
13 #include "test_support.h"
14
15 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
16 void* handle = dlopen("signed.dylib", RTLD_LAZY);
17 if ( handle == NULL ) {
18 FAIL("dlerror(): %s", dlerror());
19 } else {
20 int result = dlclose(handle);
21 if ( result != 0 ) {
22 FAIL("dlclose() returned %c", result);
23 }
24 }
25
26 handle = dlopen("unsigned.dylib", RTLD_LAZY);
27 if ( handle != NULL ) {
28 FAIL("dlerror(): %s", dlerror());
29 } else {
30 int result = dlclose(handle);
31 if ( result != 0 ) {
32 FAIL("dlclose() returned %c", result);
33 }
34 }
35
36 PASS("Success");
37 }
38
39