From a235b2823e38f89365a0f7fd7ceb8ce8e0edd227 Mon Sep 17 00:00:00 2001 From: hu0475 Date: Thu, 13 Jul 2023 19:32:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9storage=E5=AD=90=E7=B3=BB?= =?UTF-8?q?=E7=BB=9Ffs=E6=A8=A1=E5=9D=97=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hu0475 --- .../main/ets/test/{Common.js => Common.ets} | 0 .../src/main/ets/test/members/close.test.ets | 8 ++--- .../src/main/ets/test/members/fsync.test.ets | 18 ++++++------ .../src/main/ets/test/members/mkdir.test.ets | 2 +- .../src/main/ets/test/members/open.test.ets | 29 ++----------------- .../src/main/ets/test/members/stat.test.ets | 2 +- 6 files changed, 17 insertions(+), 42 deletions(-) rename storage/crossplatform/storagefsetstest/src/main/ets/test/{Common.js => Common.ets} (100%) diff --git a/storage/crossplatform/storagefsetstest/src/main/ets/test/Common.js b/storage/crossplatform/storagefsetstest/src/main/ets/test/Common.ets similarity index 100% rename from storage/crossplatform/storagefsetstest/src/main/ets/test/Common.js rename to storage/crossplatform/storagefsetstest/src/main/ets/test/Common.ets diff --git a/storage/crossplatform/storagefsetstest/src/main/ets/test/members/close.test.ets b/storage/crossplatform/storagefsetstest/src/main/ets/test/members/close.test.ets index ed4462fe5..2c7c78a8d 100644 --- a/storage/crossplatform/storagefsetstest/src/main/ets/test/members/close.test.ets +++ b/storage/crossplatform/storagefsetstest/src/main/ets/test/members/close.test.ets @@ -125,22 +125,22 @@ export default function fileIOClose() { * @tc.type : Function * @tc.level : Level 2 */ - it("fileIO_test_close_async_003", 2, async function (done) { - let fpath = await nextFileName("fileIO_test_close_async_003"); + it("fileIO_test_close_async_004", 2, async function (done) { + let fpath = await nextFileName("fileIO_test_close_async_004"); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE); fileIO.close(file.fd, (err) => { if (err) { - console.log("fileIO_test_close_async_003 error package: " + JSON.stringify(err)); + console.log("fileIO_test_close_async_004 error package: " + JSON.stringify(err)); expect(false).assertTrue(); } fileIO.unlinkSync(fpath); done(); }); } catch (e) { - console.log("fileIO_test_close_async_003 has failed for " + e.message + ", code: " + e.code); + console.log("fileIO_test_close_async_004 has failed for " + e.message + ", code: " + e.code); expect(false).assertTrue(); } }); diff --git a/storage/crossplatform/storagefsetstest/src/main/ets/test/members/fsync.test.ets b/storage/crossplatform/storagefsetstest/src/main/ets/test/members/fsync.test.ets index e485856ca..94059d613 100644 --- a/storage/crossplatform/storagefsetstest/src/main/ets/test/members/fsync.test.ets +++ b/storage/crossplatform/storagefsetstest/src/main/ets/test/members/fsync.test.ets @@ -27,7 +27,7 @@ export default function fileIOFsync() { * @tc.type : Function * @tc.level : Level 2 */ - it("fileIO_test_fsync_async_000", 0, async function (done) { + it("fileIO_test_fsync_async_000", 2, async function (done) { let fpath = await nextFileName("fileIO_test_fsync_async_000"); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); @@ -50,9 +50,9 @@ export default function fileIOFsync() { * Invalid fd parameter. * @tc.size : MediumTest * @tc.type : Function - * @tc.level : Level 2 + * @tc.level : Level 3 */ - it("fileIO_test_fsync_async_001", 0, async function (done) { + it("fileIO_test_fsync_async_001", 3, async function (done) { try { await fileIO.fsync(-1); expect(false).assertTrue(); @@ -72,7 +72,7 @@ export default function fileIOFsync() { * @tc.type : Function * @tc.level : Level 2 */ - it("fileIO_test_fsync_async_002", 0, async function (done) { + it("fileIO_test_fsync_async_002", 2, async function (done) { let fpath = await nextFileName("fileIO_test_fsync_async_002"); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); @@ -100,9 +100,9 @@ export default function fileIOFsync() { * Invalid fd parameter. * @tc.size : MediumTest * @tc.type : Function - * @tc.level : Level 2 + * @tc.level : Level 3 */ - it("fileIO_test_fsync_async_003", 0, async function (done) { + it("fileIO_test_fsync_async_003", 3, async function (done) { try { fileIO.fsync(-1, (err) => { if (err) { @@ -179,7 +179,7 @@ export default function fileIOFsync() { * @tc.type : Function * @tc.level : Level 2 */ - it("fileIO_test_fsync_sync_000", 0, async function () { + it("fileIO_test_fsync_sync_000", 2, async function () { let fpath = await nextFileName("fileIO_test_fsync_sync_000"); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); @@ -201,9 +201,9 @@ export default function fileIOFsync() { * Invalid fd parameter. * @tc.size : MediumTest * @tc.type : Function - * @tc.level : Level 2 + * @tc.level : Level 3 */ - it("fileIO_test_fsync_sync_001", 0, function () { + it("fileIO_test_fsync_sync_001", 3, function () { try { fileIO.fsyncSync(-1); expect(false).assertTrue(); diff --git a/storage/crossplatform/storagefsetstest/src/main/ets/test/members/mkdir.test.ets b/storage/crossplatform/storagefsetstest/src/main/ets/test/members/mkdir.test.ets index d02945b2c..03ae02e7e 100644 --- a/storage/crossplatform/storagefsetstest/src/main/ets/test/members/mkdir.test.ets +++ b/storage/crossplatform/storagefsetstest/src/main/ets/test/members/mkdir.test.ets @@ -56,7 +56,7 @@ export default function fileIOMkdir() { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { - await fileIO.mkdirSync(fpath); + await fileIO.mkdir(fpath); expect(false).assertTrue(); } catch (e) { console.log("fileIO_test_mkdir_async_001 has failed for " + e.message + ", code: " + e.code); diff --git a/storage/crossplatform/storagefsetstest/src/main/ets/test/members/open.test.ets b/storage/crossplatform/storagefsetstest/src/main/ets/test/members/open.test.ets index 15d454b5a..5b93ebb1c 100644 --- a/storage/crossplatform/storagefsetstest/src/main/ets/test/members/open.test.ets +++ b/storage/crossplatform/storagefsetstest/src/main/ets/test/members/open.test.ets @@ -30,9 +30,9 @@ export default function fileIOOpen() { it("fileIO_test_open_async_000", 2, async function (done) { let fpath = await nextFileName("fileIO_test_open_async_000"); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + let file = await fileIO.open(fpath, fileIO.OpenMode.READ_ONLY); try { - let file = await fileIO.open(fpath, fileIO.OpenMode.READ_ONLY); expect(isIntNum(file.fd)).assertTrue(); fileIO.read(file.fd, new ArrayBuffer(4096)).then((readLen) => { expect(readLen == FILE_CONTENT.length).assertTrue(); @@ -40,6 +40,7 @@ export default function fileIOOpen() { fileIO.writeSync(file.fd, new ArrayBuffer(4096)); expect(false).assertTrue(); } catch (e) { + fileIO.closeSync(file) fileIO.unlinkSync(fpath); console.log("fileIO_test_open_async_000 has failed for " + e.message + ", code: " + e.code); expect(e.code == 13900008 && e.message == "Bad file descriptor").assertTrue(); @@ -1024,32 +1025,6 @@ export default function fileIOOpen() { } }); - // /** - // * @tc.number : TEST_FILEIO_OPEN_SYNC_011 - // * @tc.name : testFileIoOpenSync011 - // * @tc.desc : Test openSync() interfaces. mode=0o400002. - // * The path points to a symbolic link, throw error. - // * @tc.size : MediumTest - // * @tc.type : Function - // * @tc.level : Level 2 - // */ - // it('testFileIoOpenSync011', 0, async function () { - // let fpath = await nextFileName('testFileIoOpenSync011'); - // let ffpath = fpath + 'aaaa'; - // expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - - // try { - // fileIO.symlinkSync(fpath, ffpath); - // fileIO.openSync(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE); - // expect(false).assertTrue(); - // } catch (e) { - // fileIO.unlinkSync(fpath); - // // fileIO.unlinkSync(ffpath); - // console.log('testFileIoOpenSync011 has failed for ' + e.message + ', code: ' + e.code); - // expect(e.code == 13900033 && e.message == 'Too many symbolic links encountered').assertTrue(); - // } - // }); - /** * @tc.number : SUB_FM_TEST_FILEFS_OPEN_SYNC_1000 * @tc.name : fileIO_test_open_sync_010 diff --git a/storage/crossplatform/storagefsetstest/src/main/ets/test/members/stat.test.ets b/storage/crossplatform/storagefsetstest/src/main/ets/test/members/stat.test.ets index 114fd5299..a0be3295b 100644 --- a/storage/crossplatform/storagefsetstest/src/main/ets/test/members/stat.test.ets +++ b/storage/crossplatform/storagefsetstest/src/main/ets/test/members/stat.test.ets @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Huawei Device Co., Ltd. + * Copyright (C) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at -- GitLab