public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2] syscalls/write01.c: Add test with different buffer sizes && Remove write02
Date: Tue, 13 Jun 2017 12:59:54 +0200	[thread overview]
Message-ID: <20170613105953.GA29757@rei.lan> (raw)
In-Reply-To: <1497252431-8344-1-git-send-email-huangjh.jy@cn.fujitsu.com>

Hi!
>  testcases/kernel/syscalls/write/write01.c |  40 +++++---
>  testcases/kernel/syscalls/write/write02.c | 146 ------------------------------

If you are removing a test you have to update runtest/* files as well as
syscalls/.gitignore.

> diff --git a/testcases/kernel/syscalls/write/write01.c b/testcases/kernel/syscalls/write/write01.c
> index 1a60052..14fa7c9 100644
> --- a/testcases/kernel/syscalls/write/write01.c
> +++ b/testcases/kernel/syscalls/write/write01.c
> @@ -20,17 +20,9 @@
>   * You should have received a copy of the GNU General Public License along
>   * with this program; if not, write the Free Software Foundation, Inc.,
>   * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> - *
> - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
> - * Mountain View, CA  94043, or:
> - *
> - * http://www.sgi.com
> - *
> - * For further information regarding this notice, see:
> - *
> - * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
>   */
>  
> +#include <stdio.h>

Isn't memset() defined in string.h? Or for which definition do we need
stdio.h here?

>  #include <errno.h>
>  #include "tst_test.h"
>  
> @@ -38,17 +30,35 @@ static int fd;
>  
>  static void verify_write(void)
>  {
> -	TEST(write(fd, "w", 1));
> +	int i, badcount = 0;
> +	char buf[BUFSIZ];
> +
> +	memset(buf, 'w', BUFSIZ);
>  
> -	if (TEST_RETURN == -1)
> -		tst_res(TFAIL | TTERRNO, "write(2) failed");
> +	SAFE_LSEEK(fd, 0, SEEK_SET);
> +
> +	for (i = BUFSIZ; i > 0; i--) {
> +		TEST(write(fd, &buf, i));

The &buf == buf for arrays, but I find simply passing buf a bit less
confusing.

> +		if (TEST_RETURN == -1) {
> +			tst_res(TFAIL | TTERRNO, "write failed");
> +			return;
> +		}
> +
> +		if (TEST_RETURN != i) {
> +			badcount++;
> +			tst_res(TINFO, "bad write count");

Maybe we should write something as:

"write() returned %ld, expected %d", TEST_RETURN, i

> +		}
> +	}
> +
> +	if (badcount != 0)
> +		tst_res(TFAIL, "write() failed to return proper count");
>  	else
> -		tst_res(TPASS, "write(2) returned %ld", TEST_RETURN);
> +		tst_res(TPASS, "write() passed");
>  }

Otherwise it looks OK.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2017-06-13 10:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-21 10:48 [LTP] [PATCH 1/2] syscall/write02.c: Cleanup && convert to new API Jinhui Huang
2017-04-21 10:48 ` [LTP] [PATCH 2/2] syscall/write03.c: " Jinhui Huang
2017-05-26 14:14   ` Cyril Hrubis
2017-05-26 14:16 ` [LTP] [PATCH 1/2] syscall/write02.c: " Cyril Hrubis
2017-06-12  7:27   ` [LTP] [PATCH v2] syscalls/write01.c: Add test with different buffer sizes && Remove write02 Jinhui Huang
2017-06-13 10:59     ` Cyril Hrubis [this message]
2017-06-15  9:26       ` [LTP] [PATCH v3] " Jinhui Huang
2017-06-15 14:56         ` 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=20170613105953.GA29757@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