]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-signing.dtest/main.c
dyld-733.8.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 int main() {
14 printf("[BEGIN] dlopen-signing\n");
15 void* handle = dlopen("signed.dylib", RTLD_LAZY);
16 if ( handle == NULL ) {
17 printf("dlerror(): %s\n", dlerror());
18 printf("[FAIL] dlopen-signing (signed loading signed)\n");
19 return 0;
20 } else {
21 int result = dlclose(handle);
22 if ( result != 0 ) {
23 printf("dlclose() returned %c\n", result);
24 printf("[FAIL] dlopen-signing (signed unloading signed)\n");
25 return 0;
26 }
27 }
28
29 handle = dlopen("unsigned.dylib", RTLD_LAZY);
30 if ( handle != NULL ) {
31 printf("dlerror(): %s\n", dlerror());
32 printf("[FAIL] dlopen-signing (signed loading unsigned)\n");
33 return 0;
34 } else {
35 int result = dlclose(handle);
36 if ( result != 0 ) {
37 printf("dlclose() returned %c\n", result);
38 printf("[FAIL] dlopen-signing (signed unloading signed)\n");
39 return 0;
40 }
41 }
42
43 printf("[PASS] dlopen-signing\n");
44
45 return 0;
46 }
47
48