[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 11/14] add raw mach_msg tests
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 11/14] add raw mach_msg tests |
Date: |
Fri, 29 Dec 2023 15:20:25 +0100 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Luca Dariz, le jeu. 28 déc. 2023 20:42:58 +0100, a ecrit:
> ---
> tests/test-machmsg.c | 390 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 390 insertions(+)
> create mode 100644 tests/test-machmsg.c
>
> diff --git a/tests/test-machmsg.c b/tests/test-machmsg.c
> new file mode 100644
> index 00000000..c262f5f4
> --- /dev/null
> +++ b/tests/test-machmsg.c
> @@ -0,0 +1,390 @@
> +
> +#include <mach/message.h>
> +#include <mach/mach_types.h>
> +#include <mach/vm_param.h>
> +
> +#include <syscalls.h>
> +#include <testlib.h>
> +
> +#include <mach.user.h>
> +#include <mach_port.user.h>
> +#include <mach_host.user.h>
> +
> +#define ECHO_MAX_BODY_LEN 256
> +
> +static uint32_t align(uint32_t val, size_t aln)
> +{
> + // we should check aln is a power of 2
> + aln--;
> + return (val + aln) & (~aln);
> +}
> +
> +#define align_inline(val, n) { val = align(val, n); }
Rather name it ALIGN_INLINE, so people don't mistake this for a
function (that doesn't have side-effects on its parameters).
> +void
> +run_test_simple(void *msg, mach_msg_size_t msglen, mach_msg_id_t msgid)
> +{
> + mach_msg_header_t *head = msg;
> + mach_port_t port, receive;
> + int err;
> +
> + err = syscall_mach_port_allocate (mach_task_self (),
> + MACH_PORT_RIGHT_RECEIVE, &port);
> + ASSERT_RET(err, "syscall_mach_port_allocate");
> +
> + err = syscall_mach_port_allocate (mach_task_self (),
> + MACH_PORT_RIGHT_RECEIVE, &receive);
> + ASSERT_RET(err, "syscall_mach_port_allocate 2");
> +
> + struct echo_params params;
> + params.rx_port = port;
> + params.rx_size = msglen;
> + params.rx_number = 1;
> + test_thread_start (mach_task_self (), echo_thread, ¶ms);
> + msleep(100);
Is this msleep really needed? If yes, this is racy. If it's just to make
the test a bit more stressful, then ok.
Samuel
- Re: [PATCH 04/14] add gsync tests, (continued)
[PATCH 07/14] add basic vm tests, Luca Dariz, 2023/12/28
[PATCH 09/14] add syscall tests, Luca Dariz, 2023/12/28
[PATCH 10/14] expose MACH_MSG_USER_ALIGNMENT for manually-built messages, Luca Dariz, 2023/12/28
[PATCH 11/14] add raw mach_msg tests, Luca Dariz, 2023/12/28
- Re: [PATCH 11/14] add raw mach_msg tests,
Samuel Thibault <=
[PATCH 14/14] add tests to make check, Luca Dariz, 2023/12/28
[PATCH 12/14] add basic task tests, Luca Dariz, 2023/12/28