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 3/3] diotest5.c: replaced iovec
Date: Fri, 30 Oct 2015 04:53:13 -0400 (EDT)	[thread overview]
Message-ID: <1912499711.38973678.1446195193937.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1446137758-27267-3-git-send-email-chnyda@suse.com>





----- Original Message -----
> From: "Cedric Hnyda" <chnyda@suse.com>
> To: ltp@lists.linux.it
> Sent: Thursday, 29 October, 2015 5:55:58 PM
> Subject: [LTP]  [PATCH 3/3] diotest5.c: replaced iovec
> 
> Replaced iovec pointers by normal buffers.
> iovec were passed instead of expected buffers.

What is the problem with iovecs here?
Isn't readv/writev meant to be used in this test?

 * DESCRIPTION
 *      The programs test buffered and direct IO with vector arrays using
 *      readv() and writev() calls.

Regards,
Jan

> 
> Signed-off-by: Cedric Hnyda <chnyda@suse.com>
> ---
>  testcases/kernel/io/direct_io/diotest5.c | 54
>  +++++++++-----------------------
>  1 file changed, 14 insertions(+), 40 deletions(-)
> 
> diff --git a/testcases/kernel/io/direct_io/diotest5.c
> b/testcases/kernel/io/direct_io/diotest5.c
> index 0c10742..e5946bd 100644
> --- a/testcases/kernel/io/direct_io/diotest5.c
> +++ b/testcases/kernel/io/direct_io/diotest5.c
> @@ -84,49 +84,30 @@ static void prg_usage(void);
>  static int runtest(int fd_r, int fd_w, int iter, off64_t offset)
>  {
>  	int i, bufsize = BUFSIZE;
> -	struct iovec *iov1, *iov2, *iovp;
>  
>  	/* Allocate for buffers and data pointers */
> -	iov1 = (struct iovec *) valloc(sizeof(struct iovec) * nvector);
> -	if (iov1 == NULL) {
> -		tst_resm(TFAIL, "valloc() buf1 failed: %s", strerror(errno));
> -		return (-1);
> -	}
> +	char *buf1, *buf2;
>  
> -	iov2 = (struct iovec *) valloc(sizeof(struct iovec) * nvector);
> -	if (iov2 == NULL) {
> -		tst_resm(TFAIL, "valloc buf2 failed: %s", strerror(errno));
> -		return (-1);
> -	}
> -	for (i = 0, iovp = iov1; i < nvector; iovp++, i++) {
> -		iovp->iov_base = valloc(bufsize);
> -		if (iovp->iov_base == NULL) {
> -			tst_resm(TFAIL, "valloc for iovp->iov_base: %s",
> -				 strerror(errno));
> -			return (-1);
> -		}
> -		iovp->iov_len = bufsize;
> -	}
> -	for (i = 0, iovp = iov2; i < nvector; iovp++, i++) {
> -		iovp->iov_base = valloc(bufsize);
> -		if (iovp->iov_base == NULL) {
> -			tst_resm(TFAIL, "valloc, iov2 for iovp->iov_base: %s",
> -				 strerror(errno));
> -			return (-1);
> -		}
> -		iovp->iov_len = bufsize;
> +	buf1 = valloc(bufsize);
> +	buf2 = valloc(bufsize);
> +
> +	if (!buf1 || !buf2) {
> +		tst_resm(TBROK | TERRNO, "valloc() failed");
> +		free(buf1);
> +		free(buf2);
> +		return -1;
>  	}
>  
>  	/* Test */
>  	for (i = 0; i < iter; i++) {
> -		vfillbuf(iov1, nvector, i);
> -		vfillbuf(iov2, nvector, i + 1);
> +		fillbuf(buf1, bufsize, i);
> +		fillbuf(buf2, bufsize, i + 1);
>  		if (lseek(fd_w, offset, SEEK_SET) < 0) {
>  			tst_resm(TFAIL, "lseek before writev failed: %s",
>  				 strerror(errno));
>  			return (-1);
>  		}
> -		if (writev(fd_w, iov1, nvector) < 0) {
> +		if (write(fd_w, buf1, bufsize) < 0) {
>  			tst_resm(TFAIL, "writev failed: %s", strerror(errno));
>  			return (-1);
>  		}
> @@ -135,23 +116,16 @@ static int runtest(int fd_r, int fd_w, int iter,
> off64_t offset)
>  				 strerror(errno));
>  			return (-1);
>  		}
> -		if (readv(fd_r, iov2, nvector) < 0) {
> +		if (read(fd_r, buf2, bufsize) < 0) {
>  			tst_resm(TFAIL, "readv failed: %s", strerror(errno));
>  			return (-1);
>  		}
> -		if (vbufcmp(iov1, iov2, nvector) != 0) {
> +		if (bufcmp(buf1, buf2, bufsize) != 0) {
>  			tst_resm(TFAIL, "readv/writev comparision failed");
>  			return (-1);
>  		}
>  	}
>  
> -	/* Cleanup */
> -	for (i = 0, iovp = iov1; i < nvector; iovp++, i++)
> -		free(iovp->iov_base);
> -	for (i = 0, iovp = iov2; i < nvector; iovp++, i++)
> -		free(iovp->iov_base);
> -	free(iov1);
> -	free(iov2);
>  	return 0;
>  }
>  
> --
> 2.1.4
> 
> 
> --
> Mailing list info: http://lists.linux.it/listinfo/ltp
> 

  reply	other threads:[~2015-10-30  8:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-29 16:55 [LTP] [PATCH 1/3] diotest: cleanup & fix Cedric Hnyda
2015-10-29 16:55 ` [LTP] [PATCH 2/3] diotest4.c: Fixed filesystem Cedric Hnyda
2015-10-29 16:55 ` [LTP] [PATCH 3/3] diotest5.c: replaced iovec Cedric Hnyda
2015-10-30  8:53   ` Jan Stancek [this message]
2015-10-30  9:17     ` Cedric Hnyda
2015-11-04 12:41 ` [LTP] [PATCH 1/3] diotest: cleanup & fix 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=1912499711.38973678.1446195193937.JavaMail.zimbra@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