[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/14] add mach_host tests
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 03/14] add mach_host tests |
Date: |
Fri, 29 Dec 2023 14:44:24 +0100 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Luca Dariz, le jeu. 28 déc. 2023 20:42:50 +0100, a ecrit:
> ---
> 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
Such files are also non-trivial, and thus deserve a copyright header too.
> @@ -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, "");
Perhaps also make some basic checks, such as binfo.avail_cpus <=
binfo.max_cpus.
> + 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, "");
Here you can probably check that the min_* values is smaller than e.g.
1000, to catch randomly-filled values.
Also, it would be useful to compile the tests with
-ftrivial-auto-var-init=pattern so as to fill the structures with random
values before making the gnumach calls.
Samuel
- Re: [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, 2023/12/28
- Re: [PATCH 03/14] add mach_host tests,
Samuel Thibault <=
[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