aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2024-03-27 19:18:37 +0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2024-03-27 19:57:12 +0100
commit22c282a30ba836c8ef165dfa17e2dd354f1ba3e3 (patch)
tree6f3cb43e91e80c752acca619ab4fcf3f0b76ce28
parent2fb1f4ccbb369c06ef80dc0fe5798b239383fa4c (diff)
downloadgnumach-22c282a30ba836c8ef165dfa17e2dd354f1ba3e3.tar.gz
gnumach-22c282a30ba836c8ef165dfa17e2dd354f1ba3e3.tar.bz2
gnumach-22c282a30ba836c8ef165dfa17e2dd354f1ba3e3.zip
tests: Add vm_page_size
Message-ID: <20240327161841.95685-14-bugaevc@gmail.com>
-rw-r--r--tests/include/testlib.h2
-rw-r--r--tests/testlib.c13
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/include/testlib.h b/tests/include/testlib.h
index d2367124..035fdc28 100644
--- a/tests/include/testlib.h
+++ b/tests/include/testlib.h
@@ -70,6 +70,8 @@ thread_t test_thread_start(task_t task, void(*routine)(void*), void* arg);
mach_port_t host_priv(void);
mach_port_t device_priv(void);
+extern vm_size_t vm_page_size;
+
extern void mach_msg_destroy(mach_msg_header_t *msg);
extern mach_msg_return_t mach_msg_server(
diff --git a/tests/testlib.c b/tests/testlib.c
index baf1ce5c..12c5e771 100644
--- a/tests/testlib.c
+++ b/tests/testlib.c
@@ -29,6 +29,11 @@
#include <mach_port.user.h>
#include <mach_host.user.h>
+#ifdef PAGE_SIZE
+vm_size_t vm_page_size = PAGE_SIZE;
+#else
+vm_size_t vm_page_size;
+#endif
static int argc = 0;
static char *argv_unknown[] = {"unknown", "m1", "123", "456"};
@@ -212,6 +217,7 @@ mach_msg_return_t mach_msg_server_once(
void __attribute__((used, retain))
c_start(void **argptr)
{
+ kern_return_t kr;
intptr_t* argcptr = (intptr_t*)argptr;
argc = argcptr[0];
argv = (char **) &argcptr[1];
@@ -224,6 +230,13 @@ c_start(void **argptr)
mach_atoi(argv[1], &host_priv_port);
mach_atoi(argv[2], &device_master_port);
+#ifndef PAGE_SIZE
+ vm_statistics_data_t stats;
+ kr = vm_statistics (mach_task_self(), &stats);
+ ASSERT_RET(kr, "can't get page size");
+ vm_page_size = stats.pagesize;
+#endif
+
printf("started %s", argv[0]);
for (int i=1; i<argc; i++)
{