From 3d72a16878fe32092aac0a3f0bc265cf6c4a93d3 Mon Sep 17 00:00:00 2001 From: raoxian Date: Fri, 24 Jun 2022 15:07:39 +0800 Subject: [PATCH] update fileio Signed-off-by: raoxian --- .../main/js/default/test/FileIOError.test.js | 3 ++- .../src/main/js/default/test/FileIO.test.js | 27 +++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js b/storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js index 061978cca..cbc7162de 100644 --- a/storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js +++ b/storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js @@ -130,7 +130,8 @@ describe('FileIOError', function () { } catch (err) { console.info('fileio_test_error_004 has failed for ' + err); - expect(isInclude(err.message, 'Symbolic link loop') || isInclude(err.message, 'Too many symbolic links encountered')).assertTrue(); + expect(isInclude(err.message, 'Symbolic link loop') || + isInclude(err.message, 'Too many symbolic links encountered')).assertTrue(); fileio.unlinkSync(fpath); fileio.unlinkSync(ffpath); done(); diff --git a/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js b/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js index 3ef24e876..8b40eb8b4 100644 --- a/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js +++ b/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js @@ -495,16 +495,15 @@ describe('fileIOTest', function () { * @tc.name fileio_test_open_019 * @tc.desc Function of API, flags=0o40002. mode=0o700 */ - it('fileio_test_open_019', 0, async function () { + it('fileio_test_open_019', 0, async function () { let fpath = await nextFileName('fileio_test_open_019'); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { fileio.openSync(fpath, 0o40002, 0o700); + fileio.unlinkSync(fpath); + }catch (err) { + console.info('fileio_test_open_019 has failed for ' + err); expect(null).assertFail(); - } - catch (e) { - console.log('fileio_test_open_019 has failed for ' + e); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); } }); @@ -531,19 +530,17 @@ describe('fileIOTest', function () { /** * @tc.number SUB_STORAGE_FileIO_OpenSync_2200 * @tc.name fileio_test_open_022 - * @tc.desc Function of API, flags=0o200002. + * @tc.desc Function of API, flags=0o200000. */ it('fileio_test_open_022', 0, async function () { - let fpath = await nextFileName('fileio_test_open_022'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let dpath = await nextFileName('fileio_test_open_022') + 'd'; + fileio.mkdirSync(dpath); try { - let fd = fileio.openSync(fpath, 0o200002); - expect(fd !== null).assertTrue(); - expect(fileio.closeSync(fd) !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); - } - catch (e) { - console.log('fileio_test_open_022 has failed for ' + e); + fileio.openSync(dpath, 0o200000, 0o666); + fileio.rmdirSync(dpath); + } + catch (err) { + console.info('fileio_test_open_022 has failed for ' + err); expect(null).assertFail(); } }); -- GitLab