mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	spec/ruby/core/file/utime_spec.rb: far future timestamp may be trancated
Under some Ext4 filesystem settings, a timestamp is limited up to 0x37fffffff (2446-05-10). https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Inode_Timestamps > Therefore, timestamps should not overflow until May 2446. Actually the spec fails under one of our CI environments, like: ``` 1) File.utime allows Time instances in the far future to set mtime and atime FAILED Expected 2446 == 559444 to be truthy but was false ``` https://rubyci.org/logs/rubyci.s3.amazonaws.com/arch/ruby-master/log/20200208T180002Z.fail.html.gz
This commit is contained in:
		
							parent
							
								
									acb9b73495
								
							
						
					
					
						commit
						2173ae7801
					
				
					 1 changed files with 5 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -72,11 +72,13 @@ describe "File.utime" do
 | 
			
		|||
 | 
			
		||||
  platform_is :linux do
 | 
			
		||||
    platform_is wordsize: 64 do
 | 
			
		||||
      it "allows Time instances in the far future to set mtime and atime" do
 | 
			
		||||
      it "allows Time instances in the far future to set mtime and atime (but some filesystems limit it up to 2446-05-10)" do
 | 
			
		||||
        # https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Inode_Timestamps
 | 
			
		||||
        # "Therefore, timestamps should not overflow until May 2446."
 | 
			
		||||
        time = Time.at(1<<44)
 | 
			
		||||
        File.utime(time, time, @file1)
 | 
			
		||||
        File.atime(@file1).year.should == 559444
 | 
			
		||||
        File.mtime(@file1).year.should == 559444
 | 
			
		||||
        [559444, 2446].should.include? File.atime(@file1).year
 | 
			
		||||
        [559444, 2446].should.include? File.mtime(@file1).year
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue