提交 0db8dc7b 编写于 作者: R raoxian

update storagefileiojstest

Signed-off-by: Nraoxian <raoxian@huawei.com>
上级 9ffb8c36
......@@ -37,7 +37,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_close_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -57,7 +57,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_000 has failed for ' + err);
expect(null).assertFail();
......@@ -77,7 +77,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_001 has failed for ' + err);
expect(null).assertFail();
......@@ -97,7 +97,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_002 has failed for ' + err);
expect(null).assertFail();
......@@ -173,7 +173,7 @@ describe('fileIOTest', function () {
expect(red !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_005 has failed for ' + err);
expect(null).assertFail();
......@@ -191,7 +191,7 @@ describe('fileIOTest', function () {
try {
fileio.openSync(fpath, 0o200, 0o700);
expect(null).assertFail();
}
}
catch (err) {
fileio.unlinkSync(fpath);
}
......@@ -219,7 +219,7 @@ describe('fileIOTest', function () {
expect(red !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_007 has failed for ' + err);
expect(null).assertFail();
......@@ -248,7 +248,7 @@ describe('fileIOTest', function () {
expect(red !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_008 has failed for ' + err);
expect(null).assertFail();
......@@ -293,7 +293,7 @@ describe('fileIOTest', function () {
expect(red !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_010 has failed for ' + err);
expect(null).assertFail();
......@@ -317,7 +317,7 @@ describe('fileIOTest', function () {
expect(red !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_011 has failed for ' + err);
expect(null).assertFail();
......@@ -339,7 +339,7 @@ describe('fileIOTest', function () {
offset: 1,
});
expect(null).assertFail();
}
}
catch (err) {
console.info('fileio_test_open_012 has failed for ' + err);
expect(err.message == "Bad file descriptor").assertTrue();
......@@ -370,7 +370,7 @@ describe('fileIOTest', function () {
expect(red !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_013 has failed for ' + err);
expect(null).assertFail();
......@@ -394,7 +394,7 @@ describe('fileIOTest', function () {
fileio.closeSync(fd2);
fileio.unlinkSync(fpath);
done();
}
}
catch (err) {
console.info('fileio_test_open_014 has failed for ' + err);
expect(null).assertFail();
......@@ -414,7 +414,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_015 has failed for ' + err);
expect(null).assertFail();
......@@ -434,7 +434,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_016 has failed for ' + err);
expect(null).assertFail();
......@@ -454,7 +454,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_017 has failed for ' + err);
expect(null).assertFail();
......@@ -474,7 +474,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_018 has failed for ' + err);
expect(null).assertFail();
......@@ -512,7 +512,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_021 has failed for ' + err);
expect(null).assertFail();
......@@ -532,7 +532,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_022 has failed for ' + err);
expect(null).assertFail();
......@@ -552,7 +552,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_023 has failed for ' + err);
expect(null).assertFail();
......@@ -612,7 +612,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_026 has failed for ' + err);
expect(null).assertFail();
......@@ -640,7 +640,7 @@ describe('fileIOTest', function () {
length: 1,
});
expect(null).assertFail();
}
}
catch (err) {
fileio.unlinkSync(fpath);
}
......@@ -667,7 +667,7 @@ describe('fileIOTest', function () {
offset: 1,
});
expect(null).assertFail();
}
}
catch (err) {
fileio.unlinkSync(fpath);
}
......@@ -686,7 +686,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_029 has failed for ' + err);
expect(null).assertFail();
......@@ -716,7 +716,7 @@ describe('fileIOTest', function () {
expect(red !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_030 has failed for ' + err);
expect(null).assertFail();
......@@ -744,7 +744,7 @@ describe('fileIOTest', function () {
length: 1,
});
expect(null).assertFail();
}
}
catch (err) {
fileio.unlinkSync(fpath);
}
......@@ -771,7 +771,7 @@ describe('fileIOTest', function () {
offset: 1,
});
expect(null).assertFail();
}
}
catch (err) {
fileio.unlinkSync(fpath);
}
......@@ -790,7 +790,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_033 has failed for ' + err);
expect(null).assertFail();
......@@ -820,7 +820,7 @@ describe('fileIOTest', function () {
expect(wri !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_034 has failed for ' + err);
expect(null).assertFail();
......@@ -848,7 +848,7 @@ describe('fileIOTest', function () {
length: 1,
});
expect(null).assertFail();
}
}
catch (err) {
fileio.unlinkSync(fpath);
}
......@@ -875,7 +875,7 @@ describe('fileIOTest', function () {
offset: 1,
});
expect(null).assertFail();
}
}
catch (err) {
fileio.unlinkSync(fpath);
}
......@@ -893,7 +893,7 @@ describe('fileIOTest', function () {
let fd = fileio.openSync(fpath, 0o002, 0o001);
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_037 has failed for ' + err);
expect(null).assertFail();
......@@ -911,7 +911,7 @@ describe('fileIOTest', function () {
try {
let fd = fileio.openSync(fpath, 0o102, 0o700);
expect(null).assertFail();
}
}
catch (err) {
console.info('fileio_test_open_038 has failed for ' + err);
}
......@@ -930,7 +930,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_sync_001 has failed for ' + err);
expect(null).assertFail();
......@@ -950,7 +950,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_sync_002 has failed for ' + err);
expect(null).assertFail();
......@@ -970,7 +970,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_sync_003 has failed for ' + err);
expect(null).assertFail();
......@@ -989,7 +989,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_open_sync_004 has failed for ' + err);
expect(null).assertFail();
......@@ -1009,7 +1009,7 @@ describe('fileIOTest', function () {
expect(fd !== null).assertTrue();
fileio.closeSync(fd);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_open_sync_005 has failed for ' + err);
expect(null).assertFail();
......@@ -1040,22 +1040,29 @@ describe('fileIOTest', function () {
* @tc.desc Function of API, openSync(fpath too long).
*/
it('fileio_test_open_sync_007', 0, async function () {
let dpath = await nextFileName('fileio_open1');
let dpath = await nextFileName('fileio_test_open_sync_007');
fileio.mkdirSync(dpath);
try {
for (let i = 0; i < 16; i++) {
if (i == 15) {
let fpath = dpath + '/f' + randomString(248);
let fpath = dpath + '/f' + i;
fileio.openSync(fpath, 0o102, 0o777);
fileio.unlinkSync(fpath);
} else {
dpath = dpath + '/d' + randomString(248);
dpath = dpath + '/d' + i;
fileio.mkdirSync(dpath);
}
}
expect(null).assertFail();
}
}
catch (err) {
console.info('fileio_test_open_sync_007 has failed for ' + err);
for (let i = 15; i >= 0; i--) {
if (i < 15) {
dpath = dpath.replace(`/d${i}`, "");
}
fileio.rmdirSync(dpath);
}
}
});
......@@ -1068,7 +1075,7 @@ describe('fileIOTest', function () {
let fpath = await nextFileName(randomString(256));
try {
fileio.openSync(fpath, 0o102, 0o777);
}
}
catch (err) {
console.info('fileio_test_open_sync_008 has failed for ' + err);
}
......@@ -1080,22 +1087,29 @@ describe('fileIOTest', function () {
* @tc.desc Function of API, openSync(dir layers too long).
*/
it('fileio_test_open_sync_009', 0, async function () {
let dpath = await nextFileName('prop1');
let dpath = await nextFileName('fileio_test_open_sync_009');
fileio.mkdirSync(dpath);
try {
for (let i = 0; i < 113; i++) {
if (i == 112) {
let fpath = dpath + '/f' + i
fileio.openSync(fpath, 0o102, 0o777);
fileio.unlinkSync(fpath);
} else {
dpath = dpath + '/' + i
dpath = dpath + '/d' + i
fileio.mkdirSync(dpath);
}
}
expect(null).assertFail();
}
}
catch (err) {
console.info('fileio_test_open_sync_009 has failed for ' + err);
for (let i = 112; i >= 0; i--) {
if (i < 112) {
dpath = dpath.replace(`/d${i}`, "");
}
fileio.rmdirSync(dpath);
}
}
});
......@@ -1123,7 +1137,7 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_chmod_sync_000');
try {
fileio.closeSync(fpath);
}
}
catch (err) {
console.info('fileio_test_close_sync_000 has failed for ' + err);
expect(err.message == "Invalid fd").assertTrue();
......@@ -1138,7 +1152,7 @@ describe('fileIOTest', function () {
it('fileio_test_close_sync_001', 0, async function () {
try {
fileio.closeSync(-1);
}
}
catch (err) {
console.info('fileio_test_close_sync_001 has failed for ' + err);
expect(err.message == "Bad file descriptor").assertTrue();
......@@ -1156,7 +1170,7 @@ describe('fileIOTest', function () {
try {
fileio.accessSync(fpath);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_access_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -1204,7 +1218,7 @@ describe('fileIOTest', function () {
fileio.accessSync(fpath);
fileio.accessSync(fpath, 1);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_access_sync_004 has failed for ' + err);
expect(null).assertFail();
......@@ -1223,7 +1237,7 @@ describe('fileIOTest', function () {
fileio.accessSync(fpath);
fileio.accessSync(fpath, 2);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_access_sync_004 has failed for ' + err);
expect(null).assertFail();
......@@ -1241,7 +1255,7 @@ describe('fileIOTest', function () {
fileio.mkdirSync(dpath);
fileio.accessSync(dpath);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_access_sync_005 has failed for ' + err);
expect(null).assertFail();
......@@ -1257,7 +1271,7 @@ describe('fileIOTest', function () {
let dpath = await nextFileName('fileio_test_access_sync_006') + 'd'
try {
fileio.accessSync(dpath);
}
}
catch (err) {
console.info('fileio_test_access_sync_006 has failed for ' + err);
expect(err.message == "No such file or directory").assertTrue();
......@@ -1276,7 +1290,7 @@ describe('fileIOTest', function () {
fileio.accessSync(fpath);
fileio.accessSync(fpath, 4);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_access_sync_007 has failed for ' + err);
expect(null).assertFail();
......@@ -1294,10 +1308,10 @@ describe('fileIOTest', function () {
let fd = fileio.access(fpath).then(() => {
expect(fd !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file access Success');
fileio.unlinkSync(fpath);
console.info('file access Success');
}).catch(function(err) {
console.log("file access err: " + JSON.stringify(err));
console.info("file access err: " + JSON.stringify(err));
});
});
......@@ -1311,7 +1325,7 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let fd = fileio.access(fpath, function (err) {
expect(fd !== null).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -1325,7 +1339,7 @@ describe('fileIOTest', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_unlink_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -1341,7 +1355,7 @@ describe('fileIOTest', function () {
try {
fileio.unlinkSync(1);
expect(null).assertFail();
}
}
catch (err) {
console.info('fileio_test_unlink_sync_001 has failed for ' + err);
expect(err.message == "Invalid path").assertTrue();
......@@ -1376,7 +1390,7 @@ describe('fileIOTest', function () {
expect(typeof(res) == 'number').assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_write_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -1398,7 +1412,7 @@ describe('fileIOTest', function () {
expect(typeof(res) == 'number').assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_write_sync_001 has failed for ' + err);
expect(null).assertFail();
......@@ -1420,7 +1434,7 @@ describe('fileIOTest', function () {
}) == text.length - 1).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_write_sync_002 has failed for ' + err);
expect(null).assertFail();
......@@ -1441,7 +1455,7 @@ describe('fileIOTest', function () {
}) == (FILE_CONTENT.length - 1)).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_write_sync_003 has failed for ' + err);
expect(null).assertFail();
......@@ -1464,7 +1478,7 @@ describe('fileIOTest', function () {
expect(typeof(res) == 'number').assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_write_sync_004 has failed for ' + err);
expect(null).assertFail();
......@@ -1487,7 +1501,7 @@ describe('fileIOTest', function () {
offset: invalidOffset,
}) == 1).assertTrue();
expect(null).assertFail();
}
}
catch (err) {
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
......@@ -1510,7 +1524,7 @@ describe('fileIOTest', function () {
length: invalidLength,
}) == 1);
expect(null).assertFail();
}
}
catch (err) {
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
......@@ -1539,7 +1553,7 @@ describe('fileIOTest', function () {
it('fileio_test_write_sync_008', 0, async function () {
try {
fileio.writeSync(-1, FILE_CONTENT);
}
}
catch (err) {
console.info('fileio_test_write_sync_008 has failed for ' + err);
expect(err.message == "Bad file descriptor").assertTrue();
......@@ -1564,7 +1578,7 @@ describe('fileIOTest', function () {
expect(typeof(res) == 'number').assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_write_sync_009 has failed for ' + err);
expect(null).assertFail();
......@@ -1609,7 +1623,7 @@ describe('fileIOTest', function () {
expect(len == bufLen - 1).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_read_sync_001 has failed for ' + err);
expect(null).assertFail();
......@@ -1632,7 +1646,7 @@ describe('fileIOTest', function () {
expect(len == 1).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_read_sync_002 has failed for ' + err);
expect(null).assertFail();
......@@ -1694,7 +1708,7 @@ describe('fileIOTest', function () {
it('fileio_test_read_sync_005', 0, async function () {
try {
fileio.readSync(-1, new ArrayBuffer(4096));
}
}
catch (err) {
console.info('fileio_test_read_sync_005 has failed for ' + err);
expect(err.message == "Bad file descriptor").assertTrue();
......@@ -1717,7 +1731,7 @@ describe('fileIOTest', function () {
expect(len == FILE_CONTENT.length - 1);
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_read_sync_006 has failed for ' + err);
expect(null).assertFail();
......@@ -1740,7 +1754,7 @@ describe('fileIOTest', function () {
});
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_read_sync_007 has failed for ' + err);
expect(null).assertFail();
......@@ -1765,7 +1779,7 @@ describe('fileIOTest', function () {
expect(len == 1).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_read_sync_008 has failed for ' + err);
expect(null).assertFail();
......@@ -1789,7 +1803,7 @@ describe('fileIOTest', function () {
expect(len == 1).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_read_sync_009 has failed for ' + err);
expect(null).assertFail();
......@@ -1831,7 +1845,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o660) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -1850,7 +1864,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o460) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o460).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_001 has failed for ' + err);
expect(null).assertFail();
......@@ -1869,7 +1883,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o260) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o260).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_002 has failed for ' + err);
expect(null).assertFail();
......@@ -1903,7 +1917,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(dpath, 0o660) !== null).assertTrue();
expect((fileio.statSync(dpath).mode & 0o777) == 0o660).assertTrue();
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -1937,7 +1951,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o700) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o700).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_006 has failed for ' + err);
expect(null).assertFail();
......@@ -1956,7 +1970,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o400) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o400).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_002 has failed for ' + err);
expect(null).assertFail();
......@@ -1975,7 +1989,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o200) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o200).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_008 has failed for ' + err);
expect(null).assertFail();
......@@ -1994,7 +2008,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o100) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o100).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_009 has failed for ' + err);
expect(null).assertFail();
......@@ -2013,7 +2027,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o070) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o070).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_010 has failed for ' + err);
expect(null).assertFail();
......@@ -2032,7 +2046,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o040) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o040).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_011 has failed for ' + err);
expect(null).assertFail();
......@@ -2051,7 +2065,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o020) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o020).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_012 has failed for ' + err);
expect(null).assertFail();
......@@ -2070,7 +2084,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o010) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o010).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_013 has failed for ' + err);
expect(null).assertFail();
......@@ -2089,7 +2103,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o007) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o007).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_014 has failed for ' + err);
expect(null).assertFail();
......@@ -2108,7 +2122,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o004) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o004).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_015 has failed for ' + err);
expect(null).assertFail();
......@@ -2127,7 +2141,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o002) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o002).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_016 has failed for ' + err);
expect(null).assertFail();
......@@ -2146,7 +2160,7 @@ describe('fileIOTest', function () {
expect(fileio.chmodSync(fpath, 0o001) !== null).assertTrue();
expect((fileio.statSync(fpath).mode & 0o777) == 0o001).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chmod_sync_017 has failed for ' + err);
expect(null).assertFail();
......@@ -2166,7 +2180,7 @@ describe('fileIOTest', function () {
fileio.copyFileSync(fpath, fpathTarget);
fileio.unlinkSync(fpath);
fileio.unlinkSync(fpathTarget);
}
}
catch (err) {
console.info('fileio_test_copy_file_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -2198,7 +2212,7 @@ describe('fileIOTest', function () {
let fpath = await nextFileName('fileio_test_copy_file_sync_002');
try {
fileio.copyFileSync(fpath, 0);
}
}
catch (err) {
console.info('fileio_test_copy_file_sync_002 has failed for ' + err);
expect(err.message == "No such file or directory").assertTrue();
......@@ -2218,7 +2232,7 @@ describe('fileIOTest', function () {
fileio.copyFileSync(fpath, fpathTarget);
fileio.unlinkSync(fpath);
fileio.unlinkSync(fpathTarget);
}
}
catch (err) {
console.info('fileio_test_copy_file_sync_003 has failed for ' + err);
expect(null).assertFail();
......@@ -2238,7 +2252,7 @@ describe('fileIOTest', function () {
fileio.copyFileSync(fpath, fpathTarget);
fileio.unlinkSync(fpath);
fileio.unlinkSync(fpathTarget);
}
}
catch (err) {
console.info('fileio_test_copy_file_sync_004 has failed for ' + err);
expect(null).assertFail();
......@@ -2257,7 +2271,7 @@ describe('fileIOTest', function () {
try {
fileio.copyFileSync(fpath, fpathTarget);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_copy_file_sync_005 has failed for ' + err);
expect(null).assertFail();
......@@ -2289,7 +2303,7 @@ describe('fileIOTest', function () {
fileio.copyFileSync(-1, -1);
} catch (err) {
console.info('fileio_test_copy_file_sync_007 has failed for ' + err);
expect(err.message == "Invalid argument" || err.message == "Bad file descriptor").assertTrue();
expect(err.message == "Invalid argument").assertTrue();
}
});
......@@ -2301,22 +2315,30 @@ describe('fileIOTest', function () {
it('fileio_test_copy_file_sync_008', 0, async function () {
let fpath = await nextFileName('fileio_test_copy_file_sync_008');
fileio.openSync(fpath, 0o102, 0o777);
let dpath = await nextFileName('fileio_copy1');
let dpath = await nextFileName('fileio_test_copy_file_sync_008') + 'd';
fileio.mkdirSync(dpath);
try {
for (let i = 0; i < 16; i++) {
if (i == 15) {
let fpathTarget = dpath + '/f' + randomString(248);
let fpathTarget = dpath + '/f' + i;
fileio.copyFileSync(fpath, fpathTarget);
fileio.unlinkSync(fpath);
fileio.unlinkSync(fpathTarget);
} else {
dpath = dpath + '/d' + randomString(248);
dpath = dpath + '/d' + i;
fileio.mkdirSync(dpath);
}
}
expect(null).assertFail();
}
}
catch (err) {
console.info('fileio_test_copy_file_sync_008 has failed for ' + err);
for (let i = 15; i >= 0; i--) {
if (i < 15) {
dpath = dpath.replace(`/d${i}`, "");
}
fileio.rmdirSync(dpath);
}
}
});
......@@ -2332,7 +2354,7 @@ describe('fileIOTest', function () {
try {
fileio.copyFileSync(fpath, fpathTarget);
expect(null).assertFail();
}
}
catch (err) {
fileio.unlinkSync(fpath);
console.info('fileio_test_copy_file_sync_009 has failed for ' + err);
......@@ -2347,22 +2369,30 @@ describe('fileIOTest', function () {
it('fileio_test_copy_file_sync_010', 0, async function () {
let fpath = await nextFileName('fileio_test_copy_file_sync_010');
fileio.openSync(fpath, 0o102, 0o777);
let dpath = await nextFileName('prop');
let dpath = await nextFileName('fileio_test_copy_file_sync_010') + 'd';
fileio.mkdirSync(dpath);
try {
for (let i = 0; i < 113; i++) {
if (i == 112) {
let fpathTarget = dpath + '/f' + i
fileio.copyFileSync(fpath, fpathTarget);
fileio.unlinkSync(fpath);
fileio.unlinkSync(fpathTarget);
} else {
dpath = dpath + '/' + i
dpath = dpath + '/d' + i
fileio.mkdirSync(dpath);
}
}
expect(null).assertFail();
}
}
catch (err) {
fileio.unlinkSync(fpath);
console.info('fileio_test_copy_file_sync_010 has failed for ' + err);
for (let i = 112; i >= 0; i--) {
if (i < 112) {
dpath = dpath.replace(`/d${i}`, "");
}
fileio.rmdirSync(dpath);
}
}
});
......@@ -2377,7 +2407,7 @@ describe('fileIOTest', function () {
let fpathTarget = await nextFileName('?*:<>/|');
try {
fileio.copyFileSync(fpath, fpathTarget);
}
}
catch (err) {
fileio.unlinkSync(fpath);
console.info('fileio_test_copy_file_sync_011 has failed for ' + err);
......@@ -2398,7 +2428,7 @@ describe('fileIOTest', function () {
fileio.copyFileSync(fpath, fpathTarget, 0);
fileio.unlinkSync(fpath);
fileio.unlinkSync(fpathTarget);
}
}
catch (err) {
console.info('fileio_test_copy_file_sync_012 has failed for ' + err);
expect(null).assertFail();
......@@ -2410,17 +2440,17 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_copy_file_async_001
* @tc.desc Function of API, copy. fpatch is vaild, fpathTarget is vaild, same path, file not same, mode is 0.
*/
it('fileio_test_copy_file_async_001', 0, async function () {
it('fileio_test_copy_file_async_001', 0, async function () {
let fpath = await nextFileName('fileio_test_copy_file_async_001');
let fpathTarget = fpath + 'tgt'
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
await fileio.copyFile(fpath, fpathTarget).then(()=> {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
expect(fileio.unlinkSync(fpathTarget) !== null).assertTrue();
console.log('fileio_test_copy_file_async_001 Success');
console.info('fileio_test_copy_file_async_001 Success');
}).catch((err) => {
console.log("fileio_test_copy_file_async_001 err: " + JSON.stringify(err));
console.info("fileio_test_copy_file_async_001 err: " + JSON.stringify(err));
});
});
......@@ -2436,7 +2466,7 @@ describe('fileIOTest', function () {
expect(fileio.truncateSync(fpath, 10) !== null).assertTrue();
expect(fileio.statSync(fpath).size == 10).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_truncate_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -2501,7 +2531,7 @@ describe('fileIOTest', function () {
fileio.renameSync(fpath, fpathTarget);
fileio.accessSync(fpathTarget);
fileio.unlinkSync(fpathTarget);
}
}
catch (err) {
console.info('fileio_test_rename_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -2511,7 +2541,7 @@ describe('fileIOTest', function () {
/**
* @tc.number SUB_STORAGE_FileIO_RenameSync_0100
* @tc.name fileio_test_rename_sync_001
* @tc.desc Function of API, renameSync. The test file is not exist,
* @tc.desc Function of API, renameSync. The test file is not exist,
* fpathTarget is not same with fpatch, file name are same.
*/
it('fileio_test_rename_sync_001', 0, async function () {
......@@ -2555,7 +2585,7 @@ describe('fileIOTest', function () {
console.info('fileio_test_rename_sync_003 Test start');
fileio.renameSync(fpath, fpath);
expect(null).assertFail();
}
}
catch (err) {
fileio.unlinkSync(fpath);
}
......@@ -2570,7 +2600,7 @@ describe('fileIOTest', function () {
try {
fileio.renameSync(1, 1);
expect(null).assertFail();
}
}
catch (err) {
console.info('fileio_test_rename_sync_004 pass. ' + err);
}
......@@ -2587,7 +2617,7 @@ describe('fileIOTest', function () {
try {
fileio.renameSync(fpath, 1);
expect(null).assertFail();
}
}
catch (err) {
fileio.unlinkSync(fpath);
console.info('fileio_test_rename_sync_005 pass. ' + err);
......@@ -2607,7 +2637,7 @@ describe('fileIOTest', function () {
fileio.renameSync(dpath, dpathTarget);
fileio.accessSync(dpathTarget);
fileio.rmdirSync(dpathTarget);
}
}
catch (err) {
console.info('fileio_test_rename_sync_006 has failed for ' + err);
expect(null).assertFail();
......@@ -2660,7 +2690,7 @@ describe('fileIOTest', function () {
fileio.renameSync(dpath, dpath);
fileio.accessSync(dpath);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_rename_sync_009 has failed for ' + err);
expect(null).assertFail();
......@@ -2680,7 +2710,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o660);
expect((fileio.statSync(fpath).mode & 0o777) == 0o660).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -2700,7 +2730,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o460);
expect((fileio.statSync(fpath).mode & 0o777) == 0o460).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_001 has failed for ' + err);
expect(null).assertFail();
......@@ -2720,7 +2750,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o260);
expect((fileio.statSync(fpath).mode & 0o777) == 0o260).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_002 has failed for ' + err);
expect(null).assertFail();
......@@ -2754,7 +2784,7 @@ describe('fileIOTest', function () {
let fd = fileio.openSync(fpath);
fileio.fchmodSync(fd, 2222222222222);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_004 has failed for A' + err);
expect(null).assertFail();
......@@ -2774,7 +2804,7 @@ describe('fileIOTest', function () {
console.info(fd);
fileio.fchmodSync(fd, 0o660);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_005 has failed for ' + err);
expect(null).assertFail();
......@@ -2790,7 +2820,7 @@ describe('fileIOTest', function () {
let dpath;
try {
fileio.fchmodSync(dpath, 0o660);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_006 has failed for ' + err);
expect(err.message == "Invalid fd").assertTrue();
......@@ -2810,7 +2840,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o700);
expect((fileio.statSync(fpath).mode & 0o777) == 0o700).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_007 has failed for ' + err);
expect(null).assertFail();
......@@ -2830,7 +2860,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o400);
expect((fileio.statSync(fpath).mode & 0o777) == 0o400).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_008 has failed for ' + err);
expect(null).assertFail();
......@@ -2850,7 +2880,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o200);
expect((fileio.statSync(fpath).mode & 0o777) == 0o200).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_009 has failed for ' + err);
expect(null).assertFail();
......@@ -2870,7 +2900,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o100);
expect((fileio.statSync(fpath).mode & 0o777) == 0o100).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_010 has failed for ' + err);
expect(null).assertFail();
......@@ -2890,7 +2920,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o070);
expect((fileio.statSync(fpath).mode & 0o777) == 0o070).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_011 has failed for ' + err);
expect(null).assertFail();
......@@ -2910,7 +2940,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o040);
expect((fileio.statSync(fpath).mode & 0o777) == 0o040).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_012 has failed for ' + err);
expect(null).assertFail();
......@@ -2930,7 +2960,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o020);
expect((fileio.statSync(fpath).mode & 0o777) == 0o020).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_013 has failed for ' + err);
expect(null).assertFail();
......@@ -2950,7 +2980,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o010);
expect((fileio.statSync(fpath).mode & 0o777) == 0o010).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_014 has failed for ' + err);
expect(null).assertFail();
......@@ -2970,7 +3000,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o007);
expect((fileio.statSync(fpath).mode & 0o777) == 0o007).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_015 has failed for ' + err);
expect(null).assertFail();
......@@ -2990,7 +3020,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o004);
expect((fileio.statSync(fpath).mode & 0o777) == 0o004).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_016 has failed for ' + err);
expect(null).assertFail();
......@@ -3010,7 +3040,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o002);
expect((fileio.statSync(fpath).mode & 0o777) == 0o002).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_017 has failed for ' + err);
expect(null).assertFail();
......@@ -3030,7 +3060,7 @@ describe('fileIOTest', function () {
fileio.fchmodSync(fd, 0o001);
expect((fileio.statSync(fpath).mode & 0o777) == 0o001).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchmod_sync_018 has failed for ' + err);
expect(null).assertFail();
......@@ -3050,7 +3080,7 @@ describe('fileIOTest', function () {
fileio.ftruncateSync(fd, 10);
expect(fileio.statSync(fpath).size == 10).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_ftruncate_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -3070,7 +3100,7 @@ describe('fileIOTest', function () {
fileio.ftruncateSync(fd);
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_ftruncate_sync_001 has failed for ' + err);
expect(null).assertFail();
......@@ -3119,6 +3149,7 @@ describe('fileIOTest', function () {
}catch (err) {
console.info('fileio_test_ftruncate_sync_004 has failed for ' + err);
expect(err.message == "Invalid argument").assertTrue();
fileio.unlinkSync(fpath);
}
});
......@@ -3135,7 +3166,7 @@ describe('fileIOTest', function () {
expect(fileio.fsyncSync(fd) !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fsync_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -3150,7 +3181,7 @@ describe('fileIOTest', function () {
it('fileio_test_fsync_sync_001', 0, async function () {
try {
fileio.fsyncSync(1);
}
}
catch (err) {
console.info('fileio_test_fsync_sync_001 has failed for ' + err);
expect(err.message == "Invalid argument").assertTrue();
......@@ -3165,7 +3196,7 @@ describe('fileIOTest', function () {
it('fileio_test_fsync_sync_002', 0, async function () {
try {
fileio.fsyncSync(-1);
}
}
catch (err) {
console.info('fileio_test_fsync_sync_002 has failed for ' + err);
expect(err.message == "Bad file descriptor").assertTrue();
......@@ -3182,7 +3213,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -3199,7 +3230,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o660);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_001 has failed for ' + err);
expect(null).assertFail();
......@@ -3216,7 +3247,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o460);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_002 has failed for ' + err);
expect(null).assertFail();
......@@ -3233,7 +3264,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o260);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_003 has failed for ' + err);
expect(null).assertFail();
......@@ -3262,7 +3293,7 @@ describe('fileIOTest', function () {
it('fileio_test_mkdir_sync_rmdir_sync_005', 0, async function () {
try {
fileio.mkdirSync('/', 1);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_005 has failed for ' + err);
expect(err.message == "File exists").assertTrue();
......@@ -3279,7 +3310,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o700);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_006 has failed for ' + err);
expect(null).assertFail();
......@@ -3296,7 +3327,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o400);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_007 has failed for ' + err);
expect(null).assertFail();
......@@ -3313,7 +3344,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o200);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_008 has failed for ' + err);
expect(null).assertFail();
......@@ -3330,7 +3361,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o100);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_009 has failed for ' + err);
expect(null).assertFail();
......@@ -3347,7 +3378,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o070);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_010 has failed for ' + err);
expect(null).assertFail();
......@@ -3364,7 +3395,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o040);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_011 has failed for ' + err);
expect(null).assertFail();
......@@ -3381,7 +3412,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o020);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_012 has failed for ' + err);
expect(null).assertFail();
......@@ -3398,7 +3429,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o010);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_013 has failed for ' + err);
expect(null).assertFail();
......@@ -3415,7 +3446,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o007);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_014 has failed for ' + err);
expect(null).assertFail();
......@@ -3432,7 +3463,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o004);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_015 has failed for ' + err);
expect(null).assertFail();
......@@ -3449,7 +3480,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o002);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_016 has failed for ' + err);
expect(null).assertFail();
......@@ -3466,7 +3497,7 @@ describe('fileIOTest', function () {
try {
fileio.mkdirSync(dpath, 0o001);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_mkdir_sync_rmdir_sync_017 has failed for ' + err);
expect(null).assertFail();
......@@ -3487,7 +3518,7 @@ describe('fileIOTest', function () {
expect(stat !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fstat_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -3537,7 +3568,7 @@ describe('fileIOTest', function () {
expect(stat !== null).assertTrue();
fileio.closeSync(fd);
fileio.rmdirSync(dpath);
}
}
catch (err) {
console.info('fileio_test_fstat_sync_003 has failed for ' + err);
expect(null).assertFail();
......@@ -3558,7 +3589,7 @@ describe('fileIOTest', function () {
try {
expect(fileio.chownSync(fpath, UID, GID) !== null).assertTrue();
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_chown_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -3619,7 +3650,7 @@ describe('fileIOTest', function () {
expect(fileio.fchownSync(fd, UID, GID) !== null).assertTrue();
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_fchown_sync_000 has failed for ' + err);
expect(null).assertFail();
......@@ -3661,7 +3692,7 @@ describe('fileIOTest', function () {
try {
let fd = fileio.openSync(fpath);
fileio.fchownSync(fd, null, GID);
}
}
catch (err) {
fileio.unlinkSync(fpath);
console.info('fileio_test_fchown_sync_002 has failed for ' + err);
......@@ -3683,7 +3714,7 @@ describe('fileIOTest', function () {
try {
fd = fileio.openSync(fpath, 0o2);
expect(fileio.fchownSync(fd, UID, 0));
}
}
catch (err) {
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
......@@ -3706,7 +3737,7 @@ describe('fileIOTest', function () {
let fd = null
try {
expect(fileio.fchownSync(fd, UID, GID));
}
}
catch (err) {
fileio.unlinkSync(fpath);
console.info('fileio_test_fchown_sync_004 has failed for ' + err);
......@@ -3730,7 +3761,7 @@ describe('fileIOTest', function () {
try {
fd = fileio.openSync(fpath);
expect(fileio.fchownSync(fd, UID, GID));
}
}
catch (err) {
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
......@@ -3753,7 +3784,7 @@ describe('fileIOTest', function () {
try {
fd = fileio.openSync(fpath);
fileio.fchownSync(fd, UID, 0);
}
}
catch (err) {
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
......@@ -3774,7 +3805,7 @@ describe('fileIOTest', function () {
try {
fd = fileio.openSync(fpath, 0o2);
fileio.fchownSync(fd, 0, 0);
}
}
catch (err) {
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
......@@ -3800,7 +3831,7 @@ describe('fileIOTest', function () {
expect(rlen == 4096).assertTrue();
fileio.closeSync(fd1);
fileio.unlinkSync(fpath);
}
}
catch (err) {
console.info('fileio_test_prop_write_open_read_4k_sync has failed for ' + err);
expect(null).assertFail();
......@@ -3823,7 +3854,7 @@ describe('fileIOTest', function () {
fileio.copyFileSync(fpath, fpath1);
fileio.unlinkSync(fpath);
fileio.unlinkSync(fpath1);
}
}
catch (err) {
console.info('fileio_test_prop_copyFile_4k_sync has failed for ' + err);
expect(null).assertFail();
......@@ -3838,13 +3869,13 @@ describe('fileIOTest', function () {
it('fileio_test_stat_promise_000', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o660) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o660);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o660).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -3853,16 +3884,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_001
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_001', 0, async function () {
it('fileio_test_stat_promise_001', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o777) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o777);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o777).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -3871,16 +3902,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_002
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_002', 0, async function () {
it('fileio_test_stat_promise_002', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o774) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o774);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o774).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -3889,16 +3920,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_003
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_003', 0, async function () {
it('fileio_test_stat_promise_003', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o772) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o772);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o772).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -3907,16 +3938,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_004
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_004', 0, async function () {
it('fileio_test_stat_promise_004', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o771) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o771);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o771).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -3925,16 +3956,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_005
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_005', 0, async function () {
it('fileio_test_stat_promise_005', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o770) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o770);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o770).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -3943,16 +3974,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_006
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_006', 0, async function () {
it('fileio_test_stat_promise_006', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o666) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o666);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o666).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -3961,16 +3992,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_007
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_007', 0, async function () {
it('fileio_test_stat_promise_007', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o664) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o664);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o664).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -3979,16 +4010,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_008
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_008', 0, async function () {
it('fileio_test_stat_promise_008', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_008');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o662) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o662);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o662).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -3997,16 +4028,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_009
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_009', 0, async function () {
it('fileio_test_stat_promise_009', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_009');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o661) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o661);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o661).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -4015,16 +4046,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_010
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_010', 0, async function () {
it('fileio_test_stat_promise_010', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_010');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o660) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o660);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o660).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -4033,16 +4064,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_011
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_011', 0, async function () {
it('fileio_test_stat_promise_011', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_011');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o640) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o640);
await fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o640).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -4051,16 +4082,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_012
* @tc.desc obtain file propertys by stat promise
*/
it('fileio_test_stat_promise_012', 0, async function () {
it('fileio_test_stat_promise_012', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_promise_012');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o600) !== null).assertTrue();
let stat = await fileio.stat(fpath).then(()=> {
fileio.chmodSync(fpath, 0o600);
fileio.stat(fpath).then((stat)=> {
expect((stat.mode & 0o777) == 0o600).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
console.log('file stat Success');
fileio.unlinkSync(fpath);
console.info('file stat Success');
}).catch((err) => {
console.log("file stat err: " + JSON.stringify(err));
console.info("file stat err: " + JSON.stringify(err));
});
});
......@@ -4072,10 +4103,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_013', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_013');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o660) !== null).assertTrue();
fileio.chmodSync(fpath, 0o660);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o660).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4087,10 +4118,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_014', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_014');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o777) !== null).assertTrue();
fileio.chmodSync(fpath, 0o777);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o777).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4102,10 +4133,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_015', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_015');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o776) !== null).assertTrue();
fileio.chmodSync(fpath, 0o776);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o776).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4117,10 +4148,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_016', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_016');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o774) !== null).assertTrue();
fileio.chmodSync(fpath, 0o774);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o774).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4132,10 +4163,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_017', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_017');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o772) !== null).assertTrue();
fileio.chmodSync(fpath, 0o772);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o772).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4147,10 +4178,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_018', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_018');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o771) !== null).assertTrue();
fileio.chmodSync(fpath, 0o771);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o771).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4162,10 +4193,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_019', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_019');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o770) !== null).assertTrue();
fileio.chmodSync(fpath, 0o770);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o770).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4177,10 +4208,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_020', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_020');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o666) !== null).assertTrue();
fileio.chmodSync(fpath, 0o666);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o666).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4192,10 +4223,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_021', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_021');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o664) !== null).assertTrue();
fileio.chmodSync(fpath, 0o664);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o664).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4207,10 +4238,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_022', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_022');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o662) !== null).assertTrue();
fileio.chmodSync(fpath, 0o662);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o662).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4222,10 +4253,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_023', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_023');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o640) !== null).assertTrue();
fileio.chmodSync(fpath, 0o640);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o640).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4237,10 +4268,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_024', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_024');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o600) !== null).assertTrue();
fileio.chmodSync(fpath, 0o600);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o600).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4252,10 +4283,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_025', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_025');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o400) !== null).assertTrue();
fileio.chmodSync(fpath, 0o400);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o400).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4267,10 +4298,10 @@ describe('fileIOTest', function () {
it('fileio_test_stat_async_026', 0, async function () {
let fpath = await nextFileName('fileio_test_stat_async_026');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
expect(fileio.chmodSync(fpath, 0o200) !== null).assertTrue();
fileio.chmodSync(fpath, 0o200);
fileio.stat(fpath, function (err, stat) {
expect((stat.mode & 0o777) == 0o200).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
......@@ -4285,7 +4316,7 @@ describe('fileIOTest', function () {
let fd = fileio.openSync(fpath);
expect(fd !== null).assertTrue();
await fileio.close(fd);
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
/**
......@@ -4293,12 +4324,12 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_close_async_001
* @tc.desc Function of API close
*/
it('fileio_test_close_async_001', 0, async function () {
it('fileio_test_close_async_001', 0, async function () {
let fpath = await nextFileName('fileio_test_close_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let fd = fileio.openSync(fpath);
await fileio.close(fd, function (err) {
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
fileio.unlinkSync(fpath);
});
});
});
\ No newline at end of file
......@@ -40,7 +40,7 @@ describe('fileIOTestDir', function () {
fileio.rmdirSync(dpath);
}
catch (e) {
console.log('fileio_test_dir_open_sync_000 has failed for ' + e);
console.info('fileio_test_dir_open_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -56,7 +56,7 @@ describe('fileIOTestDir', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_dir_open_sync_001 has failed for ' + e);
console.info('fileio_test_dir_open_sync_001 has failed for ' + e);
}
});
......@@ -72,7 +72,7 @@ describe('fileIOTestDir', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_dir_open_sync_002 has failed for ' + e);
console.info('fileio_test_dir_open_sync_002 has failed for ' + e);
expect(e.message == 'No such file or directory').assertTrue();
}
});
......@@ -87,14 +87,20 @@ describe('fileIOTestDir', function () {
fileio.mkdirSync(dpath);
try {
for (let i = 0; i < 16; i++) {
console.log('time' + i);
dpath = dpath + '/f' + randomString(248);
console.info('time' + i);
dpath = dpath + '/d' + i;
fileio.mkdirSync(dpath);
}
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_dir_open_sync_003 has failed for ' + e);
console.info('fileio_test_dir_open_sync_003 has failed for ' + e);
for (let i = 16; i >= 0; i--) {
if (i < 16) {
dpath = dpath.replace(`/d${i}`, "");
}
fileio.rmdirSync(dpath);
}
}
});
......@@ -110,7 +116,7 @@ describe('fileIOTestDir', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_dir_open_sync_004 has failed for ' + e);
console.info('fileio_test_dir_open_sync_004 has failed for ' + e);
}
});
......@@ -123,15 +129,21 @@ describe('fileIOTestDir', function () {
let dpath = await nextFileName('fileio_test_dir_open_sync_005');
fileio.mkdirSync(dpath);
try {
for (let i = 0; i < 1024; i++) {
console.log('time' + i);
dpath = dpath + '/' + i
for (let i = 0; i < 113; i++) {
console.info('time' + i);
dpath = dpath + '/d' + i
fileio.mkdirSync(dpath);
}
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_dir_open_sync_005 has failed for ' + e);
console.info('fileio_test_dir_open_sync_005 has failed for ' + e);
for (let i = 113; i >= 0; i--) {
if (i < 113) {
dpath = dpath.replace(`/d${i}`, "");
}
fileio.rmdirSync(dpath);
}
}
});
......@@ -147,7 +159,7 @@ describe('fileIOTestDir', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_dir_open_sync_006 has failed for ' + e);
console.info('fileio_test_dir_open_sync_006 has failed for ' + e);
expect(e.message == 'No such file or directory').assertTrue();
}
});
......@@ -157,13 +169,13 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_open_async_001
* @tc.desc Function of API, file name contain special character.
*/
it('fileio_test_dir_open_async_001', 0, async function () {
it('fileio_test_dir_open_async_001', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_open_async_001') + 'd'
expect(fileio.mkdirSync(dpath) !== null).assertTrue();
fileio.mkdirSync(dpath);
fileio.opendir(dpath, function (err, dir) {
expect(dir !== null).assertTrue();
expect(dir.closeSync() == null).assertTrue();
expect(fileio.rmdirSync(dpath) !== null).assertTrue();
dir.closeSync();
fileio.rmdirSync(dpath);
});
});
......@@ -174,14 +186,14 @@ describe('fileIOTestDir', function () {
*/
it('fileio_test_dir_open_async_002', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_open_async_002') + 'd'
expect(fileio.mkdirSync(dpath) !== null).assertTrue();
let dir = await fileio.opendir(dpath).then(()=> {
fileio.mkdirSync(dpath);
fileio.opendir(dpath).then((dir)=> {
expect(dir !== null).assertTrue();
expect(dir.closeSync() == null).assertTrue();
expect(fileio.rmdirSync(dpath) !== null).assertTrue();
console.log('fileio opendir Success');
dir.closeSync();
fileio.rmdirSync(dpath);
console.info('fileio opendir Success');
}).catch((err) => {
console.log("fileio opendir err: " + JSON.stringify(err));
console.info("fileio opendir err: " + JSON.stringify(err));
});
});
......@@ -204,7 +216,7 @@ describe('fileIOTestDir', function () {
fileio.rmdirSync(dpath);
}
catch (e) {
console.log('fileio_test_dir_read_sync_000 has failed for ' + e);
console.info('fileio_test_dir_read_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -231,7 +243,7 @@ describe('fileIOTestDir', function () {
for (let i = 0; i < 3; i++) {
let bool = typeof (dd.readSync());
expect(bool == 'object').assertTrue();
console.log('---bool=' + bool);
console.info('---bool=' + bool);
}
dd.closeSync();
for (let i = 0; i < 3; i++) {
......@@ -244,7 +256,7 @@ describe('fileIOTestDir', function () {
fileio.rmdirSync(dpath);
}
catch (e) {
console.log('fileio_test_dir_read_sync_001 has failed for ' + e);
console.info('fileio_test_dir_read_sync_001 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -283,7 +295,7 @@ describe('fileIOTestDir', function () {
fileio.rmdirSync(dpath);
}
catch (e) {
console.log('fileio_test_dir_read_sync_002 has failed for ' + e);
console.info('fileio_test_dir_read_sync_002 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -305,7 +317,7 @@ describe('fileIOTestDir', function () {
fileio.rmdirSync(dpath);
}
catch (e) {
console.log('fileio_test_dir_read_sync_003 has failed for ' + e);
console.info('fileio_test_dir_read_sync_003 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -328,7 +340,7 @@ describe('fileIOTestDir', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_dir_read_sync_004 has failed for ' + e);
console.info('fileio_test_dir_read_sync_004 has failed for ' + e);
expect(e.message == 'Number of arguments unmatched').assertTrue();
dd.closeSync();
fileio.unlinkSync(fpath);
......@@ -359,7 +371,7 @@ describe('fileIOTestDir', function () {
fileio.rmdirSync(dpath);
}
catch (e) {
console.log('fileio_test_dir_read_sync_005 has failed for ' + e);
console.info('fileio_test_dir_read_sync_005 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -379,7 +391,7 @@ describe('fileIOTestDir', function () {
fileio.rmdirSync(dpath);
}
catch (e) {
console.log('fileio_test_dir_close_sync_000 has failed for ' + e);
console.info('fileio_test_dir_close_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -399,7 +411,7 @@ describe('fileIOTestDir', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_dir_close_sync_001 has failed for ' + e);
console.info('fileio_test_dir_close_sync_001 has failed for ' + e);
expect(e.message == 'Dir has been closed yet').assertTrue();
fileio.rmdirSync(dpath);
}
......
......@@ -170,6 +170,7 @@ describe('fileio_copyfile', function () {
fileio
.copyFile(1, fpath)
.then(function (err) {
fileio.unlinkSync(fpath);
done();
})
} catch (e) {
......
......@@ -134,11 +134,12 @@ describe('fileio_createStream', function () {
try {
fileio.createStream(fpath, 'ohos', function (err) {
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
expect(!!e).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
console.info("fileio_test_stream_create_stream_async_004 has failed for " + e);
fileio.unlinkSync(fpath);
done();
}
});
......
......@@ -85,17 +85,13 @@ describe('fileio_fdatasync', async function () {
* @tc.require
*/
it('fileio_test_fdatasync_async_002', 0, async function (done) {
let fpath = await nextFileName('fileio_test_fdatasync_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = -1;
await fileio.fdatasync(fd);
expect(null).assertFail();
done()
} catch (e) {
expect(!!e).assertTrue();
console.log('fileio_test_fdatasync_async_002 has failed for ' + e);
console.info('fileio_test_fdatasync_async_002 has failed for ' + e);
done();
}
});
......
......@@ -508,18 +508,11 @@ describe('fileio_read', function () {
* @tc.require
*/
it('fileio_test_read_async_008', 0, async function (done) {
let fpath = await nextFileName('fileio_test_read_async_008');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let err = await fileio.read(-1, new ArrayBuffer(4096));
expect(!!err).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
await fileio.read(-1, new ArrayBuffer(4096));
expect(null).assertFail();
done();
} catch (e) {
console.log('fileio_test_read_async_008 has failed for ' + e);
expect(!!e).assertTrue();
console.info('fileio_test_read_async_008 has failed for ' + e);
done();
}
});
......
......@@ -35,11 +35,11 @@ describe('fileio_symlink', function () {
try {
fileio.symlinkSync(fpath, fpath + 'aaaa');
expect(fileio.accessSync(fpath + 'aaaa') == null).assertTrue();
fileio.unlinkSync(fpath + 'aaaa');
fileio.accessSync(fpath + 'aaaa');
expect(null).assertFail();
} catch (e) {
console.log('fileio_test_symlink_sync_000 has failed for ' + e);
console.info('fileio_test_symlink_sync_000 has failed for ' + e);
fileio.unlinkSync(fpath + 'aaaa');
}
});
......@@ -58,18 +58,14 @@ describe('fileio_symlink', function () {
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio
.symlink(fpath, fpath + '1067')
.then(function (err) {
expect(fileio.accessSync(fpath + '1067') == null).assertTrue();
fileio.unlinkSync(fpath + '1067');
expect(err == null).assertTrue();
})
.catch(function (e) {
expect(e == null).assertTrue();
});
fileio.symlink(fpath, fpath + '1067').then(function (err) {
fileio.accessSync(fpath + '1067');
fileio.unlinkSync(fpath);
fileio.unlinkSync(fpath + '1067');
})
done();
} catch (e) {
console.info('fileio_test_symlink_async_000 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -85,16 +81,18 @@ describe('fileio_symlink', function () {
* @tc.require
*/
it('fileio_test_symlink_async_001', 0, async function (done) {
let fpath = await nextFileName('fileio_test_symlink_async_010');
let fpath = await nextFileName('fileio_test_symlink_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
await fileio.symlink(fpath, fpath + 'pass2', function (err) {
expect(fileio.accessSync(fpath + 'pass2') == null).assertTrue();
fileio.accessSync(fpath + 'pass2');
fileio.unlinkSync(fpath);
fileio.unlinkSync(fpath + 'pass2');
done();
});
} catch (e) {
console.info('fileio_test_symlink_async_001 has failed for ' + e);
expect(null).assertFail();
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册