未验证 提交 51c1dc0c 编写于 作者: O openharmony_ci 提交者: Gitee

!8263 【回合3.2】bugfix 用例File对象资源未清理

Merge pull request !8263 from zhuhongtao666/bugfix2_330
...@@ -37,6 +37,7 @@ describe('fileIO_fs_close', function () { ...@@ -37,6 +37,7 @@ 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);
...@@ -82,8 +83,9 @@ describe('fileIO_fs_close', function () { ...@@ -82,8 +83,9 @@ 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); let fd = file.fd;
fileIO.closeSync(file.fd); fileIO.closeSync(file);
fileIO.closeSync(fd);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
...@@ -181,6 +183,7 @@ describe('fileIO_fs_close', function () { ...@@ -181,6 +183,7 @@ 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();
}); });
...@@ -207,7 +210,7 @@ describe('fileIO_fs_close', function () { ...@@ -207,7 +210,7 @@ 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.close(file, (err) => { fileIO.close(file, (err) => {
if(err) { if (err) {
console.log('fileIO_test_close_async_001 error package: ' + JSON.stringify(err)); console.log('fileIO_test_close_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue(); expect(false).assertTrue();
} }
...@@ -237,6 +240,7 @@ describe('fileIO_fs_close', function () { ...@@ -237,6 +240,7 @@ 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) {
...@@ -286,8 +290,9 @@ describe('fileIO_fs_close', function () { ...@@ -286,8 +290,9 @@ 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); let fd = file.fd;
await fileIO.close(file.fd); await fileIO.close(file);
await fileIO.close(fd);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
...@@ -337,12 +342,13 @@ describe('fileIO_fs_close', function () { ...@@ -337,12 +342,13 @@ describe('fileIO_fs_close', function () {
it('fileIO_test_close_async_006', 0, async function (done) { it('fileIO_test_close_async_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_close_async_006'); let fpath = await nextFileName('fileIO_test_close_async_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
try { try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
await fileIO.close(file.fd, 2); await fileIO.close(file.fd, 2);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileIO.closeSync(file);
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
console.log('fileIO_test_close_async_006 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_close_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();
......
...@@ -44,6 +44,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -44,6 +44,7 @@ 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();
...@@ -93,6 +94,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -93,6 +94,7 @@ 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);
...@@ -141,6 +143,8 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -141,6 +143,8 @@ describe('fileIO_fs_FdOpenStream', async function () {
fileIO.fdopenStreamSync(file.fd, 'ohos'); fileIO.fdopenStreamSync(file.fd, 'ohos');
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_sync_004 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdopenstream_sync_004 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();
} }
...@@ -166,6 +170,8 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -166,6 +170,8 @@ describe('fileIO_fs_FdOpenStream', async function () {
fileIO.fdopenStreamSync(file.fd); fileIO.fdopenStreamSync(file.fd);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (e) { } catch (e) {
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
console.log('fileIO_test_fdopenstream_sync_005 has failed for ' + e.message + ', code: ' + e.code); console.log('fileIO_test_fdopenstream_sync_005 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();
} }
...@@ -195,6 +201,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -195,6 +201,7 @@ 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();
...@@ -227,6 +234,8 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -227,6 +234,8 @@ 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);
...@@ -256,6 +265,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -256,6 +265,7 @@ 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);
...@@ -289,6 +299,8 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -289,6 +299,8 @@ 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);
...@@ -320,6 +332,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -320,6 +332,7 @@ 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();
...@@ -348,6 +361,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -348,6 +361,7 @@ 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);
...@@ -379,6 +393,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -379,6 +393,7 @@ 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();
...@@ -413,6 +428,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -413,6 +428,7 @@ 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 + '}'
...@@ -497,6 +513,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -497,6 +513,7 @@ 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) {
...@@ -531,6 +548,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -531,6 +548,7 @@ 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();
}); });
...@@ -560,6 +578,8 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -560,6 +578,8 @@ 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);
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();
done(); done();
...@@ -586,6 +606,8 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -586,6 +606,8 @@ 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);
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();
done(); done();
...@@ -616,6 +638,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -616,6 +638,7 @@ 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();
...@@ -650,6 +673,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -650,6 +673,7 @@ 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 + '}'
...@@ -692,6 +716,8 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -692,6 +716,8 @@ 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) {
...@@ -722,6 +748,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -722,6 +748,7 @@ 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) {
...@@ -756,6 +783,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -756,6 +783,7 @@ 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();
}); });
...@@ -790,6 +818,8 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -790,6 +818,8 @@ 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) {
...@@ -822,6 +852,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -822,6 +852,7 @@ 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();
...@@ -856,6 +887,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -856,6 +887,7 @@ 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 + '}'
...@@ -895,6 +927,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -895,6 +927,7 @@ 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) {
...@@ -929,6 +962,7 @@ describe('fileIO_fs_FdOpenStream', async function () { ...@@ -929,6 +962,7 @@ 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();
}); });
......
...@@ -2304,7 +2304,7 @@ describe('fileIO_fs_stat', function () { ...@@ -2304,7 +2304,7 @@ describe('fileIO_fs_stat', function () {
let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
stat = fileIO.statSync(file2.fd); stat = fileIO.statSync(file2.fd);
expect(stat.size == FILE_CONTENT.length * 2).assertTrue(); expect(stat.size == FILE_CONTENT.length * 2).assertTrue();
fileIO.closeSync(file2.fd); fileIO.closeSync(file2);
fileIO.unlinkSync(fpath); fileIO.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册