in reply to Re^2: Perl release v5.40.1 on a 32-bit box showing failed tests for atime and ctime in Time::HiRes
in thread Perl release v5.40.1 on a 32-bit box showing failed tests for atime and ctime in Time::HiRes

From your other comment you're using ext4, so I'd expect the file system to support sub-second timestamps, if you do:

# this is a command-line command, not perl code stat .

does it show sub-second timestamps, eg. I get

$ stat . File: . Size: 20480 Blocks: 40 IO Block: 4096 directory Device: 253,2 Inode: 33079540 Links: 26 Access: (0755/drwxr-xr-x) Uid: ( 1000/ tony) Gid: ( 1000/ ton +y) Access: 2025-03-10 07:39:22.352732987 +1100 Modify: 2025-03-06 15:07:42.145467132 +1100 Change: 2025-03-06 15:07:42.145467132 +1100 Birth: 2022-08-08 15:04:51.515950529 +1000
  • Comment on Re^3: Perl release v5.40.1 on a 32-bit box showing failed tests for atime and ctime in Time::HiRes
  • Select or Download Code

Replies are listed 'Best First'.
Re^4: Perl release v5.40.1 on a 32-bit box showing failed tests for atime and ctime in Time::HiRes
by Intrepid (Curate) on Mar 12, 2025 at 02:24 UTC

    OK, let's see if we get sub-second times:

      File: .
      Size: 4096      	Blocks: 8          IO Block: 4096   directory
    Device: 0,44	Inode: 38143619    Links: 3
    Access: (0755/drwxr-xr-x)  Uid: ( 1000/  somian)   Gid: ( 1000/  somian)
    Access: 2025-03-10 14:53:44.479709798 -0400
    Modify: 2025-03-02 15:29:55.074591170 -0500
    Change: 2025-03-02 15:29:55.074591170 -0500
     Birth: -
    

    Aside from not seeing Birth times for any directory or regular file, it seems that I am running ext4 and ext4 is behaving as expecting.

    Mar 12, 2025 at 02:23 UTC

    A just machine to make big decisions
    Programmed by fellows (and gals) with compassion and vision
    We'll be clean when their work is done
    We'll be eternally free yes, and eternally young
    Donald Fagen —> I.G.Y.
    (Slightly modified for inclusiveness)

      I don't know.

      The only other test I can think of is to modify the test script to display the filename (around line 156) and additionally run stat on it

      is $got_mtime, $mtime, "mtime set correctly"; # added lines follow note "File $filename"; system "stat $filename"; system "stat -f $filename"; # added lines before this };

      The most obvious cause could be that the APIs aren't detected properly, but utime.t checks that the APIs have been found before running these tests.

      You may want to open a ticket at https://github.com/Perl/perl5/issues

        Follow-up to test errors on subsecond timestamps on files in perl 5.4.1, Time::HiRes

        tonyc, I put your additional lines of code into utime.t and this is the full output:

        # Testing for subsecond file timestamps (mtime) in /home/somian/build/perl/perl-debian-5.40/dist/Time-HiRes
        # Subsecond file timestamps in /home/somian/build/perl/perl-debian-5.40/dist/Time-HiRes: OK
        1..22
        # I am the main process 5420, starting the watchdog process...
        # I am the watchdog process 5421, sleeping for 360 seconds...
        # The watchdog process 5421 launched, continuing testing...
        # $^O = linux, atime = 1.111111111, mtime = 2.222222222
        # utime $fh
        ok 1 - One file changed
        not ok 2 - atime set correctly
        
        #   Failed test 'atime set correctly'
        #   at t/utime.t line 156.
        #          got: '1'
        #     expected: '1.111111111'
        # File Time-HiRes-utime-wUS033Puo
          File: Time-HiRes-utime-wUS033Puo
          Size: 0         	Blocks: 16         IO Block: 4096   regular empty file
        Device: 0,44	Inode: 38171226    Links: 1
        Access: (0600/-rw-------)  Uid: ( 1000/  somian)   Gid: ( 1000/  somian)
        Access: 1969-12-31 19:00:01.000000000 -0500
        Modify: 1969-12-31 19:00:02.000000000 -0500
        Change: 2025-03-13 14:30:24.401330294 -0400
         Birth: -
          File: "Time-HiRes-utime-wUS033Puo"
            ID: c5ff08d4ce0ba8ed Namelen: 143     Type: ecryptfs
        Block size: 4096       Fundamental block size: 4096
        Blocks: Total: 157996844  Free: 155774090  Available: 147729918
        Inodes: Total: 40206336   Free: 39635781
        not ok 3 - mtime set correctly
        
        #   Failed test 'mtime set correctly'
        #   at t/utime.t line 161.
        #          got: '2'
        #     expected: '2.222222222'
        #utime $filename
        ok 4 - One file changed
        not ok 5 - atime set correctly
        
        #   Failed test 'atime set correctly'
        #   at t/utime.t line 171.
        #          got: '1'
        #     expected: '1.111111111'
        not ok 6 - mtime set correctly
        
        #   Failed test 'mtime set correctly'
        #   at t/utime.t line 173.
        #          got: '2'
        #     expected: '2.222222222'
        #utime $filename round-trip
        ok 7 - One file changed
        ok 8 - One file changed
        ok 9 - atime round trip ok
        ok 10 - mtime round trip ok
        utime $filename and $fh
        ok 11 - Two files changed
        not ok 12 - File 1 atime set correctly
        
        #   Failed test 'File 1 atime set correctly'
        #   at t/utime.t line 198.
        #          got: '1'
        #     expected: '1.111111111'
        not ok 13 - File 1 mtime set correctly
        
        #   Failed test 'File 1 mtime set correctly'
        #   at t/utime.t line 200.
        #          got: '2'
        #     expected: '2.222222222'
        not ok 14 - File 2 atime set correctly
        
        #   Failed test 'File 2 atime set correctly'
        #   at t/utime.t line 206.
        #          got: '1'
        #     expected: '1.111111111'
        not ok 15 - File 2 mtime set correctly
        
        #   Failed test 'File 2 mtime set correctly'
        #   at t/utime.t line 208.
        #          got: '2'
        #     expected: '2.222222222'
        # utime undef sets time to now
        ok 16 - Two files changed
        ok 17 - File 1 atime set correctly
        ok 18 - File 1 mtime set correctly
        ok 19 - File 2 atime set correctly
        ok 20 - File 2 mtime set correctly
        # negative atime dies
        ok 21 - negative time error
        # negative mtime dies;
        ok 22 - negative time error
        # I am the main process 5420, terminating the watchdog process 5421 before it terminates me in 359 seconds (testing took 1 seconds).
        # kill KILL 5421 = 1
        # All done.
        # Looks like you failed 8 tests of 22.
        Dubious, test returned 8 (wstat 2048, 0x800)
        Failed 8/22 subtests 
        
        Test Summary Report
        -------------------
        ../dist/Time-HiRes/t/utime.t (Wstat: 2048 (exited 8) Tests: 22 Failed: 8)
          Failed tests:  2-3, 5-6, 12-15
          Non-zero exit status: 8
        Files=1, Tests=22,  2 wallclock secs ( 0.01 usr  0.01 sys +  0.22 cusr  0.06 csys =  0.30 CPU)
        Result: FAIL
        Finished test run at Thu Mar 13 14:30:25 2025.
        

        This time something jumps out at us: the filesystem is ecryptfs. I had forgotten that I followed the install-time prompts to set up encryption on my home dir. Could this be relevant to the test failures we're seeing? I am wondering if I try building perl and running the tests on another filesystem location, will that show different results for the tests in utime.t.

        Thanks again for hanging in there with me, tonyc.

        Mar 13, 2025 at 18:52 UTC