test: avoid running fsync on directory on AIX

On AIX the underlying fsync system call returns EBADF on a file
descriptor for an open directory. So avoid running fsync on it.

PR-URL: https://github.com/nodejs/node/pull/21298
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
John Barboza 2018-06-12 17:44:23 -07:00 committed by Richard Lau
parent 49ea06fda5
commit 8689c78537

View File

@ -35,7 +35,11 @@ function stat_resource(resource) {
if (typeof resource === 'string') {
return fs.statSync(resource);
} else {
const stats = fs.fstatSync(resource);
// ensure mtime has been written to disk
// except for directories on AIX where it cannot be synced
if (common.isAIX && stats.isDirectory())
return stats;
fs.fsyncSync(resource);
return fs.fstatSync(resource);
}