未验证 提交 9e3da4da 编写于 作者: O openharmony_ci 提交者: Gitee

!3292 update fileio xts

Merge pull request !3292 from zhangxingxia/master
...@@ -14,16 +14,7 @@ ...@@ -14,16 +14,7 @@
*/ */
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
import { import { describe,it,expect}from 'deccjsunit/index'
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect
}
from 'deccjsunit/index'
import { import {
FILE_CONTENT, FILE_CONTENT,
prepareFile, prepareFile,
...@@ -32,7 +23,7 @@ import { ...@@ -32,7 +23,7 @@ import {
randomString, randomString,
fileName fileName
} }
from './Common' from './Common'
describe('fileIOTest', function () { describe('fileIOTest', function () {
/** /**
* @tc.number SUB_STORAGE_FileIO_open&closesync_0000 * @tc.number SUB_STORAGE_FileIO_open&closesync_0000
...@@ -44,11 +35,11 @@ describe('fileIOTest', function () { ...@@ -44,11 +35,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o102, 0o666); let fd = fileio.openSync(fpath, 0o102, 0o666);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_close_sync_000 has failed for ' + e); console.info('fileio_test_open_close_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -64,11 +55,11 @@ describe('fileIOTest', function () { ...@@ -64,11 +55,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o202); let fd = fileio.openSync(fpath, 0o202);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_000 has failed for ' + e); console.info('fileio_test_open_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -82,13 +73,13 @@ describe('fileIOTest', function () { ...@@ -82,13 +73,13 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_open_001'); let fpath = await nextFileName('fileio_test_open_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath, 0o100, 0o01); let fd = fileio.openSync(fpath, 0o100, 0o001);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_001 has failed for ' + e); console.info('fileio_test_open_001 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -104,11 +95,11 @@ describe('fileIOTest', function () { ...@@ -104,11 +95,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_002 has failed for ' + e); console.info('fileio_test_open_002 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -130,10 +121,10 @@ describe('fileIOTest', function () { ...@@ -130,10 +121,10 @@ describe('fileIOTest', function () {
length: 1, length: 1,
}); });
expect(null).assertFail(); expect(null).assertFail();
} }catch (err) {
catch (e) { console.info('fileio_test_open_003 has failed for ' + err);
console.log('fileio_test_open_003 has failed for ' + e); expect(err.message == "Bad file descriptor").assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -152,10 +143,10 @@ describe('fileIOTest', function () { ...@@ -152,10 +143,10 @@ describe('fileIOTest', function () {
offset: 1, offset: 1,
}); });
expect(null).assertFail(); expect(null).assertFail();
} }catch (err) {
catch (e) { console.info('fileio_test_open_004 has failed for ' + err);
console.log('fileio_test_open_004 has failed for ' + e); expect(err.message == "Bad file descriptor").assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -180,11 +171,11 @@ describe('fileIOTest', function () { ...@@ -180,11 +171,11 @@ describe('fileIOTest', function () {
offset: 1, offset: 1,
}); });
expect(red !== null).assertTrue(); expect(red !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_005 has failed for ' + e); console.info('fileio_test_open_005 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -201,8 +192,8 @@ describe('fileIOTest', function () { ...@@ -201,8 +192,8 @@ describe('fileIOTest', function () {
fileio.openSync(fpath, 0o200, 0o700); fileio.openSync(fpath, 0o200, 0o700);
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -226,11 +217,11 @@ describe('fileIOTest', function () { ...@@ -226,11 +217,11 @@ describe('fileIOTest', function () {
offset: 1, offset: 1,
}); });
expect(red !== null).assertTrue(); expect(red !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_007 has failed for ' + e); console.info('fileio_test_open_007 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -255,11 +246,11 @@ describe('fileIOTest', function () { ...@@ -255,11 +246,11 @@ describe('fileIOTest', function () {
offset: 1, offset: 1,
}); });
expect(red !== null).assertTrue(); expect(red !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_008 has failed for ' + e); console.info('fileio_test_open_008 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -273,10 +264,9 @@ describe('fileIOTest', function () { ...@@ -273,10 +264,9 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_open_009'); let fpath = await nextFileName('fileio_test_open_009');
try { try {
fileio.openSync(fpath, 0o302); fileio.openSync(fpath, 0o302);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_open_009 has failed for ' + err);
catch (e) { expect(err.message == "called with O_CREAT/O_TMPFILE but no mode").assertTrue();
console.log('fileio_test_open_009 has failed for ' + e);
} }
}); });
...@@ -301,11 +291,11 @@ describe('fileIOTest', function () { ...@@ -301,11 +291,11 @@ describe('fileIOTest', function () {
offset: 1, offset: 1,
}); });
expect(red !== null).assertTrue(); expect(red !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_010 has failed for ' + e); console.info('fileio_test_open_010 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -325,11 +315,11 @@ describe('fileIOTest', function () { ...@@ -325,11 +315,11 @@ describe('fileIOTest', function () {
offset: 1, offset: 1,
}); });
expect(red !== null).assertTrue(); expect(red !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_011 has failed for ' + e); console.info('fileio_test_open_011 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -350,9 +340,10 @@ describe('fileIOTest', function () { ...@@ -350,9 +340,10 @@ describe('fileIOTest', function () {
}); });
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_open_012 has failed for ' + e); console.info('fileio_test_open_012 has failed for ' + err);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); expect(err.message == "Bad file descriptor").assertTrue();
fileio.unlinkSync(fpath);
} }
}); });
...@@ -377,11 +368,11 @@ describe('fileIOTest', function () { ...@@ -377,11 +368,11 @@ describe('fileIOTest', function () {
offset: 1, offset: 1,
}); });
expect(red !== null).assertTrue(); expect(red !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_013 has failed for ' + e); console.info('fileio_test_open_013 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -399,13 +390,13 @@ describe('fileIOTest', function () { ...@@ -399,13 +390,13 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
let fd2 = fileio.openSync(fpath, 0o4002); let fd2 = fileio.openSync(fpath, 0o4002);
expect(fd2 !== null).assertTrue(); expect(fd2 !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.closeSync(fd2) !== null).assertTrue(); fileio.closeSync(fd2);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
done(); done();
} }
catch (e) { catch (err) {
console.log('fileio_test_open_014 has failed for ' + e); console.info('fileio_test_open_014 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -421,11 +412,11 @@ describe('fileIOTest', function () { ...@@ -421,11 +412,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o20002); let fd = fileio.openSync(fpath, 0o20002);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_015 has failed for ' + e); console.info('fileio_test_open_015 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -441,11 +432,11 @@ describe('fileIOTest', function () { ...@@ -441,11 +432,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o10002); let fd = fileio.openSync(fpath, 0o10002);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_016 has failed for ' + e); console.info('fileio_test_open_016 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -461,11 +452,11 @@ describe('fileIOTest', function () { ...@@ -461,11 +452,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o4010002); let fd = fileio.openSync(fpath, 0o4010002);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_017 has failed for ' + e); console.info('fileio_test_open_017 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -481,11 +472,11 @@ describe('fileIOTest', function () { ...@@ -481,11 +472,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o100002); let fd = fileio.openSync(fpath, 0o100002);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_018 has failed for ' + e); console.info('fileio_test_open_018 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -501,10 +492,10 @@ describe('fileIOTest', function () { ...@@ -501,10 +492,10 @@ describe('fileIOTest', function () {
try { try {
fileio.openSync(fpath, 0o40002, 0o700); fileio.openSync(fpath, 0o40002, 0o700);
expect(null).assertFail(); expect(null).assertFail();
} }catch (err) {
catch (e) { console.info('fileio_test_open_019 has failed for ' + err);
console.log('fileio_test_open_019 has failed for ' + e); expect(err.message == "Not a directory").assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -519,11 +510,11 @@ describe('fileIOTest', function () { ...@@ -519,11 +510,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o2000002); let fd = fileio.openSync(fpath, 0o2000002);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) == null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_021 has failed for ' + e); console.info('fileio_test_open_021 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -539,11 +530,11 @@ describe('fileIOTest', function () { ...@@ -539,11 +530,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o200002); let fd = fileio.openSync(fpath, 0o200002);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_022 has failed for ' + e); console.info('fileio_test_open_022 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -559,11 +550,11 @@ describe('fileIOTest', function () { ...@@ -559,11 +550,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o400002); let fd = fileio.openSync(fpath, 0o400002);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_023 has failed for ' + e); console.info('fileio_test_open_023 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -579,11 +570,11 @@ describe('fileIOTest', function () { ...@@ -579,11 +570,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o1000002, 0o700); let fd = fileio.openSync(fpath, 0o1000002, 0o700);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_024 has failed for ' + e); console.info('fileio_test_open_024 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -599,11 +590,11 @@ describe('fileIOTest', function () { ...@@ -599,11 +590,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o10000002); let fd = fileio.openSync(fpath, 0o10000002);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_025 has failed for ' + e); console.info('fileio_test_open_025 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -619,11 +610,11 @@ describe('fileIOTest', function () { ...@@ -619,11 +610,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o002, 0o700); let fd = fileio.openSync(fpath, 0o002, 0o700);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_026 has failed for ' + e); console.info('fileio_test_open_026 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -650,8 +641,8 @@ describe('fileIOTest', function () { ...@@ -650,8 +641,8 @@ describe('fileIOTest', function () {
}); });
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -677,8 +668,8 @@ describe('fileIOTest', function () { ...@@ -677,8 +668,8 @@ describe('fileIOTest', function () {
}); });
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -693,11 +684,11 @@ describe('fileIOTest', function () { ...@@ -693,11 +684,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o002, 0o100); let fd = fileio.openSync(fpath, 0o002, 0o100);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_029 has failed for ' + e); console.info('fileio_test_open_029 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -723,11 +714,11 @@ describe('fileIOTest', function () { ...@@ -723,11 +714,11 @@ describe('fileIOTest', function () {
offset: 1, offset: 1,
}); });
expect(red !== null).assertTrue(); expect(red !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_030 has failed for ' + e); console.info('fileio_test_open_030 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -754,8 +745,8 @@ describe('fileIOTest', function () { ...@@ -754,8 +745,8 @@ describe('fileIOTest', function () {
}); });
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -781,8 +772,8 @@ describe('fileIOTest', function () { ...@@ -781,8 +772,8 @@ describe('fileIOTest', function () {
}); });
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -797,11 +788,11 @@ describe('fileIOTest', function () { ...@@ -797,11 +788,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o002, 0o010); let fd = fileio.openSync(fpath, 0o002, 0o010);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_033 has failed for ' + e); console.info('fileio_test_open_033 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -827,11 +818,11 @@ describe('fileIOTest', function () { ...@@ -827,11 +818,11 @@ describe('fileIOTest', function () {
length: 1, length: 1,
}); });
expect(wri !== null).assertTrue(); expect(wri !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_034 has failed for ' + e); console.info('fileio_test_open_034 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -858,8 +849,8 @@ describe('fileIOTest', function () { ...@@ -858,8 +849,8 @@ describe('fileIOTest', function () {
}); });
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -885,8 +876,8 @@ describe('fileIOTest', function () { ...@@ -885,8 +876,8 @@ describe('fileIOTest', function () {
}); });
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -900,11 +891,11 @@ describe('fileIOTest', function () { ...@@ -900,11 +891,11 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath, 0o002, 0o001); let fd = fileio.openSync(fpath, 0o002, 0o001);
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_037 has failed for ' + e); console.info('fileio_test_open_037 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -921,8 +912,8 @@ describe('fileIOTest', function () { ...@@ -921,8 +912,8 @@ describe('fileIOTest', function () {
let fd = fileio.openSync(fpath, 0o102, 0o700); let fd = fileio.openSync(fpath, 0o102, 0o700);
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_open_038 has failed for ' + e); console.info('fileio_test_open_038 has failed for ' + err);
} }
}); });
...@@ -937,11 +928,11 @@ describe('fileIOTest', function () { ...@@ -937,11 +928,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o200); let fd = fileio.openSync(fpath, 0o200);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_sync_001 has failed for ' + e); console.info('fileio_test_open_sync_001 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -957,11 +948,11 @@ describe('fileIOTest', function () { ...@@ -957,11 +948,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o201); let fd = fileio.openSync(fpath, 0o201);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_sync_002 has failed for ' + e); console.info('fileio_test_open_sync_002 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -977,11 +968,11 @@ describe('fileIOTest', function () { ...@@ -977,11 +968,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o202); let fd = fileio.openSync(fpath, 0o202);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_sync_003 has failed for ' + e); console.info('fileio_test_open_sync_003 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -996,11 +987,11 @@ describe('fileIOTest', function () { ...@@ -996,11 +987,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o102, 0o777); let fd = fileio.openSync(fpath, 0o102, 0o777);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_sync_004 has failed for ' + e); console.info('fileio_test_open_sync_004 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1013,14 +1004,14 @@ describe('fileIOTest', function () { ...@@ -1013,14 +1004,14 @@ describe('fileIOTest', function () {
it('fileio_test_open_sync_005', 0, async function () { it('fileio_test_open_sync_005', 0, async function () {
let dpath = await nextFileName('fileio_test_open_sync_005') + 'd' let dpath = await nextFileName('fileio_test_open_sync_005') + 'd'
try { try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue(); fileio.mkdirSync(dpath);
let fd = fileio.openSync(dpath); let fd = fileio.openSync(dpath);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_open_sync_005 has failed for ' + e); console.info('fileio_test_open_sync_005 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1033,12 +1024,12 @@ describe('fileIOTest', function () { ...@@ -1033,12 +1024,12 @@ describe('fileIOTest', function () {
it('fileio_test_open_sync_006', 0, async function () { it('fileio_test_open_sync_006', 0, async function () {
let dpath = await nextFileName('fileio_test_open_sync_006') + 'd' let dpath = await nextFileName('fileio_test_open_sync_006') + 'd'
try { try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue(); fileio.mkdirSync(dpath);
fileio.openSync(dpath, 0o1); fileio.openSync(dpath, 0o1);
expect(null).assertFail(); //expect(null).assertFail();
} }catch (err) {
catch (e) { console.info('fileio_test_open_sync_006 has failed for ' + err);
console.log('fileio_test_open_sync_006 has failed for ' + e); expect(err.message == "Is a directory").assertTrue();
fileio.rmdirSync(dpath); fileio.rmdirSync(dpath);
} }
}); });
...@@ -1063,8 +1054,8 @@ describe('fileIOTest', function () { ...@@ -1063,8 +1054,8 @@ describe('fileIOTest', function () {
} }
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_open_sync_007 has failed for ' + e); console.info('fileio_test_open_sync_007 has failed for ' + err);
} }
}); });
...@@ -1077,10 +1068,9 @@ describe('fileIOTest', function () { ...@@ -1077,10 +1068,9 @@ describe('fileIOTest', function () {
let fpath = await nextFileName(randomString(256)); let fpath = await nextFileName(randomString(256));
try { try {
fileio.openSync(fpath, 0o102, 0o777); fileio.openSync(fpath, 0o102, 0o777);
expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_open_sync_008 has failed for ' + e); console.info('fileio_test_open_sync_008 has failed for ' + err);
} }
}); });
...@@ -1104,8 +1094,8 @@ describe('fileIOTest', function () { ...@@ -1104,8 +1094,8 @@ describe('fileIOTest', function () {
} }
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_open_sync_009 has failed for ' + e); console.info('fileio_test_open_sync_009 has failed for ' + err);
} }
}); });
...@@ -1118,10 +1108,9 @@ describe('fileIOTest', function () { ...@@ -1118,10 +1108,9 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('?*:<>/|'); let fpath = await nextFileName('?*:<>/|');
try { try {
fileio.openSync(fpath, 0o102, 0o777); fileio.openSync(fpath, 0o102, 0o777);
expect(null).assertFail(); } catch (err) {
} console.info('fileio_test_open_sync_010 has failed for ' + err);
catch (e) { expect(err.message == "No such file or directory").assertTrue();
console.log('fileio_test_open_sync_010 has failed for ' + e);
} }
}); });
...@@ -1134,11 +1123,10 @@ describe('fileIOTest', function () { ...@@ -1134,11 +1123,10 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_chmod_sync_000'); let fpath = await nextFileName('fileio_test_chmod_sync_000');
try { try {
fileio.closeSync(fpath); fileio.closeSync(fpath);
expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_close_sync_000 has failed for ' + e); console.info('fileio_test_close_sync_000 has failed for ' + err);
expect(err.message == "Invalid fd").assertTrue();
} }
}); });
...@@ -1150,10 +1138,10 @@ describe('fileIOTest', function () { ...@@ -1150,10 +1138,10 @@ describe('fileIOTest', function () {
it('fileio_test_close_sync_001', 0, async function () { it('fileio_test_close_sync_001', 0, async function () {
try { try {
fileio.closeSync(-1); fileio.closeSync(-1);
expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_close_sync_001 has failed for ' + e); console.info('fileio_test_close_sync_001 has failed for ' + err);
expect(err.message == "Bad file descriptor").assertTrue();
} }
}); });
...@@ -1166,11 +1154,11 @@ describe('fileIOTest', function () { ...@@ -1166,11 +1154,11 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_access_sync_000'); let fpath = await nextFileName('fileio_test_access_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
expect(fileio.accessSync(fpath) !== null).assertTrue(); fileio.accessSync(fpath);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_access_sync_000 has failed for ' + e); console.info('fileio_test_access_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1183,10 +1171,9 @@ describe('fileIOTest', function () { ...@@ -1183,10 +1171,9 @@ describe('fileIOTest', function () {
it('fileio_test_access_sync_001', 0, async function () { it('fileio_test_access_sync_001', 0, async function () {
try { try {
fileio.accessSync(1); fileio.accessSync(1);
expect(null).assertFail(); } catch (err) {
} console.info('fileio_test_access_sync_001 has failed for ' + err);
catch (e) { expect(err.message == "Invalid path").assertTrue();
console.log('fileio_test_access_sync_001 has failed for ' + e);
} }
}); });
...@@ -1199,10 +1186,9 @@ describe('fileIOTest', function () { ...@@ -1199,10 +1186,9 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileIOTest'); let fpath = await nextFileName('fileIOTest');
try { try {
fileio.accessSync(fpath); fileio.accessSync(fpath);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_access_sync_002 has failed for ' + err);
catch (e) { expect(err.message == "No such file or directory").assertTrue();
console.log('fileio_test_access_sync_002 has failed for ' + e);
} }
}); });
...@@ -1215,13 +1201,12 @@ describe('fileIOTest', function () { ...@@ -1215,13 +1201,12 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_access_sync_004'); let fpath = await nextFileName('fileio_test_access_sync_004');
expect(prepareEmptyFile(fpath)).assertTrue(); expect(prepareEmptyFile(fpath)).assertTrue();
try { try {
let fd = fileio.accessSync(fpath); fileio.accessSync(fpath);
console.log(fd); fileio.accessSync(fpath, 1);
expect(fileio.accessSync(fpath, 1) !== null).assertTrue(); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
} }
catch (e) { catch (err) {
console.log('fileio_test_access_sync_004 has failed for ' + e); console.info('fileio_test_access_sync_004 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1235,13 +1220,12 @@ describe('fileIOTest', function () { ...@@ -1235,13 +1220,12 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_access_sync_004'); let fpath = await nextFileName('fileio_test_access_sync_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.accessSync(fpath); fileio.accessSync(fpath);
expect(fd !== null).assertTrue(); fileio.accessSync(fpath, 2);
expect(fileio.accessSync(fpath, 2) !== null).assertTrue(); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
} }
catch (e) { catch (err) {
console.log('fileio_test_access_sync_004 has failed for ' + e); console.info('fileio_test_access_sync_004 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1254,13 +1238,12 @@ describe('fileIOTest', function () { ...@@ -1254,13 +1238,12 @@ describe('fileIOTest', function () {
it('fileio_test_access_sync_005', 0, async function () { it('fileio_test_access_sync_005', 0, async function () {
let dpath = await nextFileName('fileio_test_access_sync_005') + 'd' let dpath = await nextFileName('fileio_test_access_sync_005') + 'd'
try { try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue(); fileio.mkdirSync(dpath);
let fd = fileio.accessSync(dpath); fileio.accessSync(dpath);
expect(fd == undefined).assertTrue(); fileio.rmdirSync(dpath);
expect(fileio.rmdirSync(dpath) !== null).assertTrue();
} }
catch (e) { catch (err) {
console.log('fileio_test_access_sync_005 has failed for ' + e); console.info('fileio_test_access_sync_005 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1274,10 +1257,10 @@ describe('fileIOTest', function () { ...@@ -1274,10 +1257,10 @@ describe('fileIOTest', function () {
let dpath = await nextFileName('fileio_test_access_sync_006') + 'd' let dpath = await nextFileName('fileio_test_access_sync_006') + 'd'
try { try {
fileio.accessSync(dpath); fileio.accessSync(dpath);
expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_access_sync_006 has failed for ' + e); console.info('fileio_test_access_sync_006 has failed for ' + err);
expect(err.message == "No such file or directory").assertTrue();
} }
}); });
...@@ -1290,13 +1273,12 @@ describe('fileIOTest', function () { ...@@ -1290,13 +1273,12 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_access_sync_007'); let fpath = await nextFileName('fileio_test_access_sync_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.accessSync(fpath); fileio.accessSync(fpath);
expect(fd !== null).assertTrue(); fileio.accessSync(fpath, 4);
expect(fileio.accessSync(fpath, 4) !== null).assertTrue(); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
} }
catch (e) { catch (err) {
console.log('fileio_test_access_sync_007 has failed for ' + e); console.info('fileio_test_access_sync_007 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1310,10 +1292,10 @@ describe('fileIOTest', function () { ...@@ -1310,10 +1292,10 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_unlink_sync_000'); let fpath = await nextFileName('fileio_test_unlink_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
expect(fileio.unlinkSync(fpath) !== null); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_unlink_sync_000 has failed for ' + e); console.info('fileio_test_unlink_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1328,8 +1310,9 @@ describe('fileIOTest', function () { ...@@ -1328,8 +1310,9 @@ describe('fileIOTest', function () {
fileio.unlinkSync(1); fileio.unlinkSync(1);
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_unlink_sync_002 has failed for ' + e); console.info('fileio_test_unlink_sync_001 has failed for ' + err);
expect(err.message == "Invalid path").assertTrue();
} }
}); });
...@@ -1342,10 +1325,9 @@ describe('fileIOTest', function () { ...@@ -1342,10 +1325,9 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileIOTest'); let fpath = await nextFileName('fileIOTest');
try { try {
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
expect(null).assertFail(); } catch (err) {
} console.info('fileio_test_unlink_sync_002 has failed for ' + err);
catch (e) { expect(err.message == "No such file or directory").assertTrue();
console.log('fileio_test_unlink_sync_002 has failed for ' + e);
} }
}); });
...@@ -1360,11 +1342,11 @@ describe('fileIOTest', function () { ...@@ -1360,11 +1342,11 @@ describe('fileIOTest', function () {
let fd = fileio.openSync(fpath, 0o102, 0o666); let fd = fileio.openSync(fpath, 0o102, 0o666);
let res = fileio.writeSync(fd, FILE_CONTENT); let res = fileio.writeSync(fd, FILE_CONTENT);
expect(typeof(res) == 'number').assertTrue(); expect(typeof(res) == 'number').assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_write_sync_000 has failed for ' + e); console.info('fileio_test_write_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1382,11 +1364,11 @@ describe('fileIOTest', function () { ...@@ -1382,11 +1364,11 @@ describe('fileIOTest', function () {
encoding: 'utf-8', encoding: 'utf-8',
}); });
expect(typeof(res) == 'number').assertTrue(); expect(typeof(res) == 'number').assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_write_sync_001 has failed for ' + e); console.info('fileio_test_write_sync_001 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1404,11 +1386,11 @@ describe('fileIOTest', function () { ...@@ -1404,11 +1386,11 @@ describe('fileIOTest', function () {
expect(fileio.writeSync(fd, text, { expect(fileio.writeSync(fd, text, {
offset: 1, offset: 1,
}) == text.length - 1).assertTrue(); }) == text.length - 1).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_write_sync_002 has failed for ' + e); console.info('fileio_test_write_sync_002 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1425,11 +1407,11 @@ describe('fileIOTest', function () { ...@@ -1425,11 +1407,11 @@ describe('fileIOTest', function () {
expect(fileio.writeSync(fd, FILE_CONTENT, { expect(fileio.writeSync(fd, FILE_CONTENT, {
length: FILE_CONTENT.length - 1, length: FILE_CONTENT.length - 1,
}) == (FILE_CONTENT.length - 1)).assertTrue(); }) == (FILE_CONTENT.length - 1)).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_write_sync_003 has failed for ' + e); console.info('fileio_test_write_sync_003 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1448,11 +1430,11 @@ describe('fileIOTest', function () { ...@@ -1448,11 +1430,11 @@ describe('fileIOTest', function () {
length: 1, length: 1,
}); });
expect(typeof(res) == 'number').assertTrue(); expect(typeof(res) == 'number').assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_write_sync_004 has failed for ' + e); console.info('fileio_test_write_sync_004 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1474,9 +1456,9 @@ describe('fileIOTest', function () { ...@@ -1474,9 +1456,9 @@ describe('fileIOTest', function () {
}) == 1).assertTrue(); }) == 1).assertTrue();
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -1497,9 +1479,9 @@ describe('fileIOTest', function () { ...@@ -1497,9 +1479,9 @@ describe('fileIOTest', function () {
}) == 1); }) == 1);
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -1511,10 +1493,9 @@ describe('fileIOTest', function () { ...@@ -1511,10 +1493,9 @@ describe('fileIOTest', function () {
it('fileio_test_write_sync_007', 0, async function () { it('fileio_test_write_sync_007', 0, async function () {
try { try {
fileio.writeSync(1, 1); fileio.writeSync(1, 1);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_write_sync_007 has failed for ' + err);
catch (e) { expect(err.message == "Illegal write buffer or encoding").assertTrue();
console.log('fileio_test_write_sync_007 has failed for ' + e);
} }
}); });
...@@ -1525,11 +1506,11 @@ describe('fileIOTest', function () { ...@@ -1525,11 +1506,11 @@ describe('fileIOTest', function () {
*/ */
it('fileio_test_write_sync_008', 0, async function () { it('fileio_test_write_sync_008', 0, async function () {
try { try {
console.log(fileio.writeSync(-1, FILE_CONTENT)); fileio.writeSync(-1, FILE_CONTENT);
expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_write_sync_008 has failed for ' + e); console.info('fileio_test_write_sync_008 has failed for ' + err);
expect(err.message == "Bad file descriptor").assertTrue();
} }
}); });
...@@ -1549,11 +1530,11 @@ describe('fileIOTest', function () { ...@@ -1549,11 +1530,11 @@ describe('fileIOTest', function () {
length: 1, length: 1,
}); });
expect(typeof(res) == 'number').assertTrue(); expect(typeof(res) == 'number').assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_write_sync_009 has failed for ' + e); console.info('fileio_test_write_sync_009 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1570,12 +1551,11 @@ describe('fileIOTest', function () { ...@@ -1570,12 +1551,11 @@ describe('fileIOTest', function () {
fileio.writeSync(fd, FILE_CONTENT, { fileio.writeSync(fd, FILE_CONTENT, {
encoding: 'gb2312', encoding: 'gb2312',
}); });
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_write_sync_010 has failed for ' + err);
catch (e) { expect(err.message == "Illegal write buffer or encoding").assertTrue();
console.log('fileio_test_write_sync_010 has failed for ' + e); fileio.closeSync(fd);
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
} }
}); });
...@@ -1592,14 +1572,14 @@ describe('fileIOTest', function () { ...@@ -1592,14 +1572,14 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o2); let fd = fileio.openSync(fpath, 0o2);
let len = fileio.readSync(fd, new ArrayBuffer(bufLen), { let len = fileio.readSync(fd, new ArrayBuffer(bufLen), {
offset: 1, offset: 1,
}); });
expect(len == bufLen - 1).assertTrue(); expect(len == bufLen - 1).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_read_sync_001 has failed for ' + e); console.info('fileio_test_read_sync_001 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1618,11 +1598,11 @@ describe('fileIOTest', function () { ...@@ -1618,11 +1598,11 @@ describe('fileIOTest', function () {
length: 1, length: 1,
}); });
expect(len == 1).assertTrue(); expect(len == 1).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_read_sync_002 has failed for ' + e); console.info('fileio_test_read_sync_002 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1642,12 +1622,11 @@ describe('fileIOTest', function () { ...@@ -1642,12 +1622,11 @@ describe('fileIOTest', function () {
fileio.readSync(fd, new ArrayBuffer(4096), { fileio.readSync(fd, new ArrayBuffer(4096), {
offset: invalidOffset, offset: invalidOffset,
}); });
expect(null).assertFail(); }catch (err) {
} fileio.closeSync(fd);
catch (e) { fileio.unlinkSync(fpath);
expect(fileio.closeSync(fd) !== null).assertTrue(); console.info('fileio_test_read_sync_003 has failed for ' + err);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); expect(err.message == "Invalid option.offset, buffer limit exceeded").assertTrue();
console.log('fileio_test_read_sync_003 has failed for ' + e);
} }
}); });
...@@ -1667,12 +1646,11 @@ describe('fileIOTest', function () { ...@@ -1667,12 +1646,11 @@ describe('fileIOTest', function () {
fileio.readSync(fd, new ArrayBuffer(4096), { fileio.readSync(fd, new ArrayBuffer(4096), {
length: invalidLength, length: invalidLength,
}); });
expect(null).assertFail(); }catch (err) {
} fileio.closeSync(fd);
catch (e) { fileio.unlinkSync(fpath);
expect(fileio.closeSync(fd) !== null).assertTrue(); console.info('fileio_test_read_sync_004 has failed for ' + err);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); expect(err.message == "Invalid option.length, buffer limit exceeded").assertTrue();
console.log('fileio_test_read_sync_004 has failed for ' + e);
} }
}); });
...@@ -1684,10 +1662,10 @@ describe('fileIOTest', function () { ...@@ -1684,10 +1662,10 @@ describe('fileIOTest', function () {
it('fileio_test_read_sync_005', 0, async function () { it('fileio_test_read_sync_005', 0, async function () {
try { try {
fileio.readSync(-1, new ArrayBuffer(4096)); fileio.readSync(-1, new ArrayBuffer(4096));
expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_read_sync_005 has failed for ' + e); console.info('fileio_test_read_sync_005 has failed for ' + err);
expect(err.message == "Bad file descriptor").assertTrue();
} }
}); });
...@@ -1705,11 +1683,11 @@ describe('fileIOTest', function () { ...@@ -1705,11 +1683,11 @@ describe('fileIOTest', function () {
position: 1, position: 1,
}); });
expect(len == FILE_CONTENT.length - 1); expect(len == FILE_CONTENT.length - 1);
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_read_sync_006 has failed for ' + e); console.info('fileio_test_read_sync_006 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1728,11 +1706,11 @@ describe('fileIOTest', function () { ...@@ -1728,11 +1706,11 @@ describe('fileIOTest', function () {
let len = fileio.readSync(fd, new ArrayBuffer(4096), { let len = fileio.readSync(fd, new ArrayBuffer(4096), {
position: invalidPos, position: invalidPos,
}); });
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_read_sync_007 has failed for ' + e); console.info('fileio_test_read_sync_007 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1753,11 +1731,11 @@ describe('fileIOTest', function () { ...@@ -1753,11 +1731,11 @@ describe('fileIOTest', function () {
length: 1, length: 1,
}); });
expect(len == 1).assertTrue(); expect(len == 1).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_read_sync_008 has failed for ' + e); console.info('fileio_test_read_sync_008 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1777,11 +1755,11 @@ describe('fileIOTest', function () { ...@@ -1777,11 +1755,11 @@ describe('fileIOTest', function () {
length: 1, length: 1,
}); });
expect(len == 1).assertTrue(); expect(len == 1).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_read_sync_009 has failed for ' + e); console.info('fileio_test_read_sync_009 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1798,16 +1776,14 @@ describe('fileIOTest', function () { ...@@ -1798,16 +1776,14 @@ describe('fileIOTest', function () {
try { try {
fd = fileio.openSync(fpath, 0o2); fd = fileio.openSync(fpath, 0o2);
fileio.readSync(fd, new ArrayBuffer(4096), { fileio.readSync(fd, new ArrayBuffer(4096), {
position: 1, offset: -1,
offset: 1,
length: 1, length: 1,
}); });
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_read_sync_010 has failed for ' + err);
catch (e) { expect(err.message == "Invalid option.offset, positive integer is desired").assertTrue();
console.log('fileio_test_read_sync_010 has failed for ' + e); fileio.closeSync(fd);
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
} }
}); });
...@@ -1822,10 +1798,10 @@ describe('fileIOTest', function () { ...@@ -1822,10 +1798,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o660) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o660) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_000 has failed for ' + e); console.info('fileio_test_chmod_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1841,10 +1817,10 @@ describe('fileIOTest', function () { ...@@ -1841,10 +1817,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o460) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o460) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o460).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o460).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_001 has failed for ' + e); console.info('fileio_test_chmod_sync_001 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1860,10 +1836,10 @@ describe('fileIOTest', function () { ...@@ -1860,10 +1836,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o260) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o260) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o260).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o260).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_002 has failed for ' + e); console.info('fileio_test_chmod_sync_002 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1877,10 +1853,9 @@ describe('fileIOTest', function () { ...@@ -1877,10 +1853,9 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_chmod_sync_003'); let fpath = await nextFileName('fileio_test_chmod_sync_003');
try { try {
fileio.chmodSync(fpath, 0o260); fileio.chmodSync(fpath, 0o260);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_chmod_sync_003 has failed for ' + err);
catch (e) { expect(err.message == "No such file or directory").assertTrue();
console.log('fileio_test_chmod_sync_003 has failed for ' + e);
} }
}); });
...@@ -1892,13 +1867,13 @@ describe('fileIOTest', function () { ...@@ -1892,13 +1867,13 @@ describe('fileIOTest', function () {
it('fileio_test_chmod_sync_004', 0, async function () { it('fileio_test_chmod_sync_004', 0, async function () {
let dpath = await nextFileName('fileio_test_chmod_sync_004'); let dpath = await nextFileName('fileio_test_chmod_sync_004');
try { try {
expect(fileio.mkdirSync(dpath, 0o777) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o777);
expect(fileio.chmodSync(dpath, 0o660) !== null).assertTrue(); expect(fileio.chmodSync(dpath, 0o660) !== null).assertTrue();
expect((fileio.statSync(dpath).mode & 0o777) == 0o660).assertTrue(); expect((fileio.statSync(dpath).mode & 0o777) == 0o660).assertTrue();
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_000 has failed for ' + e); console.info('fileio_test_chmod_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1912,10 +1887,9 @@ describe('fileIOTest', function () { ...@@ -1912,10 +1887,9 @@ describe('fileIOTest', function () {
let dpath; let dpath;
try { try {
fileio.chmodSync(dpath, 0o660); fileio.chmodSync(dpath, 0o660);
expect(null).assertFail(); } catch (err) {
} console.info('fileio_test_chmod_sync_005 has failed for ' + err);
catch (e) { expect(err.message == "Invalid path").assertTrue();
console.log('fileio_test_chmod_sync_005 has failed for ' + e);
} }
}); });
...@@ -1930,10 +1904,10 @@ describe('fileIOTest', function () { ...@@ -1930,10 +1904,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o700) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o700) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o700).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o700).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_006 has failed for ' + e); console.info('fileio_test_chmod_sync_006 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1949,10 +1923,10 @@ describe('fileIOTest', function () { ...@@ -1949,10 +1923,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o400) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o400) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o400).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o400).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_002 has failed for ' + e); console.info('fileio_test_chmod_sync_002 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1968,10 +1942,10 @@ describe('fileIOTest', function () { ...@@ -1968,10 +1942,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o200) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o200) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o200).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o200).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_008 has failed for ' + e); console.info('fileio_test_chmod_sync_008 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -1987,10 +1961,10 @@ describe('fileIOTest', function () { ...@@ -1987,10 +1961,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o100) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o100) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o100).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o100).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_009 has failed for ' + e); console.info('fileio_test_chmod_sync_009 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2006,10 +1980,10 @@ describe('fileIOTest', function () { ...@@ -2006,10 +1980,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o070) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o070) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o070).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o070).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_010 has failed for ' + e); console.info('fileio_test_chmod_sync_010 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2025,10 +1999,10 @@ describe('fileIOTest', function () { ...@@ -2025,10 +1999,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o040) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o040) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o040).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o040).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_011 has failed for ' + e); console.info('fileio_test_chmod_sync_011 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2044,10 +2018,10 @@ describe('fileIOTest', function () { ...@@ -2044,10 +2018,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o020) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o020) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o020).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o020).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_012 has failed for ' + e); console.info('fileio_test_chmod_sync_012 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2063,10 +2037,10 @@ describe('fileIOTest', function () { ...@@ -2063,10 +2037,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o010) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o010) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o010).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o010).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_013 has failed for ' + e); console.info('fileio_test_chmod_sync_013 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2082,10 +2056,10 @@ describe('fileIOTest', function () { ...@@ -2082,10 +2056,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o007) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o007) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o007).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o007).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_014 has failed for ' + e); console.info('fileio_test_chmod_sync_014 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2101,10 +2075,10 @@ describe('fileIOTest', function () { ...@@ -2101,10 +2075,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o004) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o004) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o004).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o004).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_015 has failed for ' + e); console.info('fileio_test_chmod_sync_015 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2120,10 +2094,10 @@ describe('fileIOTest', function () { ...@@ -2120,10 +2094,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o002) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o002) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o002).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o002).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_016 has failed for ' + e); console.info('fileio_test_chmod_sync_016 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2139,10 +2113,10 @@ describe('fileIOTest', function () { ...@@ -2139,10 +2113,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.chmodSync(fpath, 0o001) !== null).assertTrue(); expect(fileio.chmodSync(fpath, 0o001) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o001).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o001).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chmod_sync_017 has failed for ' + e); console.info('fileio_test_chmod_sync_017 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2157,12 +2131,12 @@ describe('fileIOTest', function () { ...@@ -2157,12 +2131,12 @@ describe('fileIOTest', function () {
let fpathTarget = fpath + 'tgt' let fpathTarget = fpath + 'tgt'
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
expect(fileio.copyFileSync(fpath, fpathTarget) !== null).assertTrue(); fileio.copyFileSync(fpath, fpathTarget);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue(); fileio.unlinkSync(fpathTarget);
} }
catch (e) { catch (err) {
console.log('fileio_test_copy_file_sync_000 has failed for ' + e); console.info('fileio_test_copy_file_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2177,10 +2151,9 @@ describe('fileIOTest', function () { ...@@ -2177,10 +2151,9 @@ describe('fileIOTest', function () {
let fpathTarget = fpath + 'tgt' let fpathTarget = fpath + 'tgt'
try { try {
fileio.copyFileSync(fpath, fpathTarget); fileio.copyFileSync(fpath, fpathTarget);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_copy_file_sync_001 has failed for ' + err);
catch (e) { expect(err.message == "No such file or directory").assertTrue();
console.log('fileio_test_copy_file_sync_001 has failed for ' + e);
} }
}); });
...@@ -2193,10 +2166,10 @@ describe('fileIOTest', function () { ...@@ -2193,10 +2166,10 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_copy_file_sync_002'); let fpath = await nextFileName('fileio_test_copy_file_sync_002');
try { try {
fileio.copyFileSync(fpath, 0); fileio.copyFileSync(fpath, 0);
expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_copy_file_sync_002 has failed for ' + e); console.info('fileio_test_copy_file_sync_002 has failed for ' + err);
expect(err.message == "No such file or directory").assertTrue();
} }
}); });
...@@ -2210,12 +2183,12 @@ describe('fileIOTest', function () { ...@@ -2210,12 +2183,12 @@ describe('fileIOTest', function () {
let fpathTarget = fpath + 'f1' let fpathTarget = fpath + 'f1'
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
expect(fileio.copyFileSync(fpath, fpathTarget) !== null).assertTrue(); fileio.copyFileSync(fpath, fpathTarget);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue(); fileio.unlinkSync(fpathTarget);
} }
catch (e) { catch (err) {
console.log('fileio_test_copy_file_sync_003 has failed for ' + e); console.info('fileio_test_copy_file_sync_003 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2230,12 +2203,12 @@ describe('fileIOTest', function () { ...@@ -2230,12 +2203,12 @@ describe('fileIOTest', function () {
let fpathTarget = await fileName('fileio_test_copy_file_sync_004'); let fpathTarget = await fileName('fileio_test_copy_file_sync_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
expect(fileio.copyFileSync(fpath, fpathTarget) !== null).assertTrue(); fileio.copyFileSync(fpath, fpathTarget);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue(); fileio.unlinkSync(fpathTarget);
} }
catch (e) { catch (err) {
console.log('fileio_test_copy_file_sync_004 has failed for ' + e); console.info('fileio_test_copy_file_sync_004 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2250,11 +2223,11 @@ describe('fileIOTest', function () { ...@@ -2250,11 +2223,11 @@ describe('fileIOTest', function () {
let fpathTarget = fpath let fpathTarget = fpath
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
expect(fileio.copyFileSync(fpath, fpathTarget) !== null).assertTrue(); fileio.copyFileSync(fpath, fpathTarget);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_copy_file_sync_005 has failed for ' + e); console.info('fileio_test_copy_file_sync_005 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2262,17 +2235,15 @@ describe('fileIOTest', function () { ...@@ -2262,17 +2235,15 @@ describe('fileIOTest', function () {
/** /**
* @tc.number SUB_STORAGE_FileIO_copyFileSync_0600 * @tc.number SUB_STORAGE_FileIO_copyFileSync_0600
* @tc.name fileio_test_copy_file_sync_006 * @tc.name fileio_test_copy_file_sync_006
* @tc.desc Function of API, copy. fpathTarget is invalid. * @tc.desc Function of API, copy.When missing parameters.
*/ */
it('fileio_test_copy_file_sync_006', 0, async function () { it('fileio_test_copy_file_sync_006', 0, async function () {
let fpath = await nextFileName('fileio_test_copy_file_sync_006'); let fpath = await nextFileName('fileio_test_copy_file_sync_006');
let fpathTarget = fpath + 'tgt'
try { try {
fileio.copyFileSync(fpath, fpathTarget); fileio.copyFileSync(fpath);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_copy_file_sync_006 has failed for ' + err);
catch (e) { expect(err.message == "Number of arguments unmatched").assertTrue();
console.log('fileio_test_copy_file_sync_006 has failed for ' + e);
} }
}); });
...@@ -2283,11 +2254,10 @@ describe('fileIOTest', function () { ...@@ -2283,11 +2254,10 @@ describe('fileIOTest', function () {
*/ */
it('fileio_test_copy_file_sync_007', 0, async function () { it('fileio_test_copy_file_sync_007', 0, async function () {
try { try {
fileio.copyFileSync(1, 1); fileio.copyFileSync(-1, -1);
expect(null).assertFail(); } catch (err) {
} console.info('fileio_test_copy_file_sync_007 has failed for ' + err);
catch (e) { expect(err.message == "Invalid argument").assertTrue();
console.log('fileio_test_copy_file_sync_007 has failed for ' + e);
} }
}); });
...@@ -2313,8 +2283,8 @@ describe('fileIOTest', function () { ...@@ -2313,8 +2283,8 @@ describe('fileIOTest', function () {
} }
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_copy_file_sync_008 has failed for ' + e); console.info('fileio_test_copy_file_sync_008 has failed for ' + err);
} }
}); });
...@@ -2331,9 +2301,9 @@ describe('fileIOTest', function () { ...@@ -2331,9 +2301,9 @@ describe('fileIOTest', function () {
fileio.copyFileSync(fpath, fpathTarget); fileio.copyFileSync(fpath, fpathTarget);
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
console.log('fileio_test_copy_file_sync_009 has failed for ' + e); console.info('fileio_test_copy_file_sync_009 has failed for ' + err);
} }
}); });
...@@ -2359,7 +2329,7 @@ describe('fileIOTest', function () { ...@@ -2359,7 +2329,7 @@ describe('fileIOTest', function () {
} }
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
} }
}); });
...@@ -2375,11 +2345,11 @@ describe('fileIOTest', function () { ...@@ -2375,11 +2345,11 @@ describe('fileIOTest', function () {
let fpathTarget = await nextFileName('?*:<>/|'); let fpathTarget = await nextFileName('?*:<>/|');
try { try {
fileio.copyFileSync(fpath, fpathTarget); fileio.copyFileSync(fpath, fpathTarget);
expect(null).assertFail();
} }
catch (e) { catch (err) {
fileio.unlinkSync(fpath); fileio.unlinkSync(fpath);
console.log('fileio_test_copy_file_sync_011 has failed for ' + e); console.info('fileio_test_copy_file_sync_011 has failed for ' + err);
expect(err.message == "No such file or directory").assertTrue();
} }
}); });
...@@ -2393,12 +2363,12 @@ describe('fileIOTest', function () { ...@@ -2393,12 +2363,12 @@ describe('fileIOTest', function () {
let fpathTarget = fpath + 'tgt' let fpathTarget = fpath + 'tgt'
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
expect(fileio.copyFileSync(fpath, fpathTarget, 0) !== null).assertTrue(); fileio.copyFileSync(fpath, fpathTarget, 0);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue(); fileio.unlinkSync(fpathTarget);
} }
catch (e) { catch (err) {
console.log('fileio_test_copy_file_sync_012 has failed for ' + e); console.info('fileio_test_copy_file_sync_012 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2414,10 +2384,10 @@ describe('fileIOTest', function () { ...@@ -2414,10 +2384,10 @@ describe('fileIOTest', function () {
try { try {
expect(fileio.truncateSync(fpath, 10) !== null).assertTrue(); expect(fileio.truncateSync(fpath, 10) !== null).assertTrue();
expect(fileio.statSync(fpath).size == 10).assertTrue(); expect(fileio.statSync(fpath).size == 10).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_truncate_sync_000 has failed for ' + e); console.info('fileio_test_truncate_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2430,10 +2400,9 @@ describe('fileIOTest', function () { ...@@ -2430,10 +2400,9 @@ describe('fileIOTest', function () {
it('fileio_test_truncate_sync_001', 0, async function () { it('fileio_test_truncate_sync_001', 0, async function () {
try { try {
fileio.truncateSync(); fileio.truncateSync();
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_truncate_sync_001 has failed for ' + err);
catch (e) { expect(err.message == "Number of arguments unmatched").assertTrue();
console.log('fileio_test_truncate_sync_001 has failed for ' + e);
} }
}); });
...@@ -2446,10 +2415,9 @@ describe('fileIOTest', function () { ...@@ -2446,10 +2415,9 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_truncate_sync_001'); let fpath = await nextFileName('fileio_test_truncate_sync_001');
try { try {
fileio.truncateSync(fpath); fileio.truncateSync(fpath);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_truncate_sync_002 has failed for ' + err);
catch (e) { expect(err.message == "No such file or directory").assertTrue();
console.log('fileio_test_truncate_sync_002 has failed for ' + e);
} }
}); });
...@@ -2462,10 +2430,9 @@ describe('fileIOTest', function () { ...@@ -2462,10 +2430,9 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_truncate_sync_003'); let fpath = await nextFileName('fileio_test_truncate_sync_003');
try { try {
fileio.truncateSync(fpath, -1); fileio.truncateSync(fpath, -1);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_truncate_sync_003 has failed for ' + err);
catch (e) { expect(err.message == "Invalid argument").assertTrue();
console.log('fileio_test_truncate_sync_003 has failed for ' + e);
} }
}); });
...@@ -2480,12 +2447,12 @@ describe('fileIOTest', function () { ...@@ -2480,12 +2447,12 @@ describe('fileIOTest', function () {
let fpathTarget = fpath + 'tgt' let fpathTarget = fpath + 'tgt'
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
expect(fileio.renameSync(fpath, fpathTarget) !== null).assertTrue(); fileio.renameSync(fpath, fpathTarget);
expect(fileio.accessSync(fpathTarget) !== null).assertTrue(); fileio.accessSync(fpathTarget);
expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue(); fileio.unlinkSync(fpathTarget);
} }
catch (e) { catch (err) {
console.log('fileio_test_rename_sync_000 has failed for ' + e); console.info('fileio_test_rename_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2501,10 +2468,9 @@ describe('fileIOTest', function () { ...@@ -2501,10 +2468,9 @@ describe('fileIOTest', function () {
let fpathTarget = fpath + 'tgt' let fpathTarget = fpath + 'tgt'
try { try {
fileio.renameSync(fpath, fpathTarget); fileio.renameSync(fpath, fpathTarget);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_rename_sync_001 has failed for ' + err);
catch (e) { expect(err.message == "No such file or directory").assertTrue();
console.log('fileio_test_rename_sync_001 has failed for ' + e);
} }
}); });
...@@ -2518,11 +2484,11 @@ describe('fileIOTest', function () { ...@@ -2518,11 +2484,11 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
fileio.renameSync(fpath, '/'); fileio.renameSync(fpath, '/');
expect(null).assertFail(); }catch (err) {
} fileio.unlinkSync(fpath);
catch (e) { console.info('fileio_test_rename_sync_002 has failed for ' + err);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); expect(err.message == "Cross-device link").assertTrue();
console.log('fileio_test_rename_sync_002 has failed for ' + e);
} }
}); });
...@@ -2535,12 +2501,12 @@ describe('fileIOTest', function () { ...@@ -2535,12 +2501,12 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_rename_sync_003'); let fpath = await nextFileName('fileio_test_rename_sync_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
console.log('fileio_test_rename_sync_003 Test start'); console.info('fileio_test_rename_sync_003 Test start');
fileio.renameSync(fpath, fpath); fileio.renameSync(fpath, fpath);
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
}); });
...@@ -2554,8 +2520,8 @@ describe('fileIOTest', function () { ...@@ -2554,8 +2520,8 @@ describe('fileIOTest', function () {
fileio.renameSync(1, 1); fileio.renameSync(1, 1);
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_rename_sync_004 pass. ' + e); console.info('fileio_test_rename_sync_004 pass. ' + err);
} }
}); });
...@@ -2571,9 +2537,9 @@ describe('fileIOTest', function () { ...@@ -2571,9 +2537,9 @@ describe('fileIOTest', function () {
fileio.renameSync(fpath, 1); fileio.renameSync(fpath, 1);
expect(null).assertFail(); expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
console.log('fileio_test_rename_sync_005 pass. ' + e); console.info('fileio_test_rename_sync_005 pass. ' + err);
} }
}); });
...@@ -2586,13 +2552,13 @@ describe('fileIOTest', function () { ...@@ -2586,13 +2552,13 @@ describe('fileIOTest', function () {
let dpath = await nextFileName('fileio_test_rename_sync_006') + 'd' let dpath = await nextFileName('fileio_test_rename_sync_006') + 'd'
let dpathTarget = await nextFileName('fileio_test_rename_sync_006-1') + 'd' let dpathTarget = await nextFileName('fileio_test_rename_sync_006-1') + 'd'
try { try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue(); fileio.mkdirSync(dpath);
expect(fileio.renameSync(dpath, dpathTarget) == undefined).assertTrue(); fileio.renameSync(dpath, dpathTarget);
expect(fileio.accessSync(dpathTarget) !== null).assertTrue(); fileio.accessSync(dpathTarget);
expect(fileio.rmdirSync(dpathTarget) !== null).assertTrue(); fileio.rmdirSync(dpathTarget);
} }
catch (e) { catch (err) {
console.log('fileio_test_rename_sync_006 has failed for ' + e); console.info('fileio_test_rename_sync_006 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2607,10 +2573,9 @@ describe('fileIOTest', function () { ...@@ -2607,10 +2573,9 @@ describe('fileIOTest', function () {
let dpathTarget = await nextFileName('fileio_test_rename_sync_007-1') + 'd' let dpathTarget = await nextFileName('fileio_test_rename_sync_007-1') + 'd'
try { try {
fileio.renameSync(dpath, dpathTarget); fileio.renameSync(dpath, dpathTarget);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_rename_sync_007 has failed for ' + err);
catch (e) { expect(err.message == "No such file or directory").assertTrue();
console.log('fileio_test_rename_sync_007 has failed for ' + e);
} }
}); });
...@@ -2623,13 +2588,12 @@ describe('fileIOTest', function () { ...@@ -2623,13 +2588,12 @@ describe('fileIOTest', function () {
let dpath = await nextFileName('fileio_test_rename_sync_008') + 'd' let dpath = await nextFileName('fileio_test_rename_sync_008') + 'd'
let dpathTarget = '/data/accounts/account_0/appdata/aaa/bbb/fileio_test_rename_sync_008-1d' let dpathTarget = '/data/accounts/account_0/appdata/aaa/bbb/fileio_test_rename_sync_008-1d'
try { try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue(); fileio.mkdirSync(dpath);
fileio.renameSync(dpath, dpathTarget); fileio.renameSync(dpath, dpathTarget);
expect(null).assertFail(); }catch (err) {
} fileio.rmdirSync(dpath);
catch (e) { console.info('fileio_test_rename_sync_008 has failed for ' + err);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); expect(err.message == "No such file or directory").assertTrue();
console.log('fileio_test_rename_sync_008 has failed for ' + e);
} }
}); });
...@@ -2641,14 +2605,13 @@ describe('fileIOTest', function () { ...@@ -2641,14 +2605,13 @@ describe('fileIOTest', function () {
it('fileio_test_rename_sync_009', 0, async function () { it('fileio_test_rename_sync_009', 0, async function () {
let dpath = await nextFileName('fileio_test_rename_sync_009') + 'd' let dpath = await nextFileName('fileio_test_rename_sync_009') + 'd'
try { try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue(); fileio.mkdirSync(dpath);
let result = fileio.renameSync(dpath, dpath); fileio.renameSync(dpath, dpath);
expect(result === undefined).assertTrue(); fileio.accessSync(dpath);
expect(fileio.accessSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
expect(fileio.rmdirSync(dpath) !== null).assertTrue();
} }
catch (e) { catch (err) {
console.log('fileio_test_rename_sync_009 has failed for ' + e); console.info('fileio_test_rename_sync_009 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2663,12 +2626,12 @@ describe('fileIOTest', function () { ...@@ -2663,12 +2626,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o660) !== null).assertTrue(); fileio.fchmodSync(fd, 0o660);
expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_000 has failed for ' + e); console.info('fileio_test_fchmod_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2683,12 +2646,12 @@ describe('fileIOTest', function () { ...@@ -2683,12 +2646,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o460) !== null).assertTrue(); fileio.fchmodSync(fd, 0o460);
expect((fileio.statSync(fpath).mode & 0o777) == 0o460).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o460).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_001 has failed for ' + e); console.info('fileio_test_fchmod_sync_001 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2703,12 +2666,12 @@ describe('fileIOTest', function () { ...@@ -2703,12 +2666,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o260) !== null).assertTrue(); fileio.fchmodSync(fd, 0o260);
expect((fileio.statSync(fpath).mode & 0o777) == 0o260).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o260).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_002 has failed for ' + e); console.info('fileio_test_fchmod_sync_002 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2721,11 +2684,10 @@ describe('fileIOTest', function () { ...@@ -2721,11 +2684,10 @@ describe('fileIOTest', function () {
it('fileio_test_fchmod_sync_003', 0, async function () { it('fileio_test_fchmod_sync_003', 0, async function () {
let fpath = await nextFileName('fileio_test_fchmod_sync_003'); let fpath = await nextFileName('fileio_test_fchmod_sync_003');
try { try {
expect(fileio.fchmodSync(fpath, 0o660) !== null).assertTrue(); fileio.fchmodSync(fpath, 0o660);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_fchmod_sync_003 has failed for ' + err);
catch (e) { expect(err.message == "Invalid fd").assertTrue();
console.log('fileio_test_fchmod_sync_003 has failed for ' + e);
} }
}); });
...@@ -2739,11 +2701,11 @@ describe('fileIOTest', function () { ...@@ -2739,11 +2701,11 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 2222222222222) !== null).assertTrue(); fileio.fchmodSync(fd, 2222222222222);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_004 has failed for A' + e); console.info('fileio_test_fchmod_sync_004 has failed for A' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2756,14 +2718,14 @@ describe('fileIOTest', function () { ...@@ -2756,14 +2718,14 @@ describe('fileIOTest', function () {
it('fileio_test_fchmod_sync_005', 0, async function () { it('fileio_test_fchmod_sync_005', 0, async function () {
let dpath = await nextFileName('fileio_test_fchmod_sync_005') + 'd' let dpath = await nextFileName('fileio_test_fchmod_sync_005') + 'd'
try { try {
expect(fileio.mkdirSync(dpath, 0o777) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o777);
let fd = fileio.openSync(dpath); let fd = fileio.openSync(dpath);
console.log(fd); console.info(fd);
expect(fileio.fchmodSync(fd, 0o660) !== null).assertTrue(); fileio.fchmodSync(fd, 0o660);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_005 has failed for ' + e); console.info('fileio_test_fchmod_sync_005 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2777,10 +2739,10 @@ describe('fileIOTest', function () { ...@@ -2777,10 +2739,10 @@ describe('fileIOTest', function () {
let dpath; let dpath;
try { try {
fileio.fchmodSync(dpath, 0o660); fileio.fchmodSync(dpath, 0o660);
expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_006 has failed for ' + e); console.info('fileio_test_fchmod_sync_006 has failed for ' + err);
expect(err.message == "Invalid fd").assertTrue();
} }
}); });
...@@ -2794,12 +2756,12 @@ describe('fileIOTest', function () { ...@@ -2794,12 +2756,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o700) !== null).assertTrue(); fileio.fchmodSync(fd, 0o700);
expect((fileio.statSync(fpath).mode & 0o777) == 0o700).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o700).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_007 has failed for ' + e); console.info('fileio_test_fchmod_sync_007 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2814,12 +2776,12 @@ describe('fileIOTest', function () { ...@@ -2814,12 +2776,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o400) !== null).assertTrue(); fileio.fchmodSync(fd, 0o400);
expect((fileio.statSync(fpath).mode & 0o777) == 0o400).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o400).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_008 has failed for ' + e); console.info('fileio_test_fchmod_sync_008 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2834,12 +2796,12 @@ describe('fileIOTest', function () { ...@@ -2834,12 +2796,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o200) !== null).assertTrue(); fileio.fchmodSync(fd, 0o200);
expect((fileio.statSync(fpath).mode & 0o777) == 0o200).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o200).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_009 has failed for ' + e); console.info('fileio_test_fchmod_sync_009 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2854,12 +2816,12 @@ describe('fileIOTest', function () { ...@@ -2854,12 +2816,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o100) !== null).assertTrue(); fileio.fchmodSync(fd, 0o100);
expect((fileio.statSync(fpath).mode & 0o777) == 0o100).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o100).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_010 has failed for ' + e); console.info('fileio_test_fchmod_sync_010 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2874,12 +2836,12 @@ describe('fileIOTest', function () { ...@@ -2874,12 +2836,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o070) !== null).assertTrue(); fileio.fchmodSync(fd, 0o070);
expect((fileio.statSync(fpath).mode & 0o777) == 0o070).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o070).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_011 has failed for ' + e); console.info('fileio_test_fchmod_sync_011 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2894,12 +2856,12 @@ describe('fileIOTest', function () { ...@@ -2894,12 +2856,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o040) !== null).assertTrue(); fileio.fchmodSync(fd, 0o040);
expect((fileio.statSync(fpath).mode & 0o777) == 0o040).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o040).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_012 has failed for ' + e); console.info('fileio_test_fchmod_sync_012 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2914,12 +2876,12 @@ describe('fileIOTest', function () { ...@@ -2914,12 +2876,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o020) !== null).assertTrue(); fileio.fchmodSync(fd, 0o020);
expect((fileio.statSync(fpath).mode & 0o777) == 0o020).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o020).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_013 has failed for ' + e); console.info('fileio_test_fchmod_sync_013 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2934,12 +2896,12 @@ describe('fileIOTest', function () { ...@@ -2934,12 +2896,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o010) !== null).assertTrue(); fileio.fchmodSync(fd, 0o010);
expect((fileio.statSync(fpath).mode & 0o777) == 0o010).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o010).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_014 has failed for ' + e); console.info('fileio_test_fchmod_sync_014 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2954,12 +2916,12 @@ describe('fileIOTest', function () { ...@@ -2954,12 +2916,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o007) !== null).assertTrue(); fileio.fchmodSync(fd, 0o007);
expect((fileio.statSync(fpath).mode & 0o777) == 0o007).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o007).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_015 has failed for ' + e); console.info('fileio_test_fchmod_sync_015 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2974,12 +2936,12 @@ describe('fileIOTest', function () { ...@@ -2974,12 +2936,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o004) !== null).assertTrue(); fileio.fchmodSync(fd, 0o004);
expect((fileio.statSync(fpath).mode & 0o777) == 0o004).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o004).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_016 has failed for ' + e); console.info('fileio_test_fchmod_sync_016 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -2994,12 +2956,12 @@ describe('fileIOTest', function () { ...@@ -2994,12 +2956,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o002) !== null).assertTrue(); fileio.fchmodSync(fd, 0o002);
expect((fileio.statSync(fpath).mode & 0o777) == 0o002).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o002).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_017 has failed for ' + e); console.info('fileio_test_fchmod_sync_017 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3014,12 +2976,12 @@ describe('fileIOTest', function () { ...@@ -3014,12 +2976,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchmodSync(fd, 0o001) !== null).assertTrue(); fileio.fchmodSync(fd, 0o001);
expect((fileio.statSync(fpath).mode & 0o777) == 0o001).assertTrue(); expect((fileio.statSync(fpath).mode & 0o777) == 0o001).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchmod_sync_018 has failed for ' + e); console.info('fileio_test_fchmod_sync_018 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3034,12 +2996,12 @@ describe('fileIOTest', function () { ...@@ -3034,12 +2996,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath, 0o2); let fd = fileio.openSync(fpath, 0o2);
expect(fileio.ftruncateSync(fd, 10) !== null).assertTrue(); fileio.ftruncateSync(fd, 10);
expect(fileio.statSync(fpath).size == 10).assertTrue(); expect(fileio.statSync(fpath).size == 10).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_ftruncate_sync_000 has failed for ' + e); console.info('fileio_test_ftruncate_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3054,12 +3016,12 @@ describe('fileIOTest', function () { ...@@ -3054,12 +3016,12 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath, 0o2); let fd = fileio.openSync(fpath, 0o2);
expect(fileio.ftruncateSync(fd) !== null).assertTrue(); fileio.ftruncateSync(fd);
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_ftruncate_sync_001 has failed for ' + e); console.info('fileio_test_ftruncate_sync_001 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3072,10 +3034,9 @@ describe('fileIOTest', function () { ...@@ -3072,10 +3034,9 @@ describe('fileIOTest', function () {
it('fileio_test_ftruncate_sync_002', 0, async function () { it('fileio_test_ftruncate_sync_002', 0, async function () {
try { try {
fileio.ftruncateSync(1); fileio.ftruncateSync(1);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_ftruncate_sync_002 has failed for ' + err);
catch (e) { expect(err.message == "Invalid argument").assertTrue();
console.log('fileio_test_ftruncate_sync_002 has failed for ' + e);
} }
}); });
...@@ -3087,10 +3048,9 @@ describe('fileIOTest', function () { ...@@ -3087,10 +3048,9 @@ describe('fileIOTest', function () {
it('fileio_test_ftruncate_sync_003', 0, async function () { it('fileio_test_ftruncate_sync_003', 0, async function () {
try { try {
fileio.ftruncateSync(-1); fileio.ftruncateSync(-1);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_ftruncate_sync_003 has failed for ' + err);
catch (e) { expect(err.message == "Bad file descriptor").assertTrue();
console.log('fileio_test_ftruncate_sync_003 has failed for ' + e);
} }
}); });
...@@ -3104,11 +3064,10 @@ describe('fileIOTest', function () { ...@@ -3104,11 +3064,10 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
let fd = fileio.openSync(fpath, 0o2); let fd = fileio.openSync(fpath, 0o2);
expect(fileio.ftruncateSync(fd, -1) !== null).assertTrue(); fileio.ftruncateSync(fd, -1);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_ftruncate_sync_004 has failed for ' + err);
catch (e) { expect(err.message == "Invalid argument").assertTrue();
console.log('fileio_test_ftruncate_sync_004 has failed for ' + e);
} }
}); });
...@@ -3123,11 +3082,11 @@ describe('fileIOTest', function () { ...@@ -3123,11 +3082,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath, 0o2); let fd = fileio.openSync(fpath, 0o2);
expect(fileio.fsyncSync(fd) !== null).assertTrue(); expect(fileio.fsyncSync(fd) !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fsync_sync_000 has failed for ' + e); console.info('fileio_test_fsync_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3140,10 +3099,10 @@ describe('fileIOTest', function () { ...@@ -3140,10 +3099,10 @@ describe('fileIOTest', function () {
it('fileio_test_fsync_sync_001', 0, async function () { it('fileio_test_fsync_sync_001', 0, async function () {
try { try {
fileio.fsyncSync(1); fileio.fsyncSync(1);
expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_fsync_sync_001 has failed for ' + e); console.info('fileio_test_fsync_sync_001 has failed for ' + err);
expect(err.message == "Invalid argument").assertTrue();
} }
}); });
...@@ -3155,10 +3114,10 @@ describe('fileIOTest', function () { ...@@ -3155,10 +3114,10 @@ describe('fileIOTest', function () {
it('fileio_test_fsync_sync_002', 0, async function () { it('fileio_test_fsync_sync_002', 0, async function () {
try { try {
fileio.fsyncSync(-1); fileio.fsyncSync(-1);
expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_fsync_sync_002 has failed for ' + e); console.info('fileio_test_fsync_sync_002 has failed for ' + err);
expect(err.message == "Bad file descriptor").assertTrue();
} }
}); });
...@@ -3170,11 +3129,11 @@ describe('fileIOTest', function () { ...@@ -3170,11 +3129,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_000', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_000', 0, async function () {
let dpath = await nextFileName('fileio_test_fsync_sync_000') + 'd' let dpath = await nextFileName('fileio_test_fsync_sync_000') + 'd'
try { try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue(); fileio.mkdirSync(dpath);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_000 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3187,11 +3146,11 @@ describe('fileIOTest', function () { ...@@ -3187,11 +3146,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_001', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_001', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_001') + 'd' let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_001') + 'd'
try { try {
expect(fileio.mkdirSync(dpath, 0o660) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o660);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_001 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_001 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3204,11 +3163,11 @@ describe('fileIOTest', function () { ...@@ -3204,11 +3163,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_002', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_002', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_002') + 'd' let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_002') + 'd'
try { try {
expect(fileio.mkdirSync(dpath, 0o460) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o460);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_002 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_002 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3221,11 +3180,11 @@ describe('fileIOTest', function () { ...@@ -3221,11 +3180,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_003', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_003', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_003') + 'd' let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_003') + 'd'
try { try {
expect(fileio.mkdirSync(dpath, 0o260) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o260);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_003 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_003 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3237,11 +3196,10 @@ describe('fileIOTest', function () { ...@@ -3237,11 +3196,10 @@ describe('fileIOTest', function () {
*/ */
it('fileio_test_mkdir_sync_rmdir_sync_004', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_004', 0, async function () {
try { try {
expect(fileio.mkdirSync(1) !== null); fileio.mkdirSync(1);
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_mkdir_sync_rmdir_sync_004 has failed for ' + err);
catch (e) { expect(err.message == "Invalid path").assertTrue();
console.log('fileio_test_fsync_sync_004 has failed for ' + e);
} }
}); });
...@@ -3252,11 +3210,11 @@ describe('fileIOTest', function () { ...@@ -3252,11 +3210,11 @@ describe('fileIOTest', function () {
*/ */
it('fileio_test_mkdir_sync_rmdir_sync_005', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_005', 0, async function () {
try { try {
expect(fileio.mkdirSync('/', 1) !== null).assertTrue(); fileio.mkdirSync('/', 1);
expect(null).assertFail();
} }
catch (e) { catch (err) {
console.log('fileio_test_fsync_sync_005 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_005 has failed for ' + err);
expect(err.message == "File exists").assertTrue();
} }
}); });
...@@ -3268,11 +3226,11 @@ describe('fileIOTest', function () { ...@@ -3268,11 +3226,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_006', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_006', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_006') + 'd' let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_006') + 'd'
try { try {
expect(fileio.mkdirSync(dpath, 0o700) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o700);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_006 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_006 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3285,11 +3243,11 @@ describe('fileIOTest', function () { ...@@ -3285,11 +3243,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_007', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_007', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_007') + 'd' let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_007') + 'd'
try { try {
expect(fileio.mkdirSync(dpath, 0o400) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o400);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_007 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_007 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3302,11 +3260,11 @@ describe('fileIOTest', function () { ...@@ -3302,11 +3260,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_008', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_008', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_008') + 'd' let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_008') + 'd'
try { try {
expect(fileio.mkdirSync(dpath, 0o200) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o200);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_008 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_008 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3319,11 +3277,11 @@ describe('fileIOTest', function () { ...@@ -3319,11 +3277,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_009', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_009', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_009') + 'd' let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_009') + 'd'
try { try {
expect(fileio.mkdirSync(dpath, 0o100) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o100);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_009 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_009 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3336,11 +3294,11 @@ describe('fileIOTest', function () { ...@@ -3336,11 +3294,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_010', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_010', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_010') + 'd'; let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_010') + 'd';
try { try {
expect(fileio.mkdirSync(dpath, 0o070) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o070);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_010 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_010 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3353,11 +3311,11 @@ describe('fileIOTest', function () { ...@@ -3353,11 +3311,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_011', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_011', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_011') + 'd'; let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_011') + 'd';
try { try {
expect(fileio.mkdirSync(dpath, 0o040) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o040);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_011 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_011 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3370,11 +3328,11 @@ describe('fileIOTest', function () { ...@@ -3370,11 +3328,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_012', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_012', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_012') + 'd'; let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_012') + 'd';
try { try {
expect(fileio.mkdirSync(dpath, 0o020) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o020);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_012 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_012 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3387,11 +3345,11 @@ describe('fileIOTest', function () { ...@@ -3387,11 +3345,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_013', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_013', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_013') + 'd'; let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_013') + 'd';
try { try {
expect(fileio.mkdirSync(dpath, 0o010) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o010);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_013 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_013 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3404,11 +3362,11 @@ describe('fileIOTest', function () { ...@@ -3404,11 +3362,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_014', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_014', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_014') + 'd'; let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_014') + 'd';
try { try {
expect(fileio.mkdirSync(dpath, 0o007) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o007);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_014 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_014 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3421,11 +3379,11 @@ describe('fileIOTest', function () { ...@@ -3421,11 +3379,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_015', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_015', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_015') + 'd'; let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_015') + 'd';
try { try {
expect(fileio.mkdirSync(dpath, 0o004) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o004);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_015 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_015 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3438,11 +3396,11 @@ describe('fileIOTest', function () { ...@@ -3438,11 +3396,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_016', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_016', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_016') + 'd'; let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_016') + 'd';
try { try {
expect(fileio.mkdirSync(dpath, 0o002) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o002);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_016 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_016 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3455,11 +3413,11 @@ describe('fileIOTest', function () { ...@@ -3455,11 +3413,11 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_017', 0, async function () { it('fileio_test_mkdir_sync_rmdir_sync_017', 0, async function () {
let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_017') + 'd'; let dpath = await nextFileName('fileio_test_mkdir_sync_rmdir_sync_017') + 'd';
try { try {
expect(fileio.mkdirSync(dpath, 0o001) !== null).assertTrue(); fileio.mkdirSync(dpath, 0o001);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_mkdir_sync_rmdir_sync_017 has failed for ' + e); console.info('fileio_test_mkdir_sync_rmdir_sync_017 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3476,11 +3434,11 @@ describe('fileIOTest', function () { ...@@ -3476,11 +3434,11 @@ describe('fileIOTest', function () {
let fd = fileio.openSync(fpath, 0o2); let fd = fileio.openSync(fpath, 0o2);
let stat = fileio.fstatSync(fd); let stat = fileio.fstatSync(fd);
expect(stat !== null).assertTrue(); expect(stat !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fstat_sync_000 has failed for ' + e); console.info('fileio_test_fstat_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3492,26 +3450,24 @@ describe('fileIOTest', function () { ...@@ -3492,26 +3450,24 @@ describe('fileIOTest', function () {
*/ */
it('fileio_test_fstat_sync_001', 0, async function () { it('fileio_test_fstat_sync_001', 0, async function () {
try { try {
expect(fileio.fstatSync(1) !== null).assertTrue(); expect(fileio.fstatSync(-1) !== null).assertTrue();
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_fstat_sync_001 has failed for ' + err);
catch (e) { expect(err.message == "Bad file descriptor").assertTrue();
console.log('fileio_test_fstat_sync_001 has failed for ' + e);
} }
}); });
/** /**
* @tc.number SUB_STORAGE_FileIO_FstatSync_0200 * @tc.number SUB_STORAGE_FileIO_FstatSync_0200
* @tc.name fileio_test_fstat_sync_002 * @tc.name fileio_test_fstat_sync_002
* @tc.desc Function of API, fstatSync, fd = 1. The test file is not exist. * @tc.desc Function of API, fstatSync, fd is string type.
*/ */
it('fileio_test_fstat_sync_002', 0, async function () { it('fileio_test_fstat_sync_002', 0, async function () {
try { try {
expect(fileio.fstatSync(1) !== null).assertTrue(); fileio.fstatSync("");
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_fstat_sync_002 has failed for ' + err);
catch (e) { expect(err.message == "Invalid fd").assertTrue();
console.log('fileio_test_fstat_sync_002 has failed for ' + e);
} }
}); });
...@@ -3523,16 +3479,16 @@ describe('fileIOTest', function () { ...@@ -3523,16 +3479,16 @@ describe('fileIOTest', function () {
it('fileio_test_fstat_sync_003', 0, async function () { it('fileio_test_fstat_sync_003', 0, async function () {
let dpath = await nextFileName('fileio_test_fstat_sync_003') + 'd' let dpath = await nextFileName('fileio_test_fstat_sync_003') + 'd'
try { try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue(); fileio.mkdirSync(dpath);
let fd = fileio.openSync(dpath); let fd = fileio.openSync(dpath);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
let stat = fileio.fstatSync(fd); let stat = fileio.fstatSync(fd);
expect(stat !== null).assertTrue(); expect(stat !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.rmdirSync(dpath) !== null).assertTrue(); fileio.rmdirSync(dpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fstat_sync_003 has failed for ' + e); console.info('fileio_test_fstat_sync_003 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3550,10 +3506,10 @@ describe('fileIOTest', function () { ...@@ -3550,10 +3506,10 @@ describe('fileIOTest', function () {
let GID = stat.gid let GID = stat.gid
try { try {
expect(fileio.chownSync(fpath, UID, GID) !== null).assertTrue(); expect(fileio.chownSync(fpath, UID, GID) !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_chown_sync_000 has failed for ' + e); console.info('fileio_test_chown_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3572,11 +3528,10 @@ describe('fileIOTest', function () { ...@@ -3572,11 +3528,10 @@ describe('fileIOTest', function () {
let GID = stat.gid let GID = stat.gid
try { try {
expect(fileio.chownSync(fpathc, UID, GID)); expect(fileio.chownSync(fpathc, UID, GID));
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_chown_sync_001 has failed for ' + err);
catch (e) { expect(err.message == "No such file or directory").assertTrue();
console.log('fileio_test_chown_sync_001 has failed for ' + e); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
} }
}); });
...@@ -3590,11 +3545,10 @@ describe('fileIOTest', function () { ...@@ -3590,11 +3545,10 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
expect(fileio.chownSync(fpath, 0, 0)); expect(fileio.chownSync(fpath, 0, 0));
expect(null).assertFail(); }catch (err) {
} console.info('fileio_test_chown_sync_002 has failed for ' + err);
catch (e) { expect(err.message == "Operation not permitted").assertTrue();
console.log('fileio_test_chown_sync_002 has failed for ' + e); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
} }
}); });
...@@ -3612,11 +3566,11 @@ describe('fileIOTest', function () { ...@@ -3612,11 +3566,11 @@ describe('fileIOTest', function () {
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
expect(fileio.fchownSync(fd, UID, GID) !== null).assertTrue(); expect(fileio.fchownSync(fd, UID, GID) !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_fchown_sync_000 has failed for ' + e); console.info('fileio_test_fchown_sync_000 has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3634,11 +3588,10 @@ describe('fileIOTest', function () { ...@@ -3634,11 +3588,10 @@ describe('fileIOTest', function () {
let GID = stat.gid let GID = stat.gid
try { try {
expect(fileio.fchownSync(-1, UID, GID)); expect(fileio.fchownSync(-1, UID, GID));
expect(null).assertFail(); }catch (err) {
} fileio.unlinkSync(fpath);
catch (e) { console.info('fileio_test_fchown_sync_001 has failed for ' + err);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); expect(err.message == "Bad file descriptor").assertTrue();
console.log('fileio_test_fchown_sync_001 has failed for ' + e);
} }
}); });
...@@ -3656,12 +3609,12 @@ describe('fileIOTest', function () { ...@@ -3656,12 +3609,12 @@ describe('fileIOTest', function () {
let GID = stat.gid let GID = stat.gid
try { try {
let fd = fileio.openSync(fpath); let fd = fileio.openSync(fpath);
fileio.fchownSync(fd, cc, GID); fileio.fchownSync(fd, null, GID);
expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
console.log('fileio_test_fchown_sync_002 has failed for ' + e); console.info('fileio_test_fchown_sync_002 has failed for ' + err);
expect(err.message == "Operation not permitted").assertTrue();
} }
}); });
...@@ -3679,12 +3632,12 @@ describe('fileIOTest', function () { ...@@ -3679,12 +3632,12 @@ describe('fileIOTest', function () {
try { try {
fd = fileio.openSync(fpath, 0o2); fd = fileio.openSync(fpath, 0o2);
expect(fileio.fchownSync(fd, UID, 0)); expect(fileio.fchownSync(fd, UID, 0));
expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
console.log('fileio_test_fchown_sync_003 has failed for ' + e); console.info('fileio_test_fchown_sync_003 has failed for ' + err);
expect(err.message == "Operation not permitted").assertTrue();
} }
}); });
...@@ -3702,12 +3655,11 @@ describe('fileIOTest', function () { ...@@ -3702,12 +3655,11 @@ describe('fileIOTest', function () {
let fd = null let fd = null
try { try {
expect(fileio.fchownSync(fd, UID, GID)); expect(fileio.fchownSync(fd, UID, GID));
expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
console.log('fileio_test_fchown_sync_004 has failed for ' + e); console.info('fileio_test_fchown_sync_004 has failed for ' + err);
expect(err.message == "Invalid fd").assertTrue();
} }
}); });
...@@ -3727,12 +3679,12 @@ describe('fileIOTest', function () { ...@@ -3727,12 +3679,12 @@ describe('fileIOTest', function () {
try { try {
fd = fileio.openSync(fpath); fd = fileio.openSync(fpath);
expect(fileio.fchownSync(fd, UID, GID)); expect(fileio.fchownSync(fd, UID, GID));
expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
console.log('fileio_test_fchown_sync_005 has failed for ' + e); console.info('fileio_test_fchown_sync_005 has failed for ' + err);
expect(err.message == "Operation not permitted").assertTrue();
} }
}); });
...@@ -3750,12 +3702,12 @@ describe('fileIOTest', function () { ...@@ -3750,12 +3702,12 @@ describe('fileIOTest', function () {
try { try {
fd = fileio.openSync(fpath); fd = fileio.openSync(fpath);
fileio.fchownSync(fd, UID, 0); fileio.fchownSync(fd, UID, 0);
expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
console.log('fileio_test_fchown_sync_006 has failed for ' + e); console.info('fileio_test_fchown_sync_006 has failed for ' + err);
expect(err.message == "Operation not permitted").assertTrue();
} }
}); });
...@@ -3771,12 +3723,12 @@ describe('fileIOTest', function () { ...@@ -3771,12 +3723,12 @@ describe('fileIOTest', function () {
try { try {
fd = fileio.openSync(fpath, 0o2); fd = fileio.openSync(fpath, 0o2);
fileio.fchownSync(fd, 0, 0); fileio.fchownSync(fd, 0, 0);
expect(null).assertFail();
} }
catch (e) { catch (err) {
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
console.log('fileio_test_fchown_sync_007 has failed for ' + e); console.info('fileio_test_fchown_sync_007 has failed for ' + err);
expect(err.message == "Operation not permitted").assertTrue();
} }
}); });
...@@ -3791,15 +3743,15 @@ describe('fileIOTest', function () { ...@@ -3791,15 +3743,15 @@ describe('fileIOTest', function () {
let fd = fileio.openSync(fpath, 0o102, 0o777); let fd = fileio.openSync(fpath, 0o102, 0o777);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.writeSync(fd, randomString(4096)) !== null).assertTrue(); expect(fileio.writeSync(fd, randomString(4096)) !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
let fd1 = fileio.openSync(fpath, 0o2); let fd1 = fileio.openSync(fpath, 0o2);
let rlen = fileio.readSync(fd1, new ArrayBuffer(4096)); let rlen = fileio.readSync(fd1, new ArrayBuffer(4096));
expect(rlen == 4096).assertTrue(); expect(rlen == 4096).assertTrue();
expect(fileio.closeSync(fd1) !== null).assertTrue(); fileio.closeSync(fd1);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
} }
catch (e) { catch (err) {
console.log('fileio_test_prop_write_open_read_4k_sync has failed for ' + e); console.info('fileio_test_prop_write_open_read_4k_sync has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
...@@ -3816,13 +3768,13 @@ describe('fileIOTest', function () { ...@@ -3816,13 +3768,13 @@ describe('fileIOTest', function () {
let fd = fileio.openSync(fpath, 0o102, 0o777); let fd = fileio.openSync(fpath, 0o102, 0o777);
expect(fd !== null).assertTrue(); expect(fd !== null).assertTrue();
expect(fileio.writeSync(fd, randomString(4096)) !== null).assertTrue(); expect(fileio.writeSync(fd, randomString(4096)) !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue(); fileio.closeSync(fd);
expect(fileio.copyFileSync(fpath, fpath1) !== null).assertTrue(); fileio.copyFileSync(fpath, fpath1);
expect(fileio.unlinkSync(fpath) !== null).assertTrue(); fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpath1) !== null).assertTrue(); fileio.unlinkSync(fpath1);
} }
catch (e) { catch (err) {
console.log('fileio_test_prop_copyFile_4k_sync has failed for ' + e); console.info('fileio_test_prop_copyFile_4k_sync has failed for ' + err);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
......
...@@ -14,12 +14,7 @@ ...@@ -14,12 +14,7 @@
*/ */
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
import { import { describe,it,expect}from 'deccjsunit/index'
describe,
it,
expect
}
from 'deccjsunit/index'
import { import {
FILE_CONTENT, FILE_CONTENT,
prepareFile, prepareFile,
......
...@@ -14,18 +14,12 @@ ...@@ -14,18 +14,12 @@
*/ */
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
import { import { describe,it,expect}from 'deccjsunit/index'
describe,
it,
expect
}
from 'deccjsunit/index';
import { import {
FILE_CONTENT, FILE_CONTENT,
prepareFile, prepareFile,
nextFileName nextFileName
} }from './Common';
from './Common';
describe('fileIOTestDirent', function () { describe('fileIOTestDirent', function () {
......
...@@ -14,12 +14,7 @@ ...@@ -14,12 +14,7 @@
*/ */
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
import { import { describe,it,expect}from 'deccjsunit/index'
describe,
it,
expect
}
from 'deccjsunit/index'
import { import {
FILE_CONTENT, FILE_CONTENT,
prepareFile, prepareFile,
......
...@@ -14,12 +14,7 @@ ...@@ -14,12 +14,7 @@
*/ */
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
import { import { describe,it,expect}from 'deccjsunit/index'
describe,
it,
expect
}
from 'deccjsunit/index'
import { import {
FILE_CONTENT, FILE_CONTENT,
prepareFile, prepareFile,
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import { import {
fileio, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBoolean, fileio, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBoolean,
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, describe, it, expect,
} from '../../Common'; } from '../../Common';
describe('fileio_stat_fstat', function () { describe('fileio_stat_fstat', function () {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import { import {
fileio, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBoolean, fileio, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBoolean,
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, describe, it, expect,
} from '../../Common'; } from '../../Common';
describe('fileio_lstat', function () { describe('fileio_lstat', function () {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import { import {
fileio, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBoolean, fileio, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBoolean,
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, describe, it, expect,
} from '../../Common'; } from '../../Common';
describe('fileio_stat', function () { describe('fileio_stat', function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册