public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: "daisl.fnst@fujitsu.com" <daisl.fnst@fujitsu.com>
Cc: "ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH] syscalls/write06: Add new test
Date: Fri, 10 Dec 2021 11:57:08 +0100	[thread overview]
Message-ID: <YbMyhM7/wqbGCdgk@yuki> (raw)
In-Reply-To: <338aba97-dd1d-9a9e-e6a0-dcd60cf8ebc9@fujitsu.com>

Hi!
> What I want to test is the following description of open(2) man-pages:
> 
> O_APPEND
>  ?????? ?? The file is opened in append mode.?? Before each write(2), the 
> file offset is positioned at the end of the file, as if with lseek(2).?? 
> The modification of the file offset and the write operation are 
> performed as a single atomic step.

Ah, now it makes much more sense.

I think part of the problem is that the code is actually confusing. I do
not like the l_seek() function at all, it's confusing at best because it
does several different things at the same time. So it would be much
better to write the offset check as:

	off = SAFE_LSEEK(fd, 1K, SEEK_SET)
	if (off != 1K)
		tst_brk(TBROK, "Failed to seek to 1K");

	SAFE_WRITE(1, fd, write_buf[1], K1);

	off = SAFE_LSEEK(fd, 0, SEEK_CUR);
	if (off != K3)
		tst_res(TFAIL, "Wrong offset after write %zu expected %u", off, K3)
	else
		tst_res(TPASS, "Offset is correct after write %zu", off);

	SAFE_FSTAT(fd, &statbuf);
	if (statbuf.st_size != K3) {
		tst_res(TFAIL, "Wrong file size after append %zu expected %u",
			statubuf.st_size, K3);
	} else {
		tst_res(TPASS, "Correct file size after append %u", K3);
	}


This makes it much clearer what happens here and the TPASS message
actually says what has passed...

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2021-12-10 10:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06 21:17 [LTP] [PATCH] syscalls/write06: Add new test Dai Shili
2021-12-07 13:51 ` Cyril Hrubis
2021-12-08  8:38   ` daisl.fnst
2021-12-10 10:57     ` Cyril Hrubis [this message]
2021-12-20 19:23       ` [LTP] [PATCH v2] " Dai Shili
2021-12-20  9:53         ` Petr Vorel
2021-12-21 20:03           ` [LTP] [PATCH v3] " Dai Shili
2021-12-21 19:44             ` Petr Vorel
2021-12-23  1:42             ` xuyang2018.jy

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=YbMyhM7/wqbGCdgk@yuki \
    --to=chrubis@suse.cz \
    --cc=daisl.fnst@fujitsu.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