1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

split test for 32 and 64 bits systems

This commit is contained in:
M Bussonnier 2025-03-05 13:22:23 +01:00 committed by Dorian Péron
parent 7632acfc90
commit 57d0157c6a

View file

@ -119,8 +119,11 @@ fn test_touch_set_mdhms_time() {
} }
#[test] #[test]
#[cfg(target_pointer_width = "64")]
fn test_touch_2_digit_years_68() { fn test_touch_2_digit_years_68() {
// 68 and before are 20xx // 68 and before are 20xx
// it will fail on 32 bits, because of wraparound for anything after
// 2038-01-19
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let file = "test_touch_set_two_digit_68_time"; let file = "test_touch_set_two_digit_68_time";
@ -138,6 +141,27 @@ fn test_touch_2_digit_years_68() {
assert_eq!(mtime, expected); assert_eq!(mtime, expected);
} }
#[test]
fn test_touch_2_digit_years_2038() {
// Same as test_touch_2_digit_years_68 but for 32 bits systems
// we test a date before the y2038 bug
let (at, mut ucmd) = at_and_ucmd!();
let file = "test_touch_set_two_digit_68_time";
ucmd.args(&["-t", "3801010000", file])
.succeeds()
.no_output();
assert!(at.file_exists(file));
// January 1, 2038, 00:00:00
let expected = FileTime::from_unix_time(2_145_916_800, 0);
let (atime, mtime) = get_file_times(&at, file);
assert_eq!(atime, mtime);
assert_eq!(atime, expected);
assert_eq!(mtime, expected);
}
#[test] #[test]
fn test_touch_2_digit_years_69() { fn test_touch_2_digit_years_69() {
// 69 and after are 19xx // 69 and after are 19xx