From 8f2c07dd5d1e0640da0f8ab093c8b11973022f29 Mon Sep 17 00:00:00 2001 From: raoxian Date: Mon, 29 Aug 2022 10:22:13 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=8F=90=E4=BA=A4fchown.test?= =?UTF-8?q?.js=20=E5=BC=82=E6=AD=A5004=E5=92=8C005=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: raoxian --- .../test/module_fileio/members/fchown.test.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/storage/storagefileiojstest/src/main/js/test/module_fileio/members/fchown.test.js b/storage/storagefileiojstest/src/main/js/test/module_fileio/members/fchown.test.js index ce1a79995..13e6e4b11 100644 --- a/storage/storagefileiojstest/src/main/js/test/module_fileio/members/fchown.test.js +++ b/storage/storagefileiojstest/src/main/js/test/module_fileio/members/fchown.test.js @@ -122,6 +122,54 @@ describe('fileio_fchown', async function () { } }); + /** + * @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0400 + * @tc.name fileio_test_fchown_async_004 + * @tc.desc Test the fchownAsync() interface with promise, wrong owner. Test file modification failed. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileio_test_fchown_async_004', 0, async function (done) { + let fpath = await nextFileName('fileio_test_fchown_async_004'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + try { + let fd = fileio.openSync(fpath); + let stat = fileio.statSync(fpath); + await fileio.fchown(fd, null, stat.gid); + } catch (e) { + console.info('fileio_test_fchown_async_004 has failed for ' + e); + expect(e.message == "Operation not permitted" || e.message == "Invalid owner").assertTrue(); + fileio.unlinkSync(fpath); + done(); + } + }); + + /** + * @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0500 + * @tc.name fileio_test_fchown_async_005 + * @tc.desc Test the fchownAsync() interface with promise, wrong group. Test file modification failed. + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 0 + * @tc.require + */ + it('fileio_test_fchown_async_005', 0, async function (done) { + let fpath = await nextFileName('fileio_test_fchown_async_005'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + try { + let fd = fileio.openSync(fpath); + let stat = fileio.statSync(fpath); + await fileio.fchown(fd, stat.uid, null); + } catch (e) { + console.info('fileio_test_fchown_async_005 has failed for ' + e); + expect(e.message == "Invalid group").assertTrue(); + fileio.unlinkSync(fpath); + done(); + } + }); + /** * @tc.number SUB_DF_FILEIO_FCHOWN_SYNC_0000 * @tc.name fileio_test_fchown_sync_000 -- GitLab