diff --git a/test/parallel/test-fs-utimes-y2K38.js b/test/parallel/test-fs-utimes-y2K38.js index 860fcb31860b78..5dc4bbcd6c5412 100644 --- a/test/parallel/test-fs-utimes-y2K38.js +++ b/test/parallel/test-fs-utimes-y2K38.js @@ -7,17 +7,27 @@ const fs = require('fs'); tmpdir.refresh(); -// Check for Y2K38 support. For Windows, assume it's there. Windows doesn't have -// `touch`. -if (!common.isWindows) { +// Check for Y2K38 support. For Windows and AIX, assume it's there. Windows +// doesn't have `touch` and `date -r` which are used in the check for support. +// AIX lacks `date -r`. +if (!common.isWindows && !common.isAIX) { const testFilePath = `${tmpdir.path}/y2k38-test`; const testFileDate = '204001020304'; const { spawnSync } = require('child_process'); - const { status } = spawnSync('touch', - ['-t', testFileDate, testFilePath], + const touchResult = spawnSync('touch', + ['-t', testFileDate, testFilePath], + { encoding: 'utf8' }); + if (touchResult.status !== 0) { + common.skip('File system appears to lack Y2K38 support (touch failed)'); + } + + const dateResult = spawnSync('date', + ['-r', testFilePath, '+%Y%m%d%H%M'], { encoding: 'utf8' }); - if (status !== 0) { - common.skip('File system appears to lack Y2K38 support'); + + assert.strictEqual(dateResult.status, 0); + if (dateResult.stdout.trim() !== testFileDate) { + common.skip('File system appears to lack Y2k38 support (date failed)'); } }