1 #include <spawn.h> 2 #include <sys/wait.h> 3 #include <darwintest.h> 4 #include <mach-o/dyld.h> 5 #include <errno.h> 6 7 T_DECL(nox86exec, "make sure the nox86exec boot-arg is honored", T_META_ALL_VALID_ARCHS(false), T_META_BOOTARGS_SET("nox86exec=1")) 8 { 9 #if TARGET_OS_OSX && defined(__arm64__) 10 int spawn_ret, pid; 11 char path[1024]; 12 uint32_t size = sizeof(path); 13 14 T_ASSERT_EQ(_NSGetExecutablePath(path, &size), 0, NULL); 15 T_ASSERT_LT(strlcat(path, "_helper", size), (unsigned long)size, NULL); 16 17 spawn_ret = posix_spawn(&pid, path, NULL, NULL, NULL, NULL); 18 if (spawn_ret == 0) { 19 int wait_ret = 0; 20 waitpid(pid, &wait_ret, 0); 21 T_ASSERT_FALSE(WIFEXITED(wait_ret), "x86_64 helper should not run"); 22 } 23 #else 24 T_SKIP("Skipping. Test only runs on arm64 macOS."); 25 #endif 26 } 27