提交 b110bf0c 编写于 作者: 1 18721213663

fix_fs_close

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