public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: chrubis@suse.cz
To: DAN LI <li.dan@cn.fujitsu.com>
Cc: LTP list <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH] mount/mount03.c: Test feature MS_NOATIME of mount(2)
Date: Mon, 1 Jul 2013 13:52:32 +0200	[thread overview]
Message-ID: <20130701115232.GA15035@rei.suse.cz> (raw)
In-Reply-To: <51D160D2.4070806@cn.fujitsu.com>

Hi!
> +	case 6:
> +		/* Validate MS_NOATIME flag of mount call */
> +
> +		snprintf(file, PATH_MAX, "%satime", path_name);
> +		fd = open(file, O_CREAT | O_RDWR, S_IRWXU);
> +		if (fd == -1) {
> +			tst_resm(TWARN | TERRNO, "opening %s failed", file);
> +			return 1;
> +		}
> +
> +		if (write(fd, "TEST_MS_NOATIME", 15) != 15) {
> +			tst_resm(TWARN | TERRNO, "write %s failed", file);
> +			return 1;
> +		}
> +
> +		if (fstat(fd, &file_stat) == -1) {
> +			tst_resm(TWARN | TERRNO, "stat %s failed #1", file);
> +			return 1;
> +		}
> +
> +		atime = file_stat.st_atime;
> +

The time_t, if I'm not mistaken, has resolution in seconds, so you need
to sleep a second here before you call the read() bellow to be sure
timestamp is different at the time you try to read.


Moreover the whole testcase should better be cleaned up (it doesn't use
the tst_require_root() and does some strange/unnecessary things in the
temp dir).


-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

      reply	other threads:[~2013-07-01 11:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01 10:58 [LTP] [PATCH] mount/mount03.c: Test feature MS_NOATIME of mount(2) DAN LI
2013-07-01 11:52 ` chrubis [this message]

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=20130701115232.GA15035@rei.suse.cz \
    --to=chrubis@suse.cz \
    --cc=li.dan@cn.fujitsu.com \
    --cc=ltp-list@lists.sourceforge.net \
    /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