2017-01-03 22:16:48 +01:00
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the
|
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
|
// following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-07 02:04:22 +01:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
2017-07-18 00:33:46 +02:00
|
|
|
const fixtures = require('../common/fixtures');
|
2017-12-25 07:38:11 +01:00
|
|
|
const tmpdir = require('../common/tmpdir');
|
2010-03-22 08:25:24 +01:00
|
|
|
|
2016-12-07 02:04:22 +01:00
|
|
|
const fs = require('fs');
|
2017-09-21 20:13:37 +02:00
|
|
|
const path = require('path');
|
2010-03-22 08:25:24 +01:00
|
|
|
|
2017-09-21 20:13:37 +02:00
|
|
|
const fileFixture = fixtures.path('a.js');
|
2017-12-25 07:38:11 +01:00
|
|
|
const fileTemp = path.join(tmpdir.path, 'a.js');
|
2010-03-22 08:25:24 +01:00
|
|
|
|
2017-09-21 20:13:37 +02:00
|
|
|
// Copy fixtures to temp.
|
2017-12-25 07:38:11 +01:00
|
|
|
tmpdir.refresh();
|
2017-09-21 20:13:37 +02:00
|
|
|
fs.copyFileSync(fileFixture, fileTemp);
|
|
|
|
|
2017-12-21 23:38:02 +01:00
|
|
|
fs.open(fileTemp, 'a', 0o777, common.mustCall(function(err, fd) {
|
2016-12-07 02:04:22 +01:00
|
|
|
assert.ifError(err);
|
2010-03-22 08:25:24 +01:00
|
|
|
|
|
|
|
fs.fdatasyncSync(fd);
|
|
|
|
|
|
|
|
fs.fsyncSync(fd);
|
|
|
|
|
2016-12-07 02:04:22 +01:00
|
|
|
fs.fdatasync(fd, common.mustCall(function(err) {
|
|
|
|
assert.ifError(err);
|
|
|
|
fs.fsync(fd, common.mustCall(function(err) {
|
|
|
|
assert.ifError(err);
|
2019-07-30 08:50:21 +02:00
|
|
|
fs.closeSync(fd);
|
2016-12-07 02:04:22 +01:00
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}));
|
2017-11-26 22:35:06 +01:00
|
|
|
|
2018-03-19 14:17:50 +01:00
|
|
|
['', false, null, undefined, {}, []].forEach((input) => {
|
|
|
|
const errObj = {
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
2019-09-23 08:17:25 +02:00
|
|
|
name: 'TypeError'
|
2018-03-19 14:17:50 +01:00
|
|
|
};
|
|
|
|
assert.throws(() => fs.fdatasync(input), errObj);
|
|
|
|
assert.throws(() => fs.fdatasyncSync(input), errObj);
|
|
|
|
assert.throws(() => fs.fsync(input), errObj);
|
|
|
|
assert.throws(() => fs.fsyncSync(input), errObj);
|
2017-11-26 22:35:06 +01:00
|
|
|
});
|