X-Git-Url: https://git.saurik.com/apple/dyld.git/blobdiff_plain/dd1e3476105179eb3efd5ebd2af97f6de91170b3..16b475fcb248267b8b51f759bc62a49ec2afa88d:/testing/test-cases/macOS-cache-rebuild.dtest/main.cpp?ds=sidebyside diff --git a/testing/test-cases/macOS-cache-rebuild.dtest/main.cpp b/testing/test-cases/macOS-cache-rebuild.dtest/main.cpp new file mode 100644 index 0000000..9d3ea90 --- /dev/null +++ b/testing/test-cases/macOS-cache-rebuild.dtest/main.cpp @@ -0,0 +1,43 @@ +// BUILD_ONLY: MacOSX + +// BUILD: $CXX main.cpp -o $BUILD_DIR/rebuild-dyld-cache.exe + +// FIXME: This test will not make sense when remove update_dyld_shared_cache, and the functionality will be subsummed by root testing +// ./rebuild-dyld-cache.exe + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "test_support.h" + +extern char** environ; + +int main(int argc, const char* argv[], const char* envp[], const char* apple[]) { + _process process; + process.set_executable_path("/usr/bin/update_dyld_shared_cache"); + const char* env[] = { "TEST_OUTPUT=None", NULL}; + process.set_env(env); + const char* args[] = { "-cache_dir", "/tmp/", NULL }; + process.set_args(args); + process.set_exit_handler(^(pid_t pid) { + int childStatus; + (void)wait4(pid, &childStatus, 0, NULL); + if (WIFEXITED(childStatus) == 0) + FAIL("update_dyld_shared_cache did not exit"); + else if (WEXITSTATUS(childStatus) != 0) + FAIL("update_dyld_shared_cache failed"); + else + PASS("Success"); + }); + + process.launch(); +} +