From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/msgrcv07: Add functional test for MSG_COPY flag
Date: Fri, 14 Aug 2020 15:28:55 +0200 [thread overview]
Message-ID: <20200814132855.GC5559@yuki.lan> (raw)
In-Reply-To: <1597392640-26678-1-git-send-email-xuyang2018.jy@cn.fujitsu.com>
Hi!
> +static void test_msg_copy(void)
> +{
> + struct msqid_ds buf = {0};
> +
> + if (!msg_copy_sup)
> + tst_res(TCONF, "kernel doesn't support MSG_COPY flag, skip it");
> + prepare_queue();
> +
> + /*
> + * If MSG_COPY flag was specified, then mtype is interpreted as number
> + * of the message to copy.
> + */
> + SAFE_MSGRCV(queue_id, &rcv_buf, MSGSIZE, 0, MSG_COPY | IPC_NOWAIT);
> + if (strcmp(rcv_buf.mtext, MSG1) == 0 && rcv_buf.type == MSGTYPE1)
> + tst_res(TPASS, "msgrcv(MSG_COPY) got MSGTYPE1 msg data"
> + " correctly");
> + else
> + tst_res(TFAIL, "msgrcv(MSG_COPY) got MSGTYPE1 msg data"
> + " incorrectly");
> +
> + SAFE_MSGRCV(queue_id, &rcv_buf, MSGSIZE, 1, MSG_COPY | IPC_NOWAIT);
> + if (strcmp(rcv_buf.mtext, MSG2) == 0 && rcv_buf.type == MSGTYPE2)
> + tst_res(TPASS, "msgrcv(MSG_COPY) got MSGTYPE2 msg data"
> + " correctly");
> + else
> + tst_res(TFAIL, "msgrcv(MSG_COPY) got MSGTYPE2 msg data"
> + " incorrectly");
> +
> + SAFE_MSGCTL(queue_id, IPC_STAT, &buf);
> + if (buf.msg_qnum == 2)
> + tst_res(TPASS, "msgrcv(MSG_COPY) succeeded, msg queue "
> + "still has 2 msg");
> + else
> + tst_res(TFAIL, "msgrcv(MSG_COPY) msg queue expected 2 msg num,"
> + " but only got %d", (int)buf.msg_qnum);
> + SAFE_MSGCTL(queue_id, IPC_RMID, NULL);
> +}
>
> static void setup(void)
> {
> msgkey = GETIPCKEY();
> + prepare_queue();
> + TEST(msgrcv(queue_id, &rcv_buf, MSGSIZE, MSGTYPE1, MSG_COPY));
> + if (TST_RET != -1)
> + tst_res(TINFO, "msgrcv succeeded unexpectedly, kernel doesn't"
> + " support MSG_COPY flag");
> +
> + if (TST_ERR == EINVAL) {
> + tst_res(TINFO, "msgrcv failed as expected when not using"
> + " MSG_COPY and IPC_NOWAIT concurrently");
> + msg_copy_sup = 1;
> + } else if (TST_ERR == ENOSYS) {
> + tst_res(TINFO, "kernel doesn't enable CONFIG_CHECKPOINT_RESTORE");
> + } else {
> + tst_res(TINFO | TTERRNO, "msgrcv failed when not using MSG_COPY"
> + "and IPC_NOWAIT concurrently, expected EINVAL but got");
> + }
Why can't we just check for ENOSYS in the test_msg_copy() instead?
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2020-08-14 13:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-14 8:10 [LTP] [PATCH] syscalls/msgrcv07: Add functional test for MSG_COPY flag Yang Xu
2020-08-14 8:15 ` Yang Xu
2020-08-14 13:28 ` Cyril Hrubis [this message]
2020-08-14 14:17 ` Yang Xu
2020-08-18 5:18 ` [LTP] [PATCH v2] " Yang Xu
2020-09-08 14:08 ` Cyril Hrubis
2020-09-09 2:23 ` Yang Xu
2020-09-09 8:27 ` [LTP] [PATCH v3 1/2] " Yang Xu
2020-09-09 8:27 ` [LTP] [PATCH v3 2/2] syscalls/msgrcv07: improve and short message Yang Xu
2020-09-09 15:16 ` Cyril Hrubis
2020-09-09 15:15 ` [LTP] [PATCH v3 1/2] syscalls/msgrcv07: Add functional test for MSG_COPY flag Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200814132855.GC5559@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.