Skip Menu |

This queue is for tickets about the Time-HiRes CPAN distribution.

Report information
The Basics
Id: 116127
Status: open
Priority: 0/
Queue: Time-HiRes

People
Owner: Nobody in particular
Requestors: simcop2387 [...] simcop2387.info
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: t/utime.t fails on ext3
Date: Wed, 13 Jul 2016 16:42:15 -0700
To: bug-Time-HiRes [...] rt.cpan.org, jhi [...] iki.fi
From: Ryan Voots <simcop2387 [...] simcop2387.info>
The tests for t/utime.t fail when using an older filesystem on linux. I'm using ext3 on this system and it fails to record the fractional seconds. dist/Time-HiRes/t/utime ........................................ # Failed test 'atime set correctly' # at t/utime.t line 35. # got: '1' # expected: '1.111111111' # Failed test 'mtime set correctly' # at t/utime.t line 36. # got: '2' # expected: '2.222222222' # Failed test 'atime set correctly' # at t/utime.t line 44. # got: '1' # expected: '1.111111111' # Failed test 'mtime set correctly' # at t/utime.t line 45. # got: '2' # expected: '2.222222222' # Failed test 'File 1 atime set correctly' # at t/utime.t line 55. # got: '1' # expected: '1.111111111' # Failed test 'File 1 mtime set correctly' # at t/utime.t line 56. # got: '2' # expected: '2.222222222' # Failed test 'File 2 atime set correctly' # at t/utime.t line 60. # got: '1' # expected: '1.111111111' # Failed test 'File 2 mtime set correctly' # at t/utime.t line 61. # got: '2' # expected: '2.222222222' # Failed test 'File 1 atime set correctly' # at t/utime.t line 75. # '0.328052043914795' # < # '0.1' # Failed test 'File 1 mtime set correctly' # at t/utime.t line 76. # '0.328052043914795' # < # '0.1' # Failed test 'File 2 atime set correctly' # at t/utime.t line 80. # '0.328052043914795' # < # '0.1' # Failed test 'File 2 mtime set correctly' # at t/utime.t line 81. # '0.328052043914795' # < # '0.1' # Looks like you failed 12 tests of 18. FAILED at test 2 dist/XSLoader/t/XSLoader ....................................... ok
How does one detect that the filesystem is ext3?
Subject: Re: [rt.cpan.org #116127] t/utime.t fails on ext3
Date: Thu, 14 Jul 2016 08:03:06 +0000
To: bug-Time-HiRes [...] rt.cpan.org
From: Ryan Voots <simcop2387 [...] simcop2387.info>
I've been looking for a good way to do it, best way I've found so far is reading /proc/mounts and finding the mount point for where the test is being run and checking it's type. I also suspect (but haven't tested yet) that a bunch of other filesystems are going to have similar problems. On Thu, Jul 14, 2016, 12:28 AM Jarkko_Hietaniemi via RT < bug-Time-HiRes@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=116127 > > > How does one detect that the filesystem is ext3? >
Yeah, for the general case some guesswork for the filesystem timestamp resolution might be useful. But if there is some more definite way of detecting particular filesystems, it would not hurt. Can you do "df $filename" and get at the relevant more directly?
Subject: Re: [rt.cpan.org #116127] t/utime.t fails on ext3
Date: Thu, 14 Jul 2016 21:08:16 -0700
To: bug-Time-HiRes [...] rt.cpan.org
From: Ryan Voots <simcop2387 [...] simcop2387.info>
Looks like it'll give you the mount point to check, that combined with /proc/mounts should let you detect the file system and only enable the test on ones that support sub second times root@simcop2387:~/letsencrypt-lighttpd# df /tmp/tmp.Ki6yC1AIFr Filesystem 1K-blocks Used Available Use% Mounted on /dev/root 44990064 34542948 9984028 78% / root@simcop2387:~/letsencrypt-lighttpd# cat /proc/mounts /dev/root / ext3 rw,noatime,errors=remount-ro,barrier=0,data=writeback 0 0 devtmpfs /dev devtmpfs rw,relatime,size=1021656k,nr_inodes=255414,mode=755 0 0 ... On Thu, Jul 14, 2016 at 5:09 AM, Jarkko_Hietaniemi via RT < bug-Time-HiRes@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=116127 > > > Yeah, for the general case some guesswork for the filesystem timestamp > resolution might be useful. But if there is some more definite way of > detecting particular filesystems, it would not hurt. > > Can you do "df $filename" and get at the relevant more directly? >
Subject: Re: [rt.cpan.org #116127] t/utime.t fails on ext3
Date: Fri, 15 Jul 2016 10:21:28 +0300
To: bug-Time-HiRes [...] rt.cpan.org
From: Jarkko Hietaniemi <jhi [...] iki.fi>
On Friday-201607-15 7:08, simcop2387@simcop2387.info via RT wrote: Show quoted text
> Queue: Time-HiRes > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=116127 > > > Looks like it'll give you the mount point to check, that combined with > /proc/mounts should let you detect the file system and only enable the test > on ones that support sub second times > > root@simcop2387:~/letsencrypt-lighttpd# df /tmp/tmp.Ki6yC1AIFr > Filesystem 1K-blocks Used Available Use% Mounted on > /dev/root 44990064 34542948 9984028 78% / > > root@simcop2387:~/letsencrypt-lighttpd# cat /proc/mounts > /dev/root / ext3 rw,noatime,errors=remount-ro,barrier=0,data=writeback 0 0 > devtmpfs /dev devtmpfs rw,relatime,size=1021656k,nr_inodes=255414,mode=755 > 0 0
Could you try running this in your system: perl -MFile::Temp=tempfile -wle 'my ($fh, $fn) = tempfile(UNLINK=>1); sub getfstype { my ($fn) = @_; open(my $df, "df $fn |"); my @df = <$df>; my $dev = +(split(" ", $df[1]))[0]; if (open(my $mounts, "/proc/mounts")) { while (<$mounts>){ my @m = split(" "); if ($m[0] eq $dev) { return $m[2] } } } return } print getfstype($fn); ' Show quoted text
> ... > > > On Thu, Jul 14, 2016 at 5:09 AM, Jarkko_Hietaniemi via RT < > bug-Time-HiRes@rt.cpan.org> wrote: >
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=116127 > >> >> Yeah, for the general case some guesswork for the filesystem timestamp >> resolution might be useful. But if there is some more definite way of >> detecting particular filesystems, it would not hurt. >> >> Can you do "df $filename" and get at the relevant more directly? >>
> >
Subject: Re: [rt.cpan.org #116127] t/utime.t fails on ext3
Date: Fri, 15 Jul 2016 13:42:10 -0700
To: bug-Time-HiRes [...] rt.cpan.org
From: Ryan Voots <simcop2387 [...] simcop2387.info>
Looks like it works as expected, on the ext3 system: root@simcop2387:~/letsencrypt-lighttpd# perl -MFile::Temp=tempfile -wle 'my ($fh, $fn) = tempfile(UNLINK=>1); Show quoted text
> sub getfstype { my ($fn) = @_; open(my $df, "df $fn |"); my @df = <$df>; > my $dev = +(split(" ", $df[1]))[0]; if (open(my $mounts, > "/proc/mounts")) { while (<$mounts>){ my @m = split(" "); if ($m[0] eq > $dev) { return $m[2] } } } return } print getfstype($fn); '
ext3 root@simcop2387:~/letsencrypt-lighttpd# on my more modern dev system: # perl -MFile::Temp=tempfile -wle 'my ($fh, $fn) = tempfile(UNLINK=>1); sub getfstype { my ($fn) = @_; open(my $df, "df $fn |"); my @df = <$df>; my $dev = +(split(" ", $df[1]))[0]; if (open(my $mounts, "/proc/mounts")) { while (<$mounts>){ my @m = split(" "); if ($m[0] eq $dev) { return $m[2] } } } return } print getfstype($fn); ' ext4 On Fri, Jul 15, 2016 at 12:21 AM, jhi@iki.fi via RT < bug-Time-HiRes@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=116127 > > > On Friday-201607-15 7:08, simcop2387@simcop2387.info via RT wrote:
> > Queue: Time-HiRes > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=116127 > > > > > Looks like it'll give you the mount point to check, that combined with > > /proc/mounts should let you detect the file system and only enable the
> test
> > on ones that support sub second times > > > > root@simcop2387:~/letsencrypt-lighttpd# df /tmp/tmp.Ki6yC1AIFr > > Filesystem 1K-blocks Used Available Use% Mounted on > > /dev/root 44990064 34542948 9984028 78% / > > > > root@simcop2387:~/letsencrypt-lighttpd# cat /proc/mounts > > /dev/root / ext3 rw,noatime,errors=remount-ro,barrier=0,data=writeback 0
> 0
> > devtmpfs /dev devtmpfs
> rw,relatime,size=1021656k,nr_inodes=255414,mode=755
> > 0 0
> > Could you try running this in your system: > > perl -MFile::Temp=tempfile -wle 'my ($fh, $fn) = tempfile(UNLINK=>1); > sub getfstype { my ($fn) = @_; open(my $df, "df $fn |"); my @df = <$df>; > my $dev = +(split(" ", $df[1]))[0]; if (open(my $mounts, > "/proc/mounts")) { while (<$mounts>){ my @m = split(" "); if ($m[0] eq > $dev) { return $m[2] } } } return } print getfstype($fn); ' >
> > ... > > > > > > On Thu, Jul 14, 2016 at 5:09 AM, Jarkko_Hietaniemi via RT < > > bug-Time-HiRes@rt.cpan.org> wrote: > >
> >> <URL: https://rt.cpan.org/Ticket/Display.html?id=116127 > > >> > >> Yeah, for the general case some guesswork for the filesystem timestamp > >> resolution might be useful. But if there is some more definite way of > >> detecting particular filesystems, it would not hurt. > >> > >> Can you do "df $filename" and get at the relevant more directly? > >>
> > > >
> > >
As CPANTester using an ext2 filesystem, I reproduce this issue, see http://www.cpantesters.org/cpan/report/dde2dfdc-3961-11e6-937e-a6475af59b17 On Wed Jul 13 19:42:27 2016, simcop2387@simcop2387.info wrote: Show quoted text
> The tests for t/utime.t fail when using an older filesystem on linux. I'm > using ext3 on this system and it fails to record the fractional seconds. > > dist/Time-HiRes/t/utime ........................................ # > Failed test 'atime set correctly' > # at t/utime.t line 35. > # got: '1' > # expected: '1.111111111' > # Failed test 'mtime set correctly' > # at t/utime.t line 36. > # got: '2' > # expected: '2.222222222' > # Failed test 'atime set correctly' > # at t/utime.t line 44. > # got: '1' > # expected: '1.111111111' > # Failed test 'mtime set correctly' > # at t/utime.t line 45. > # got: '2' > # expected: '2.222222222' > # Failed test 'File 1 atime set correctly' > # at t/utime.t line 55. > # got: '1' > # expected: '1.111111111' > # Failed test 'File 1 mtime set correctly' > # at t/utime.t line 56. > # got: '2' > # expected: '2.222222222' > # Failed test 'File 2 atime set correctly' > # at t/utime.t line 60. > # got: '1' > # expected: '1.111111111' > # Failed test 'File 2 mtime set correctly' > # at t/utime.t line 61. > # got: '2' > # expected: '2.222222222' > # Failed test 'File 1 atime set correctly' > # at t/utime.t line 75. > # '0.328052043914795' > # < > # '0.1' > # Failed test 'File 1 mtime set correctly' > # at t/utime.t line 76. > # '0.328052043914795' > # < > # '0.1' > # Failed test 'File 2 atime set correctly' > # at t/utime.t line 80. > # '0.328052043914795' > # < > # '0.1' > # Failed test 'File 2 mtime set correctly' > # at t/utime.t line 81. > # '0.328052043914795' > # < > # '0.1' > # Looks like you failed 12 tests of 18. > FAILED at test 2 > dist/XSLoader/t/XSLoader ....................................... ok
On Sat Sep 24 08:55:12 2016, PERRAD wrote: Show quoted text
> As CPANTester using an ext2 filesystem, I reproduce this issue, see > http://www.cpantesters.org/cpan/report/dde2dfdc-3961-11e6-937e- > a6475af59b17
How about with Time-HiRes 1.9739?
Subject: Re: [rt.cpan.org #116127] t/utime.t fails on ext3
Date: Sat, 24 Sep 2016 18:17:38 -0700
To: bug-Time-HiRes [...] rt.cpan.org
From: Ryan Voots <simcop2387 [...] simcop2387.info>
My original report was with 1.9739, here's the full build log. there's nothing in utime.t to skip the tests if the filesystem doesn't support sub-second time stamps. % cat build.log cpanm (App::cpanminus) 1.7027 on perl 5.022000 built for x86_64-linux Work directory is /home/ryan/.cpanm/work/1474765782.17422 You have make /usr/bin/make You have LWP 6.13 You have /bin/tar: tar (GNU tar) 1.27.1 Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html Show quoted text
>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by John Gilmore and Jay Fenlason. You have /usr/bin/unzip Searching Time::HiRes on cpanmetadb ... Unpacking Time-HiRes-1.9739.tar.gz --> Working on Time::HiRes Fetching http://www.cpan.org/authors/id/J/JH/JHI/Time-HiRes-1.9739.tar.gz ... OK Time-HiRes-1.9739/ Time-HiRes-1.9739/Changes Time-HiRes-1.9739/fallback/ Time-HiRes-1.9739/hints/ Time-HiRes-1.9739/HiRes.pm Time-HiRes-1.9739/HiRes.xs Time-HiRes-1.9739/Makefile.PL Time-HiRes-1.9739/MANIFEST Time-HiRes-1.9739/META.json Time-HiRes-1.9739/META.yml Time-HiRes-1.9739/ppport.h Time-HiRes-1.9739/README Time-HiRes-1.9739/t/ Time-HiRes-1.9739/TODO Time-HiRes-1.9739/typemap Time-HiRes-1.9739/t/alarm.t Time-HiRes-1.9739/t/clock.t Time-HiRes-1.9739/t/gettimeofday.t Time-HiRes-1.9739/t/itimer.t Time-HiRes-1.9739/t/nanosleep.t Time-HiRes-1.9739/t/sleep.t Time-HiRes-1.9739/t/stat.t Time-HiRes-1.9739/t/time.t Time-HiRes-1.9739/t/tv_interval.t Time-HiRes-1.9739/t/ualarm.t Time-HiRes-1.9739/t/usleep.t Time-HiRes-1.9739/t/utime.t Time-HiRes-1.9739/t/Watchdog.pm Time-HiRes-1.9739/hints/aix.pl Time-HiRes-1.9739/hints/dec_osf.pl Time-HiRes-1.9739/hints/dynixptx.pl Time-HiRes-1.9739/hints/irix.pl Time-HiRes-1.9739/hints/linux.pl Time-HiRes-1.9739/hints/sco.pl Time-HiRes-1.9739/hints/solaris.pl Time-HiRes-1.9739/hints/svr4.pl Time-HiRes-1.9739/fallback/const-c.inc Time-HiRes-1.9739/fallback/const-xs.inc Entering Time-HiRes-1.9739 Checking configure dependencies from META.json Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.04_01) Running Makefile.PL Configuring Time-HiRes-1.9739 ... Configuring Time::HiRes... Using hints hints/linux.pl... Extra libraries: -lrt... Have syscall()... looking for syscall.h... found <syscall.h>. Looking for gettimeofday()... found. Looking for setitimer()... found. Looking for getitimer()... found. You have interval timers (both setitimer and getitimer). Looking for ualarm()... found. Looking for usleep()... found. Looking for nanosleep()... testing... found. You can mix subsecond sleeps with signals, if you want to. (It's still not portable, though.) Looking for clock_gettime()... found. Looking for clock_getres()... found. Looking for clock_nanosleep()... found. Looking for clock()... found. Looking for futimens()... found. Looking for utimensat()... found. Looking for stat() subsecond timestamps... Trying struct stat st_atimespec.tv_nsec...NOT found. Trying struct stat st_atimensec...NOT found. Trying struct stat st_atime_n...NOT found. Trying struct stat st_atim.tv_nsec...found. Trying struct stat st_uatime...Processing hints file hints/linux.pl NOT found. You seem to have stat() subsecond timestamps. (Your struct stat has them, but the filesystems must help.) Checking if your kit is complete... Looks good Generating a Unix-style Makefile Writing Makefile for Time::HiRes Writing MYMETA.yml and MYMETA.json Now you may issue 'make'. Do not forget also 'make test'. Checking dependencies from MYMETA.json ... Checking if you have Test::More 0 ... Yes (1.001014) Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.04_01) Checking if you have Carp 0 ... Yes (1.38) Checking if you have DynaLoader 0 ... Yes (1.32) Checking if you have Config 0 ... Yes (5.022000) Checking if you have strict 0 ... Yes (1.09) Checking if you have Exporter 0 ... Yes (5.72) OK Building and testing Time-HiRes-1.9739 ... cp HiRes.pm blib/lib/Time/HiRes.pm Running Mkbootstrap for Time::HiRes () chmod 644 "HiRes.bs" "/home/ryan/perl5/perlbrew/perls/perl-5.22.0/bin/perl" "/home/ryan/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/ExtUtils/xsubpp" -typemap "/home/ryan/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/ExtUtils/typemap" -typemap "typemap" HiRes.xs > HiRes.xsc && mv HiRes.xsc HiRes.c cc -c -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -O2 -DVERSION=\"1.9739\" -DXS_VERSION=\"1.9739\" -fPIC "-I/home/ryan/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/x86_64-linux/CORE" -DTIME_HIRES_NANOSLEEP -DTIME_HIRES_CLOCK_GETTIME -DTIME_HIRES_CLOCK_GETRES -DTIME_HIRES_CLOCK_NANOSLEEP -DTIME_HIRES_CLOCK -DHAS_FUTIMENS -DHAS_UTIMENSAT -DTIME_HIRES_UTIME -DTIME_HIRES_STAT_XTIM -DTIME_HIRES_STAT=4 -DATLEASTFIVEOHOHFIVE HiRes.c rm -f blib/arch/auto/Time/HiRes/HiRes.so LD_RUN_PATH="/lib/x86_64-linux-gnu" cc -shared -O2 -L/usr/local/lib -fstack-protector HiRes.o -o blib/arch/auto/Time/HiRes/HiRes.so \ -lrt \ chmod 755 blib/arch/auto/Time/HiRes/HiRes.so "/home/ryan/perl5/perlbrew/perls/perl-5.22.0/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- HiRes.bs blib/arch/auto/Time/HiRes/HiRes.bs 644 Manifying 1 pod document Running Mkbootstrap for Time::HiRes () chmod 644 "HiRes.bs" PERL_DL_NONLAZY=1 "/home/ryan/perl5/perlbrew/perls/perl-5.22.0/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/alarm.t ......... ok t/clock.t ......... ok t/gettimeofday.t .. ok t/itimer.t ........ ok t/nanosleep.t ..... ok t/sleep.t ......... ok t/stat.t .......... ok t/time.t .......... ok t/tv_interval.t ... ok t/ualarm.t ........ ok t/usleep.t ........ ok # Failed test 'atime set correctly' # at t/utime.t line 35. # got: '1' # expected: '1.111111111' # Failed test 'mtime set correctly' # at t/utime.t line 36. # got: '2' # expected: '2.222222222' # Failed test 'atime set correctly' # at t/utime.t line 44. # got: '1' # expected: '1.111111111' # Failed test 'mtime set correctly' # at t/utime.t line 45. # got: '2' # expected: '2.222222222' # Failed test 'File 1 atime set correctly' # at t/utime.t line 55. # got: '1' # expected: '1.111111111' # Failed test 'File 1 mtime set correctly' # at t/utime.t line 56. # got: '2' # expected: '2.222222222' # Failed test 'File 2 atime set correctly' # at t/utime.t line 60. # got: '1' # expected: '1.111111111' # Failed test 'File 2 mtime set correctly' # at t/utime.t line 61. # got: '2' # expected: '2.222222222' # Failed test 'File 1 atime set correctly' # at t/utime.t line 75. # '0.439713954925537' # < # '0.1' # Failed test 'File 1 mtime set correctly' # at t/utime.t line 76. # '0.439713954925537' # < # '0.1' # Failed test 'File 2 atime set correctly' # at t/utime.t line 80. # '0.439713954925537' # < # '0.1' # Failed test 'File 2 mtime set correctly' # at t/utime.t line 81. # '0.439713954925537' # < # '0.1' # Looks like you failed 12 tests of 18. t/utime.t ......... Dubious, test returned 12 (wstat 3072, 0xc00) Failed 12/18 subtests Test Summary Report ------------------- t/utime.t (Wstat: 3072 Tests: 18 Failed: 12) Failed tests: 2-3, 5-6, 8-11, 13-16 Non-zero exit status: 12 Files=12, Tests=113, 27 wallclock secs ( 0.10 usr 0.02 sys + 13.97 cusr 0.16 csys = 14.25 CPU) Result: FAIL Failed 1/12 test programs. 12/113 subtests failed. Makefile:1032: recipe for target 'test_dynamic' failed make: *** [test_dynamic] Error 12 ! Installing Time::HiRes failed. See /home/ryan/.cpanm/work/1474765782.17422/build.log for details. Retry with --force to force install it. FAIL On Sat, Sep 24, 2016 at 5:16 PM, Jarkko_Hietaniemi via RT < bug-Time-HiRes@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=116127 > > > On Sat Sep 24 08:55:12 2016, PERRAD wrote:
> > As CPANTester using an ext2 filesystem, I reproduce this issue, see > > http://www.cpantesters.org/cpan/report/dde2dfdc-3961-11e6-937e- > > a6475af59b17
> > How about with Time-HiRes 1.9739? > > > >
On Sat Sep 24 21:17:59 2016, simcop2387@simcop2387.info wrote: Show quoted text
> My original report was with 1.9739, here's the full build log. there's > nothing in utime.t to skip the tests if the filesystem doesn't support > sub-second time stamps.
Right. I had forgotten where this started.
If you could try the attached patch? It is against the Perl core (because that's the primary source of Time-HiRes now), so e.g. "git am" is probably not going to work well, but manual patching with "patch -p2 < 0001-*.patch" while in the Time-HiRes directory should work.
Subject: 0001-Detect-ext3-ext2-they-do-not-have-hires-utime.patch
From 2ab2080de68f5baf3a419b49154ffdfb68932ccc Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi <jhi@iki.fi> Date: Sat, 24 Sep 2016 22:01:59 -0400 Subject: [PATCH] Detect ext3/ext2, they do not have hires utime. --- dist/Time-HiRes/t/utime.t | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/dist/Time-HiRes/t/utime.t b/dist/Time-HiRes/t/utime.t index ede2e78..aaf1225 100644 --- a/dist/Time-HiRes/t/utime.t +++ b/dist/Time-HiRes/t/utime.t @@ -23,9 +23,46 @@ use File::Temp qw( tempfile ); use Config; -# Cygwin timestamps have less precision. -my $atime = $^O eq 'cygwin' ? 1.1111111 : 1.111111111; -my $mtime = $^O eq 'cygwin' ? 2.2222222 : 2.222222222; +# Hope initially for nanosecond accuracy. +my $atime = 1.111111111; +my $mtime = 2.222222222; + +if ($^O eq 'cygwin') { + # Cygwin timestamps have less precision. + $atime = 1.1111111; + $mtime = 2.2222222; +} elsif ($^O eq 'linux' && -e '/proc/mounts') { + # The linux might be wrong when ext3 + # is available in other operating systems, + # but then we need other methods for detecting + # the filesystem type of the tempfiles. + my ($fh, $fn) = tempfile(UNLINK => 1); + sub getfstype { + my ($fn) = @_; + my $cmd = "df $fn"; + open(my $df, "$cmd |") or die "$cmd: $!"; + my @df = <$df>; # Assume $df[0] is header line. + my $dev = +(split(" ", $df[1]))[0]; + open(my $mounts, "/proc/mounts") or die "/proc/mounts: $!"; + while (<$mounts>) { + my @m = split(" "); + if ($m[0] eq $dev) { return $m[2] } + } + return; + } + my $fstype = getfstype($fn); + unless (defined $fstype) { + warn "Unknown fstype for $fn\n"; + } else { + print "# fstype = $fstype\n"; + if ($fstype eq 'ext3' || $fstype eq 'ext2') { + $atime = int($atime); + $mtime = int($mtime); + } + } +} + +print "# \$^O = $^O, atime = $atime, mtime = $mtime\n"; print "# utime \$fh\n"; { -- 2.9.3
Subject: Re: [rt.cpan.org #116127] t/utime.t fails on ext3
Date: Sat, 24 Sep 2016 19:26:44 -0700
To: bug-Time-HiRes [...] rt.cpan.org
From: Ryan Voots <simcop2387 [...] simcop2387.info>
Helps but there's still some issues, it looks like the other tests in there are also expecting sub-second times, in particular it looks like the first four failures here are happening because $got_atime, and $got_mtime are both rounded up to 1, but $now is properly more precise. Since all of these tests seem to require the filesystem to support <1 sec precision, i think it would be best to skip the tests since while everything will function, it won't ever pass on the case of ext2/ext3 (i suspect other older filesystems too but don't have an exhaustive list). t/utime.t ......... 1/18 # Failed test 'File 1 atime set correctly' # at t/utime.t line 112. # '0.955666065216064' # < # '0.1' # Failed test 'File 1 mtime set correctly' # at t/utime.t line 113. # '0.955666065216064' # < # '0.1' # Failed test 'File 2 atime set correctly' # at t/utime.t line 117. # '0.955666065216064' # < # '0.1' # Failed test 'File 2 mtime set correctly' # at t/utime.t line 118. # '0.955666065216064' # < # '0.1' # Failed test 'negative time error' # at t/utime.t line 125. # 'Time::HiRes::utime(-4, 2): negative time not invented yet at t/utime.t line 124. # ' # doesn't match '(?^:::utime\(-4, 2\.22222\): negative time not invented yet)' # Failed test 'negative time error' # at t/utime.t line 132. # 'Time::HiRes::utime(1, -4): negative time not invented yet at t/utime.t line 131. # ' # doesn't match '(?^:::utime\(1.11111, -4\): negative time not invented yet)' # Looks like you failed 6 tests of 18. t/utime.t ......... Dubious, test returned 6 (wstat 1536, 0x600) Failed 6/18 subtests Test Summary Report ------------------- t/utime.t (Wstat: 1536 Tests: 18 Failed: 6) Failed tests: 13-18 Non-zero exit status: 6 Files=12, Tests=113, 26 wallclock secs ( 0.08 usr 0.03 sys + 14.18 cusr 0.12 csys = 14.41 CPU) Result: FAIL Failed 1/12 test programs. 6/113 subtests failed. Makefile:1032: recipe for target 'test_dynamic' failed make: *** [test_dynamic] Error 6 On Sat, Sep 24, 2016 at 7:16 PM, Jarkko_Hietaniemi via RT < bug-Time-HiRes@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=116127 > > > If you could try the attached patch? It is against the Perl core (because > that's the primary source of Time-HiRes now), so e.g. "git am" is probably > not going to work well, but manual patching with "patch -p2 < 0001-*.patch" > while in the Time-HiRes directory should work. > > >
Hmm, okay. Thanks for testing. Please try the try #2.
Subject: 0001-Detect-ext3-ext2-they-do-not-have-hires-utime.patch
From 361d755d54edbe0a5bae1406a34fd055562cd133 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi <jhi@iki.fi> Date: Sat, 24 Sep 2016 22:01:59 -0400 Subject: [PATCH] Detect ext3/ext2, they do not have hires utime. --- dist/Time-HiRes/t/utime.t | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/dist/Time-HiRes/t/utime.t b/dist/Time-HiRes/t/utime.t index ede2e78..795252e 100644 --- a/dist/Time-HiRes/t/utime.t +++ b/dist/Time-HiRes/t/utime.t @@ -3,6 +3,7 @@ use strict; BEGIN { require Time::HiRes; require Test::More; + require File::Temp; unless(&Time::HiRes::d_hires_utime) { Test::More::plan(skip_all => "no hires_utime"); } @@ -15,6 +16,35 @@ BEGIN { if ($^O eq 'gnukfreebsd') { Test::More::plan(skip_all => "futimens() and utimensat() not working in $^O"); } + if ($^O eq 'linux' && -e '/proc/mounts') { + # The linux might be wrong when ext3 + # is available in other operating systems, + # but then we need other methods for detecting + # the filesystem type of the tempfiles. + my ($fh, $fn) = File::Temp::tempfile(UNLINK => 1); + sub getfstype { + my ($fn) = @_; + my $cmd = "df $fn"; + open(my $df, "$cmd |") or die "$cmd: $!"; + my @df = <$df>; # Assume $df[0] is header line. + my $dev = +(split(" ", $df[1]))[0]; + open(my $mounts, "/proc/mounts") or die "/proc/mounts: $!"; + while (<$mounts>) { + my @m = split(" "); + if ($m[0] eq $dev) { return $m[2] } + } + return; + } + my $fstype = getfstype($fn); + unless (defined $fstype) { + warn "Unknown fstype for $fn\n"; + } else { + print "# fstype = $fstype\n"; + if ($fstype eq 'ext3' || $fstype eq 'ext2') { + Test::More::plan(skip_all => "fstype $fstype has no subsecond timestamps in $^O"); + } + } + } } use Test::More tests => 18; @@ -23,9 +53,16 @@ use File::Temp qw( tempfile ); use Config; -# Cygwin timestamps have less precision. -my $atime = $^O eq 'cygwin' ? 1.1111111 : 1.111111111; -my $mtime = $^O eq 'cygwin' ? 2.2222222 : 2.222222222; +# Hope initially for nanosecond accuracy. +my $atime = 1.111111111; +my $mtime = 2.222222222; + +if ($^O eq 'cygwin') { + # Cygwin timestamps have less precision. + $atime = 1.1111111; + $mtime = 2.2222222; +} +print "# \$^O = $^O, atime = $atime, mtime = $mtime\n"; print "# utime \$fh\n"; { -- 2.9.3
Subject: Re: [rt.cpan.org #116127] t/utime.t fails on ext3
Date: Sat, 24 Sep 2016 20:16:44 -0700
To: bug-Time-HiRes [...] rt.cpan.org
From: Ryan Voots <simcop2387 [...] simcop2387.info>
Passes here, -> % make test Running Mkbootstrap for Time::HiRes () chmod 644 "HiRes.bs" PERL_DL_NONLAZY=1 "/home/ryan/perl5/perlbrew/perls/perl-5.22.0/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/alarm.t ......... ok t/clock.t ......... ok t/gettimeofday.t .. ok t/itimer.t ........ ok t/nanosleep.t ..... ok t/sleep.t ......... ok t/stat.t .......... ok t/time.t .......... ok t/tv_interval.t ... ok t/ualarm.t ........ ok t/usleep.t ........ ok t/utime.t ......... skipped: fstype ext3 has no subsecond timestamps in linux All tests successful. Files=12, Tests=95, 26 wallclock secs ( 0.09 usr 0.02 sys + 14.18 cusr 0.14 csys = 14.43 CPU) Result: PASS On Sat, Sep 24, 2016 at 7:45 PM, Jarkko_Hietaniemi via RT < bug-Time-HiRes@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=116127 > > > Hmm, okay. Thanks for testing. Please try the try #2. > >
Released Time-HiRes 1.9740.
Subject: Re: [rt.cpan.org #116127] t/utime.t fails on ext3
Date: Sun, 25 Sep 2016 16:12:48 -0700
To: bug-Time-HiRes [...] rt.cpan.org
From: Ryan Voots <simcop2387 [...] simcop2387.info>
Just tested it off cpan, works great On Sun, Sep 25, 2016 at 3:40 PM, Jarkko_Hietaniemi via RT < bug-Time-HiRes@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=116127 > > > Released Time-HiRes 1.9740. > >
On Sun Sep 25 18:40:57 2016, JHI wrote: Show quoted text
> Released Time-HiRes 1.9740.
The version 1.9740 still fails on my box, see http://www.cpantesters.org/cpan/report/1ecc29dc-84b6-11e6-be39-9d3809623efe The reason is : - tempfile() with template gives a file in the current directory which is on ext2 - tempfile() without template gives a file in /tmp which is on ext4 The attached patch solves this issue. Francois
Subject: 0001-use-everywhere-tempfile-with-template.patch
use everywhere tempfile() with template Signed-off-by: Francois Perrad <francois.perrad@gadz.org> --- a/t/utime.t +++ b/t/utime.t @@ -21,7 +21,7 @@ BEGIN { # is available in other operating systems, # but then we need other methods for detecting # the filesystem type of the tempfiles. - my ($fh, $fn) = File::Temp::tempfile(UNLINK => 1); + my ($fh, $fn) = File::Temp::tempfile( "Time-HiRes-utime-XXXXXXXXX", UNLINK => 1); sub getfstype { my ($fn) = @_; my $cmd = "df $fn"; --
On Sun Oct 02 03:17:17 2016, PERRAD wrote: Show quoted text
> On Sun Sep 25 18:40:57 2016, JHI wrote:
> > Released Time-HiRes 1.9740.
> > The version 1.9740 still fails on my box, see > http://www.cpantesters.org/cpan/report/1ecc29dc-84b6-11e6-be39- > 9d3809623efe > > The reason is : > - tempfile() with template gives a file in the current directory which > is on ext2 > - tempfile() without template gives a file in /tmp which is on ext4 > > The attached patch solves this issue. > > Francois
Offline, Jarkko asked me to take care of this patch, i.e., apply it to Perl 5 blead, as Time-HiRes is "blead upstream." I did so; see http://perl5.git.perl.org/perl.git/commitdiff/91dca83e. François, could you verify that Perl 5 blead PASSes for you on your mixed-filesystem architecture? If there are *still* problems with Time-HiRes, could you then open a bug ticket with 'perlbug'? I recommend that this ticket be closed. Thank you very much. Jim Keenan
On Sun Oct 09 16:54:27 2016, JKEENAN wrote: Show quoted text
> On Sun Oct 02 03:17:17 2016, PERRAD wrote:
> > On Sun Sep 25 18:40:57 2016, JHI wrote:
> > > Released Time-HiRes 1.9740.
> > > > The version 1.9740 still fails on my box, see > > http://www.cpantesters.org/cpan/report/1ecc29dc-84b6-11e6-be39- > > 9d3809623efe > > > > The reason is : > > - tempfile() with template gives a file in the current directory > > which > > is on ext2 > > - tempfile() without template gives a file in /tmp which is on ext4 > > > > The attached patch solves this issue. > > > > Francois
> > Offline, Jarkko asked me to take care of this patch, i.e., apply it to > Perl 5 blead, as Time-HiRes is "blead upstream." I did so; see > http://perl5.git.perl.org/perl.git/commitdiff/91dca83e. > > François, could you verify that Perl 5 blead PASSes for you on your > mixed-filesystem architecture? If there are *still* problems with > Time-HiRes, could you then open a bug ticket with 'perlbug'? >
$ perlbrew install blead dist/Time-HiRes/t/utime ........................................ skipped So, it is OK. François Show quoted text
> I recommend that this ticket be closed. > > Thank you very much. > Jim Keenan
I find this /proc/mounts and df magic a bit hacky and overengineered. You could instead touch a file twice with a subsecond sleep in between and check if you get subsecond stat() results like this: use Time::HiRes qw(sleep stat); sub have_subsecond_file_times { my @mtimes; for (1..2) { open my $f, '>', 'stattest'; push @mtimes, (stat $f)[9]; close $f; sleep .25 if $_ == 1; } my $delta = $mtimes[1] - $mtimes[0]; return $delta > 0 && $delta < 1; } This has the advantage that it doesn't depend on hard-coded assumptions on filesystem types and it works on systems other than Linux too.
FWIW I still get this issue on any modern Perl, using Macosx Sierra. Anything I can do to help? John On Fri Jul 21 09:22:10 2017, CGPAN wrote: Show quoted text
> I find this /proc/mounts and df magic a bit hacky and overengineered. > You could instead touch a file twice with a subsecond sleep in between > and check if you get subsecond stat() results like this: > > > use Time::HiRes qw(sleep stat); > > sub have_subsecond_file_times { > my @mtimes; > for (1..2) { > open my $f, '>', 'stattest'; > push @mtimes, (stat $f)[9]; > close $f; > sleep .25 if $_ == 1; > } > my $delta = $mtimes[1] - $mtimes[0]; > return $delta > 0 && $delta < 1; > } > > > This has the advantage that it doesn't depend on hard-coded > assumptions on filesystem types and it works on systems other than > Linux too.
On Thu Jan 11 09:14:35 2018, JJNAPIORK wrote: Show quoted text
> FWIW I still get this issue on any modern Perl, using Macosx Sierra. > Anything I can do to help? >
Including using the more recent releases of Time-HiRes from CPAN? The newer releases should have fixed this problem. The older releases Perl you can install to macosx obviously still have older releases of Time-HiRes.
On Thu Jan 11 09:14:35 2018, JJNAPIORK wrote: Show quoted text
> FWIW I still get this issue on any modern Perl, using Macosx Sierra. > Anything I can do to help?
Please tell us with which Perls and which Time-HiRes versions you have tested, and on which macosx filesystems? Show quoted text
> John > > On Fri Jul 21 09:22:10 2017, CGPAN wrote:
> > I find this /proc/mounts and df magic a bit hacky and overengineered. > > You could instead touch a file twice with a subsecond sleep in > > between > > and check if you get subsecond stat() results like this: > > > > > > use Time::HiRes qw(sleep stat); > > > > sub have_subsecond_file_times { > > my @mtimes; > > for (1..2) { > > open my $f, '>', 'stattest'; > > push @mtimes, (stat $f)[9]; > > close $f; > > sleep .25 if $_ == 1; > > } > > my $delta = $mtimes[1] - $mtimes[0]; > > return $delta > 0 && $delta < 1; > > } > > > > > > This has the advantage that it doesn't depend on hard-coded > > assumptions on filesystem types and it works on systems other than > > Linux too.
I just hit this building perl-5.26.2 on OSX 10.13.5. Filesystem: Mac OS Extended (Journaled) All tests pass except: # Looks like you failed 12 tests of 18. ../dist/Time-HiRes/t/utime.t ....................................... Dubious, test returned 12 (wstat 3072, 0xc00) Failed 12/18 subtests
update: 5.28.0 passes on the same system as the previous comment. Perhaps something needs to be backported?
On Mon Jun 25 14:26:42 2018, JOSHR wrote: Show quoted text
> update: 5.28.0 passes on the same system as the previous comment. > Perhaps something needs to be backported?
The Time::HiRes distribution is now primarily maintained in the Perl 5 core distribution ("blead upstream"). For backporting to any perl-5.26.3 release, we need to have a ticket in the core distribution's issue tracker that we can link to the "blockers for 5.26.3" ticket. Therefore, what I would ask you to do is the following: 1. Confirm that if you try to install the latest version available on CPAN (https://metacpan.org/release/Time-HiRes) against perl-5.26.2, it passes all its tests. (You don't actually have to install if you don't want to. You could, e.g., say 'test Time::HiRes' inside the 'cpan' shell utility.) 2. Assuming you get a PASS, please file a ticket via perlbug@perl.org with the following information: a. 'perl -V' information for your perl-5.26.2 installation. b. For failing test, output of: ##### cd t;./perl harness -v ../dist/Time-Hires/t/utime.t; cd - ##### c. Link to *this* rt.cpan.org ticket. d. Request to include in any perl-5.26.3 release. (I'm not guaranteeing that there will be such a release; it's up to the maintenance pumpking. But if you file such a ticket I will include it on the backport list.) Time::HiRes has moved on quite a bit since the release included in perl-5.26.2, so the backport may be tricky. ##### $ corelist -a Time::HiRes | grep 'v5.26.2' v5.26.2 1.9741 ##### Thank you very much. Jim Keenan