dyld-832.7.1.tar.gz
[apple/dyld.git] / testing / test-cases / _dyld_shared_cache_contains_path.dtest / main.c
1
2 // BUILD: $CC main.c -o $BUILD_DIR/_dyld_shared_cache_contains_path.exe
3
4 // RUN: ./_dyld_shared_cache_contains_path.exe
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <mach-o/dyld_priv.h>
10 #include <dlfcn.h>
11
12 #include "test_support.h"
13
14 int main(int argc, const char* argv[], const char* envp[], const char* apple[])
15 {
16 size_t length;
17 bool hasCache = ( _dyld_get_shared_cache_range(&length) != NULL );
18
19 if ( _dyld_shared_cache_contains_path("/usr/lib/libSystem.B.dylib") != hasCache ) {
20 if ( hasCache )
21 FAIL("libSystem.B.dylib is not in dyld cache");
22 else
23 FAIL("no cache, but libSystem.B.dylib is in dyld cache");
24 }
25
26 if ( _dyld_shared_cache_contains_path("/System/Library/Frameworks/Foundation.framework/Foundation") != hasCache ) {
27 if ( hasCache )
28 FAIL("Foundation.framework is not in dyld cache");
29 else
30 FAIL("no cache, but Foundation.framework is in dyld cache");
31 }
32
33 #if TARGET_OS_OSX
34 if ( _dyld_shared_cache_contains_path("/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation") != hasCache ) {
35 if ( hasCache )
36 FAIL("Current/Foundation.framework is not in dyld cache");
37 else
38 FAIL("no cache, but Current/Foundation.framework is in dyld cache");
39 }
40 #endif
41
42
43 PASS("SUCCESS");
44 }
45