提交 afaaca4d 编写于 作者: F fengjq

Bugfix for Watcher interface, delete invalide events.

Signed-off-by: Nfengjq <fengjunqing@huawei.com>
上级 e68e9777
...@@ -32,8 +32,7 @@ import { ...@@ -32,8 +32,7 @@ import {
'IN_CREATE': 0x00000100, 'IN_CREATE': 0x00000100,
'IN_DELETE': 0x00000200, 'IN_DELETE': 0x00000200,
'IN_DELETE_SELF': 0x00000400, 'IN_DELETE_SELF': 0x00000400,
'IN_MOVE_SELF': 0x00000800, 'IN_MOVE_SELF': 0x00000800
'IN_ISDIR': 0x40000000
} }
const callback = (data) => { const callback = (data) => {
...@@ -352,7 +351,7 @@ export default function fileIOWatcher() { ...@@ -352,7 +351,7 @@ export default function fileIOWatcher() {
* @tc.number SUB_DF_FILEIO_WATCHER_0800 * @tc.number SUB_DF_FILEIO_WATCHER_0800
* @tc.name fileIO_test_watcher_008 * @tc.name fileIO_test_watcher_008
* @tc.desc Test watcher event '0x00000100': 'IN_CREATE' * @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.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
...@@ -365,18 +364,11 @@ export default function fileIOWatcher() { ...@@ -365,18 +364,11 @@ export default function fileIOWatcher() {
fileIO.mkdirSync(dpath); fileIO.mkdirSync(dpath);
try { try {
let flag = false; let resWatcher = startWatcher(testNum, watcherEvent.IN_CREATE, dpath);
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();
fileIO.mkdirSync(ddpath); fileIO.mkdirSync(ddpath);
await sleep(WAIT_HALF_SECOND); await sleep(WAIT_HALF_SECOND);
expect(flag == true).assertTrue(); expect(resWatcher.flag == true).assertTrue();
watcher.stop(); resWatcher.watcher.stop();
fileIO.rmdirSync(dpath); fileIO.rmdirSync(dpath);
done(); done();
} catch (e) { } catch (e) {
...@@ -420,7 +412,7 @@ export default function fileIOWatcher() { ...@@ -420,7 +412,7 @@ export default function fileIOWatcher() {
* @tc.number SUB_DF_FILEIO_WATCHER_1000 * @tc.number SUB_DF_FILEIO_WATCHER_1000
* @tc.name fileIO_test_watcher_010 * @tc.name fileIO_test_watcher_010
* @tc.desc Test watcher event '0x00000200': 'IN_DELETE' * @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.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
...@@ -434,18 +426,11 @@ export default function fileIOWatcher() { ...@@ -434,18 +426,11 @@ export default function fileIOWatcher() {
fileIO.mkdirSync(ddpath); fileIO.mkdirSync(ddpath);
try { try {
let flag = false; let resWatcher = startWatcher(testNum, watcherEvent.IN_DELETE, dpath);
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();
fileIO.rmdirSync(ddpath); fileIO.rmdirSync(ddpath);
await sleep(WAIT_HALF_SECOND); await sleep(WAIT_HALF_SECOND);
expect(flag == true).assertTrue(); expect(resWatcher.flag == true).assertTrue();
watcher.stop(); resWatcher.watcher.stop();
fileIO.rmdirSync(dpath); fileIO.rmdirSync(dpath);
done(); done();
} catch (e) { } catch (e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册