From afaaca4d7db09f179f5ec2fbadc3a60e116bee6d Mon Sep 17 00:00:00 2001 From: fengjq Date: Thu, 27 Jul 2023 21:30:46 +0800 Subject: [PATCH] Bugfix for Watcher interface, delete invalide events. Signed-off-by: fengjq --- .../src/main/js/test/members/watcher.test.js | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/watcher.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/watcher.test.js index f0344e623..9a6663031 100644 --- a/storage/storagefileiov9jstest/src/main/js/test/members/watcher.test.js +++ b/storage/storagefileiov9jstest/src/main/js/test/members/watcher.test.js @@ -32,8 +32,7 @@ import { 'IN_CREATE': 0x00000100, 'IN_DELETE': 0x00000200, 'IN_DELETE_SELF': 0x00000400, - 'IN_MOVE_SELF': 0x00000800, - 'IN_ISDIR': 0x40000000 + 'IN_MOVE_SELF': 0x00000800 } const callback = (data) => { @@ -352,7 +351,7 @@ export default function fileIOWatcher() { * @tc.number SUB_DF_FILEIO_WATCHER_0800 * @tc.name fileIO_test_watcher_008 * @tc.desc Test watcher event '0x00000100': 'IN_CREATE' - * open a nonexistent folder on create mode, verifying the event is 'IN_ISDIR | IN_CREATE'. + * open a nonexistent folder on create mode, verifying the event is 'IN_CREATE'. * @tc.size MEDIUM * @tc.type Function * @tc.level Level 0 @@ -365,18 +364,11 @@ export default function fileIOWatcher() { fileIO.mkdirSync(dpath); try { - let flag = false; - let watcher = fileIO.createWatcher(dpath, watcherEvent.IN_CREATE, (data) => { - console.log(`${testNum} :{event: ${data.event}, fileName: ${data.fileName}, cookie: ${data.cookie}}`); - if ((watcherEvent.IN_ISDIR | watcherEvent.IN_CREATE) === data.event) { - flag = true; - } - }); - watcher.start(); + let resWatcher = startWatcher(testNum, watcherEvent.IN_CREATE, dpath); fileIO.mkdirSync(ddpath); await sleep(WAIT_HALF_SECOND); - expect(flag == true).assertTrue(); - watcher.stop(); + expect(resWatcher.flag == true).assertTrue(); + resWatcher.watcher.stop(); fileIO.rmdirSync(dpath); done(); } catch (e) { @@ -420,7 +412,7 @@ export default function fileIOWatcher() { * @tc.number SUB_DF_FILEIO_WATCHER_1000 * @tc.name fileIO_test_watcher_010 * @tc.desc Test watcher event '0x00000200': 'IN_DELETE' - * delete a file , verifying the event is 'IN_ISDIR | IN_DELETE'. + * delete a directory , verifying the event is 'IN_DELETE'. * @tc.size MEDIUM * @tc.type Function * @tc.level Level 0 @@ -434,18 +426,11 @@ export default function fileIOWatcher() { fileIO.mkdirSync(ddpath); try { - let flag = false; - let watcher = fileIO.createWatcher(dpath, watcherEvent.IN_DELETE, (data) => { - console.log(`${testNum} :{event: ${data.event}, fileName: ${data.fileName}, cookie: ${data.cookie}}`); - if ((watcherEvent.IN_ISDIR | watcherEvent.IN_DELETE) === data.event) { - flag = true; - } - }); - watcher.start(); + let resWatcher = startWatcher(testNum, watcherEvent.IN_DELETE, dpath); fileIO.rmdirSync(ddpath); await sleep(WAIT_HALF_SECOND); - expect(flag == true).assertTrue(); - watcher.stop(); + expect(resWatcher.flag == true).assertTrue(); + resWatcher.watcher.stop(); fileIO.rmdirSync(dpath); done(); } catch (e) { -- GitLab