[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/14] add mach_host tests
From: |
Luca Dariz |
Subject: |
[PATCH 03/14] add mach_host tests |
Date: |
Thu, 28 Dec 2023 20:42:50 +0100 |
---
tests/test-mach_host.c | 54 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
create mode 100644 tests/test-mach_host.c
diff --git a/tests/test-mach_host.c b/tests/test-mach_host.c
new file mode 100644
index 00000000..99fc4aca
--- /dev/null
+++ b/tests/test-mach_host.c
@@ -0,0 +1,54 @@
+
+#include <testlib.h>
+
+#include <mach_host.user.h>
+
+void test_kernel_version()
+{
+ int err;
+ kernel_version_t kver;
+ err = host_get_kernel_version(mach_host_self(), kver);
+ ASSERT_RET(err, "host_kernel_info");
+ printf("kernel version: %s\n", kver);
+}
+
+void test_host_info()
+{
+ int err;
+ mach_msg_type_number_t count;
+ mach_port_t thishost = mach_host_self();
+
+ host_basic_info_data_t binfo;
+ count = HOST_BASIC_INFO_COUNT;
+ err = host_info(thishost, HOST_BASIC_INFO, (host_info_t)&binfo, &count);
+ ASSERT_RET(err, "host_basic_info");
+ ASSERT(count == HOST_BASIC_INFO_COUNT, "");
+
+ const int maxcpus = 255;
+ int proc_slots[maxcpus];
+ count = maxcpus;
+ err = host_info(thishost, HOST_PROCESSOR_SLOTS, (host_info_t)&proc_slots,
&count);
+ ASSERT_RET(err, "host_processor_slots");
+ ASSERT((1 <= count) && (count <= maxcpus), "");
+
+ host_sched_info_data_t sinfo;
+ count = HOST_SCHED_INFO_COUNT;
+ err = host_info(thishost, HOST_SCHED_INFO, (host_info_t)&sinfo, &count);
+ ASSERT_RET(err, "host_sched_info");
+ ASSERT(count == HOST_SCHED_INFO_COUNT, "");
+
+ host_load_info_data_t linfo;
+ count = HOST_LOAD_INFO_COUNT;
+ err = host_info(thishost, HOST_LOAD_INFO, (host_info_t)&linfo, &count);
+ ASSERT_RET(err, "host_load_info");
+ ASSERT(count == HOST_LOAD_INFO_COUNT, "");
+}
+
+// TODO processor sets
+
+int main(int argc, char *argv[], int envc, char *envp[])
+{
+ test_kernel_version();
+ test_host_info();
+ return 0;
+}
--
2.39.2
- [PATCH 05/14] add mach_port tests, (continued)
[PATCH 08/14] add thread creation helper to tests, Luca Dariz, 2023/12/28
[PATCH 03/14] add mach_host tests,
Luca Dariz <=
[PATCH 13/14] add basic thread tests, Luca Dariz, 2023/12/28
[PATCH 01/14] USER32: change default to disabled and make it a general option, Luca Dariz, 2023/12/28
[PATCH 06/14] adjust range when changing memory pageability, Luca Dariz, 2023/12/28
[PATCH 04/14] add gsync tests, Luca Dariz, 2023/12/28