Skip to content

Commit

Permalink
test: loosen test for negative timestamps in test-fs-stat-date
Browse files Browse the repository at this point in the history
PR-URL: #44707
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
  • Loading branch information
LiviaMedeiros authored and danielleadams committed Oct 11, 2022
1 parent db5aeed commit fe91beb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/parallel/test-fs-stat-date.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ function closeEnough(actual, expected, margin) {
if (process.arch === 'ppc64') {
margin += 1000;
}

// Filesystems without support for timestamps before 1970-01-01, such as NFSv3,
// should return 0 for negative numbers. Do not treat it as error.
if (actual === 0 && expected < 0) {
console.log(`ignored 0 while expecting ${expected}`);
return;
}

assert.ok(Math.abs(Number(actual - expected)) < margin,
`expected ${expected} ± ${margin}, got ${actual}`);
}
Expand Down

0 comments on commit fe91beb

Please sign in to comment.