]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/macOS-cache-rebuild.dtest/main.cpp
dyld-750.5.tar.gz
[apple/dyld.git] / testing / test-cases / macOS-cache-rebuild.dtest / main.cpp
1 // BUILD_ONLY: MacOSX
2
3 // BUILD: $CXX main.cpp -o $BUILD_DIR/rebuild-dyld-cache.exe
4
5 // FIXME: This test will not make sense when remove update_dyld_shared_cache, and the functionality will be subsummed by root testing
6 // ./rebuild-dyld-cache.exe
7
8
9 #include <stdio.h>
10 #include <dlfcn.h>
11 #include <unistd.h>
12 #include <signal.h>
13 #include <spawn.h>
14 #include <errno.h>
15 #include <sys/uio.h>
16 #include <sys/wait.h>
17 #include <sys/types.h>
18
19 #include "test_support.h"
20
21 extern char** environ;
22
23 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
24 _process process;
25 process.set_executable_path("/usr/bin/update_dyld_shared_cache");
26 const char* env[] = { "TEST_OUTPUT=None", NULL};
27 process.set_env(env);
28 const char* args[] = { "-cache_dir", "/tmp/", NULL };
29 process.set_args(args);
30 process.set_exit_handler(^(pid_t pid) {
31 int childStatus;
32 (void)wait4(pid, &childStatus, 0, NULL);
33 if (WIFEXITED(childStatus) == 0)
34 FAIL("update_dyld_shared_cache did not exit");
35 else if (WEXITSTATUS(childStatus) != 0)
36 FAIL("update_dyld_shared_cache failed");
37 else
38 PASS("Success");
39 });
40
41 process.launch();
42 }
43