public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 3/3] writev01: rewrite and drop partially valid iovec tests
Date: Tue, 11 Oct 2016 09:39:21 +0200	[thread overview]
Message-ID: <57FC9729.7000107@redhat.com> (raw)
In-Reply-To: <20161010160346.GG1684@rei>

On 10/10/2016 06:03 PM, Cyril Hrubis wrote:
>> +
>> +static void test_writev(unsigned int i)
>> +{
>> +	struct testcase_t *tcase = &testcases[i];
>> +	int ret;
>> +
>> +	TEST(writev(*(tcase->pfd), *(tcase->piovec), tcase->iovcnt));
>> +
>> +	ret = (TEST_RETURN == tcase->exp_ret);
>> +	if (TEST_RETURN < 0 || tcase->exp_ret < 0)
>> +		ret &= (TEST_ERRNO == tcase->exp_errno);
>> +
>> +	if (ret) {
>> +		tst_res(TPASS | TTERRNO, "%s, ret: %ld", tcase->desc,
>> +			TEST_RETURN);
>> +	} else {
>> +		tst_res(TPASS | TTERRNO, "%s, ret: %ld", tcase->desc,
>                          ^
> 			 TFAIL?
> 
>> +			TEST_RETURN);
>> +	}
> 
> Also I would have created separate functions for failure/success tests
> so that we can print more informative results, i.e. include the expected
> errno in the TFAIL result message.
> 
> Apart from that this is much better than the original.
> 

How about:

static void test_writev(unsigned int i)
{
        struct testcase_t *tcase = &testcases[i];
        int ret;

        TEST(writev(*(tcase->pfd), *(tcase->piovec), tcase->iovcnt));

        ret = (TEST_RETURN == tcase->exp_ret);
        if (TEST_RETURN < 0 || tcase->exp_ret < 0) {
                ret &= (TEST_ERRNO == tcase->exp_errno);
                tst_res((ret ? TPASS : TFAIL),
                        "%s, expected: %d (%s), got: %ld (%s)", tcase->desc,
                        tcase->exp_ret, tst_strerrno(tcase->exp_errno),
                        TEST_RETURN, tst_strerrno(TEST_ERRNO));
        } else {
                tst_res((ret ? TPASS : TFAIL),
                        "%s, expected: %d, got: %ld", tcase->desc,
                        tcase->exp_ret, TEST_RETURN);
        }
}

$ ./writev01
tst_test.c:756: INFO: Timeout per run is 0h 05m 00s
writev01.c:139: PASS: invalid iov_len, expected: -1 (EINVAL), got: -1 (EINVAL)
writev01.c:139: PASS: invalid fd, expected: -1 (EBADF), got: -1 (EBADF)
writev01.c:139: PASS: invalid iovcnt, expected: -1 (EINVAL), got: -1 (EINVAL)
writev01.c:143: PASS: zero iovcnt, expected: 0, got: 0
writev01.c:143: PASS: NULL and zero length iovec, expected: 64, got: 64
writev01.c:139: PASS: write to closed pipe, expected: -1 (EPIPE), got: -1 (EPIPE)

Regards,
Jan


  reply	other threads:[~2016-10-11  7:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-07  8:11 [LTP] [PATCH v2 1/3] syscalls: new test writev07 Jan Stancek
2016-10-07  8:11 ` [LTP] [PATCH v2 2/3] writev: remove writev03 and writev04 Jan Stancek
2016-10-07  8:11 ` [LTP] [PATCH v2 3/3] writev01: rewrite and drop partially valid iovec tests Jan Stancek
2016-10-10 16:03   ` Cyril Hrubis
2016-10-11  7:39     ` Jan Stancek [this message]
2016-10-11  8:41       ` Cyril Hrubis
2016-10-11 10:18         ` Jan Stancek
2016-10-10 15:54 ` [LTP] [PATCH v2 1/3] syscalls: new test writev07 Cyril Hrubis
2016-12-01  6:36 ` Cui Bixuan
2016-12-01  7:36   ` Jan Stancek

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=57FC9729.7000107@redhat.com \
    --to=jstancek@redhat.com \
    --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