Skip to content

Commit 4fc6eae

Browse files
author
M Bussonnier
committed
split test for 32 and 64 bits systems
1 parent 11ec510 commit 4fc6eae

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/by-util/test_touch.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,11 @@ fn test_touch_set_mdhms_time() {
119119
}
120120

121121
#[test]
122+
#[cfg(target_pointer_width = "64")]
122123
fn test_touch_2_digit_years_68() {
123124
// 68 and before are 20xx
125+
// it will fail on 32 bits, because of wraparound for anything after
126+
// 2038-01-19
124127
let (at, mut ucmd) = at_and_ucmd!();
125128
let file = "test_touch_set_two_digit_68_time";
126129

@@ -138,6 +141,27 @@ fn test_touch_2_digit_years_68() {
138141
assert_eq!(mtime, expected);
139142
}
140143

144+
#[test]
145+
fn test_touch_2_digit_years_2038() {
146+
// Same as test_touch_2_digit_years_68 but for 32 bits systems
147+
// we test a date before the y2038 bug
148+
let (at, mut ucmd) = at_and_ucmd!();
149+
let file = "test_touch_set_two_digit_68_time";
150+
151+
ucmd.args(&["-t", "3801010000", file])
152+
.succeeds()
153+
.no_output();
154+
155+
assert!(at.file_exists(file));
156+
157+
// January 1, 2038, 00:00:00
158+
let expected = FileTime::from_unix_time(2_145_916_800, 0);
159+
let (atime, mtime) = get_file_times(&at, file);
160+
assert_eq!(atime, mtime);
161+
assert_eq!(atime, expected);
162+
assert_eq!(mtime, expected);
163+
}
164+
141165
#[test]
142166
fn test_touch_2_digit_years_69() {
143167
// 69 and after are 19xx

0 commit comments

Comments
 (0)