aboutsummaryrefslogtreecommitdiffstats
path: root/main/perl/0002-Time-HiRes-bring-up-to-date-with-CPAN.patch
blob: 68cf3c66a077e6fbeeb1d93c434f8b6d3c88b702 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
From 3a57bd4d5e78d639b78eed9fcc27028720f8d326 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Sun, 25 Sep 2016 19:48:52 -0400
Subject: [PATCH] Time-HiRes: bring up-to-date with CPAN.

The ext3/ext2 filesystems do not have subsecond resolution, therefore skip the
t/utime.t test. [rt.cpan.org #116127]
---
 dist/Time-HiRes/Changes   |  5 +++++
 dist/Time-HiRes/HiRes.pm  |  2 +-
 dist/Time-HiRes/t/utime.t | 43 ++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/dist/Time-HiRes/Changes b/dist/Time-HiRes/Changes
index d54fda8..e21623b 100644
--- a/dist/Time-HiRes/Changes
+++ b/dist/Time-HiRes/Changes
@@ -1,5 +1,10 @@
 Revision history for the Perl extension Time::HiRes.
 
+1.9740 [2016-09-25]
+  - the ext3/ext2 filesystems do not have subsecond resolution,
+    therefore skip the t/utime.t test
+    [rt.cpan.org #116127]
+
 1.9739 [2016-06-28]
   - the upcoming macOS 10.12 (Sierra, the operating system formerly
     known as OS X, or Darwin) has implemented the clock_gettime()
diff --git a/dist/Time-HiRes/HiRes.pm b/dist/Time-HiRes/HiRes.pm
index 2071e5e..a4c5002 100644
--- a/dist/Time-HiRes/HiRes.pm
+++ b/dist/Time-HiRes/HiRes.pm
@@ -28,7 +28,7 @@ our @EXPORT_OK = qw (usleep sleep ualarm alarm gettimeofday time tv_interval
 		 stat lstat utime
 		);
 
-our $VERSION = '1.9739';
+our $VERSION = '1.9740';
 our $XS_VERSION = $VERSION;
 $VERSION = eval $VERSION;
 
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.7.4