]> git.saurik.com Git - apple/xnu.git/blobdiff - tests/test_utils.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tests / test_utils.c
diff --git a/tests/test_utils.c b/tests/test_utils.c
new file mode 100644 (file)
index 0000000..e5197d4
--- /dev/null
@@ -0,0 +1,25 @@
+#include <sys/kern_sysctl.h>
+#include <sys/sysctl.h>
+#include <dispatch/dispatch.h>
+#include <darwintest.h>
+
+#include "test_utils.h"
+
+bool
+is_development_kernel()
+{
+       static dispatch_once_t is_development_once;
+       static bool is_development;
+
+       dispatch_once(&is_development_once, ^{
+               int dev;
+               size_t dev_size = sizeof(dev);
+
+               T_QUIET;
+               T_ASSERT_POSIX_SUCCESS(sysctlbyname("kern.development", &dev,
+               &dev_size, NULL, 0), NULL);
+               is_development = (dev != 0);
+       });
+
+       return is_development;
+}