From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 1/1] syscalls/mq_timedreceive: convert to new API
Date: Fri, 3 Mar 2017 14:03:42 +0100 [thread overview]
Message-ID: <20170303130342.GA16323@rei.lan> (raw)
In-Reply-To: <20170301201331.22402-1-pvorel@suse.cz>
Hi!
> - /*
> - * Prepare send message
> - */
> - for (i = 0; i < tc->len; i++)
> - smsg[i] = i;
> + if (tc->ttype == SEND_SIGINT)
> + pid = create_sig_proc(SIGINT, 40, 200000);
>
> - /*
> - * Send message
> - */
> - switch (tc->ttype) {
> - case EMPTY_QUEUE:
> - case SEND_SIGINT:
> - case FD_NONE:
> - case FD_NOT_EXIST:
> - case FD_FILE:
> - break;
> - default:
> - TEST(rc = mq_timedsend(fd, smsg, tc->len, tc->prio, &ts));
> - if (TEST_RETURN < 0) {
> - tst_resm(TFAIL | TTERRNO, "mq_timedsend failed");
> - result = 1;
> - goto EXIT;
> - }
> - break;
> - }
> + for (j = 0; j < tc->len; j++)
> + smsg[j] = j;
> +
> + /* send */
> + if ((tc->ttype == NORMAL || tc->ttype == INVALID_MSG_LEN)
> + && mq_timedsend(fd, smsg, tc->len, tc->prio,
> + &((struct timespec){0})) < 0)
> + tst_brk(TBROK | TERRNO, "mq_timedsend failed");
This is still too ugly. Why can't we get rid of all of these special
cases here and move the code that is specific for a given test to the
test setup and cleanup functions?
Apart from that we may as well open the fd pointing to file once in the
test setup and close it once in the test cleanup.
Also we should use SAFE_OPEN() for opening the file. And we may as well
add safe_posix_ipc.h with SAFE_MQ_OPEN().
Oh, and we are adding signal handler twice in the test setup(), once via
signal() and second time via sigaction().
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2017-03-03 13:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-01 20:13 [LTP] [PATCH v2 1/1] syscalls/mq_timedreceive: convert to new API Petr Vorel
2017-03-03 13:03 ` Cyril Hrubis [this message]
2017-03-03 13:43 ` Petr Vorel
2017-03-03 14:05 ` 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=20170303130342.GA16323@rei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox