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