]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/macOS-cache-rebuild.dtest/main.c
dyld-733.8.tar.gz
[apple/dyld.git] / testing / test-cases / macOS-cache-rebuild.dtest / main.c
1 // BUILD_ONLY: MacOSX
2
3 // BUILD: $CC main.c -o $BUILD_DIR/rebuild-dyld-cache.exe
4
5 // RUN: ./rebuild-dyld-cache.exe
6
7
8 #include <stdio.h>
9 #include <dlfcn.h>
10 #include <unistd.h>
11 #include <signal.h>
12 #include <spawn.h>
13 #include <errno.h>
14 #include <sys/uio.h>
15 #include <sys/wait.h>
16 #include <sys/types.h>
17
18 extern char** environ;
19
20 int main()
21 {
22 printf("[BEGIN] macOS-cache-rebuild\n");
23
24 const char* argv[] = { "/usr/bin/update_dyld_shared_cache", "-cache_dir", "/tmp/", NULL };
25 pid_t child;
26 int psResult = posix_spawn(&child, "/usr/bin/update_dyld_shared_cache", NULL, NULL, (char**)argv, environ);
27 if ( psResult != 0 ) {
28 printf("[FAIL] macOS-cache-rebuild: posix_spawn failed, err=%d\n", psResult);
29 return 0;
30 }
31
32 int childStatus;
33 (void)wait4(child, &childStatus, 0, NULL);
34 if (WIFEXITED(childStatus) == 0)
35 printf("[FAIL] macOS-cache-rebuild: update_dyld_shared_cache did not exit\n");
36 else if (WEXITSTATUS(childStatus) != 0)
37 printf("[FAIL] macOS-cache-rebuild: update_dyld_shared_cache failed\n");
38 else
39 printf("[PASS] macOS-cache-rebuild\n");
40
41 return 0;
42 }
43