提交 b110bf0c 编写于 作者: 1 18721213663

fix_fs_close

Signed-off-by: N18721213663 <zhuhongtao12@huawei.com>
上级 4e43ce23
......@@ -37,10 +37,10 @@ describe('fileIO_fs_close', function () {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
fileIO.closeSync(file.fd);
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_close_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
......@@ -64,6 +64,7 @@ describe('fileIO_fs_close', function () {
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_close_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
......@@ -183,7 +184,6 @@ describe('fileIO_fs_close', function () {
console.log('fileIO_test_close_async_000 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
});
......@@ -240,7 +240,6 @@ describe('fileIO_fs_close', function () {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
await fileIO.close(file.fd);
await fileIO.close(file);
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......
......@@ -44,7 +44,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(false).assertTrue();
} catch (e) {
fpr.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -94,7 +93,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fpr.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fdopenstream_sync_002 has failed for ' + e.message + ', code: ' + e.code);
......@@ -201,7 +199,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(false).assertTrue();
} catch (e) {
fpw.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -234,8 +231,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
let fpr = fileIO.fdopenStreamSync(file2.fd, 'r');
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpr.closeSync();
fileIO.closeSync(file1);
fileIO.closeSync(file2);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fdopenstream_sync_007 has failed for ' + e.message + ', code: ' + e.code);
......@@ -265,7 +260,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(fpw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpw.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fdopenstream_sync_008 has failed for ' + e.message + ', code: ' + e.code);
......@@ -299,8 +293,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
let fpr = fileIO.fdopenStreamSync(file2.fd, 'r');
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
fpr.closeSync();
fileIO.closeSync(file1);
fileIO.closeSync(file2);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fdopenstream_sync_009 has failed for ' + e.message + ', code: ' + e.code);
......@@ -332,7 +324,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(false).assertTrue();
} catch (e) {
fpa.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_sync_010 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -361,7 +352,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
fpa.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_fdopenstream_sync_011 has failed for ' + e.message + ', code: ' + e.code);
......@@ -393,7 +383,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(false).assertTrue();
} catch (e) {
fpr.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -428,7 +417,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
fpr.write(FILE_CONTENT, (err) => {
if (err) {
fpr.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log(
'fileIO_test_fdopenstream_async_001 error: {message: ' + err.message + ', code: ' + err.code + '}'
......@@ -513,7 +501,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpr.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -548,7 +535,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(fpr.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpr.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
});
......@@ -578,7 +564,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
await fileIO.fdopenStream(file.fd, 'ohos');
expect(false).assertTrue();
} catch (e) {
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......@@ -606,7 +591,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
await fileIO.fdopenStream(file.fd);
expect(false).assertTrue();
} catch (e) {
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
......@@ -638,7 +622,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(false).assertTrue();
} catch (e) {
fpw.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_async_008 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -673,7 +656,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
fpw.read(new ArrayBuffer(4096), (err) => {
if (err) {
fpw.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log(
'fileIO_test_fdopenstream_async_009 error: {message: ' + err.message + ', code: ' + err.code + '}'
......@@ -716,8 +698,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
let fpr = await fileIO.fdopenStream(file2.fd, 'r');
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpr.closeSync();
fileIO.closeSync(file1);
fileIO.closeSync(file2);
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -748,7 +728,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(fpw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpw.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -783,7 +762,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(fpw.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpw.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length).assertTrue();
fpw.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
});
......@@ -818,8 +796,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
let fpr = await fileIO.fdopenStream(file2.fd, 'r');
expect(fpr.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
fpr.closeSync();
fileIO.closeSync(file1);
fileIO.closeSync(file2);
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -852,7 +828,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(false).assertTrue();
} catch (e) {
fpa.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_async_014 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900005 && e.message == 'I/O error').assertTrue();
......@@ -887,7 +862,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
fpa.read(new ArrayBuffer(4096), (err) => {
if (err) {
fpa.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log(
'fileIO_test_fdopenstream_async_015 error: {message: ' + err.message + ', code: ' + err.code + '}'
......@@ -927,7 +901,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
fpa.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
} catch (e) {
......@@ -962,7 +935,6 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect(fpa.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(fpa.readSync(new ArrayBuffer(4096)) == FILE_CONTENT.length * 2).assertTrue();
fpa.closeSync();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
done();
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册