Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
9b15c832
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9b15c832
编写于
6月 07, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3396 update storagefileiojstest
Merge pull request !3396 from raoxian/master
上级
07bb9fb4
5296bd8f
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
227 addition
and
205 deletion
+227
-205
storage/storagefileiojstest/src/main/js/default/test/Common.js
...ge/storagefileiojstest/src/main/js/default/test/Common.js
+9
-0
storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js
...oragefileiojstest/src/main/js/default/test/FileIO.test.js
+140
-128
storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js
...gefileiojstest/src/main/js/default/test/FileIODir.test.js
+35
-32
storage/storagefileiojstest/src/main/js/default/test/FileIOStat.test.js
...efileiojstest/src/main/js/default/test/FileIOStat.test.js
+9
-5
storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js
...ileiojstest/src/main/js/default/test/FileIOStream.test.js
+14
-9
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/copyFile.test.js
...in/js/default/test/module_fileio/members/copyFile.test.js
+1
-0
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/createStream.test.js
...s/default/test/module_fileio/members/createStream.test.js
+3
-2
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/fdatasync.test.js
...n/js/default/test/module_fileio/members/fdatasync.test.js
+1
-5
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/read.test.js
...c/main/js/default/test/module_fileio/members/read.test.js
+2
-9
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/symlink.test.js
...ain/js/default/test/module_fileio/members/symlink.test.js
+13
-15
未找到文件。
storage/storagefileiojstest/src/main/js/default/test/Common.js
浏览文件 @
9b15c832
...
...
@@ -99,6 +99,15 @@ export function randomString(num) {
return
pwd
;
}
export
function
forceRemoveDir
(
path
,
num
)
{
for
(
let
i
=
num
;
i
>=
0
;
i
--
)
{
if
(
i
<
num
)
{
path
=
path
.
replace
(
`/d
${
i
}
`
,
""
);
}
fileio
.
rmdirSync
(
path
);
}
}
function
isIntNum
(
val
)
{
return
typeof
val
===
'
number
'
&&
val
%
1
===
0
;
}
...
...
storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js
浏览文件 @
9b15c832
...
...
@@ -21,7 +21,8 @@ import {
nextFileName
,
prepareEmptyFile
,
randomString
,
fileName
fileName
,
forceRemoveDir
}
from
'
./Common
'
describe
(
'
fileIOTest
'
,
function
()
{
...
...
@@ -1040,15 +1041,16 @@ describe('fileIOTest', function () {
* @tc.desc Function of API, openSync(fpath too long).
*/
it
(
'
fileio_test_open_sync_007
'
,
0
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
fileio_
open1
'
);
let
dpath
=
await
nextFileName
(
'
fileio_
test_open_sync_007
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
for
(
let
i
=
0
;
i
<
16
;
i
++
)
{
if
(
i
==
15
)
{
let
fpath
=
dpath
+
'
/f
'
+
randomString
(
248
)
;
let
fpath
=
dpath
+
'
/f
'
+
i
;
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
fileio
.
unlinkSync
(
fpath
);
}
else
{
dpath
=
dpath
+
'
/d
'
+
randomString
(
248
)
;
dpath
=
dpath
+
'
/d
'
+
i
;
fileio
.
mkdirSync
(
dpath
);
}
}
...
...
@@ -1056,6 +1058,7 @@ describe('fileIOTest', function () {
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_open_sync_007 has failed for
'
+
err
);
forceRemoveDir
(
dpath
,
15
);
}
});
...
...
@@ -1080,15 +1083,16 @@ describe('fileIOTest', function () {
* @tc.desc Function of API, openSync(dir layers too long).
*/
it
(
'
fileio_test_open_sync_009
'
,
0
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
prop1
'
);
let
dpath
=
await
nextFileName
(
'
fileio_test_open_sync_009
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
for
(
let
i
=
0
;
i
<
113
;
i
++
)
{
if
(
i
==
112
)
{
let
fpath
=
dpath
+
'
/f
'
+
i
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
fileio
.
unlinkSync
(
fpath
);
}
else
{
dpath
=
dpath
+
'
/
'
+
i
dpath
=
dpath
+
'
/
d
'
+
i
fileio
.
mkdirSync
(
dpath
);
}
}
...
...
@@ -1096,6 +1100,7 @@ describe('fileIOTest', function () {
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_open_sync_009 has failed for
'
+
err
);
forceRemoveDir
(
dpath
,
112
);
}
});
...
...
@@ -1294,10 +1299,10 @@ describe('fileIOTest', function () {
let
fd
=
fileio
.
access
(
fpath
).
then
(()
=>
{
expect
(
fd
!==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file access Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file access Success
'
);
}).
catch
(
function
(
err
)
{
console
.
log
(
"
file access err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file access err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -1311,7 +1316,7 @@ describe('fileIOTest', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
fd
=
fileio
.
access
(
fpath
,
function
(
err
)
{
expect
(
fd
!==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -2301,15 +2306,17 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_copy_file_sync_008
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_copy_file_sync_008
'
);
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
let
dpath
=
await
nextFileName
(
'
fileio_
copy1
'
)
;
let
dpath
=
await
nextFileName
(
'
fileio_
test_copy_file_sync_008
'
)
+
'
d
'
;
fileio
.
mkdirSync
(
dpath
);
try
{
for
(
let
i
=
0
;
i
<
16
;
i
++
)
{
if
(
i
==
15
)
{
let
fpathTarget
=
dpath
+
'
/f
'
+
randomString
(
248
)
;
let
fpathTarget
=
dpath
+
'
/f
'
+
i
;
fileio
.
copyFileSync
(
fpath
,
fpathTarget
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
fpathTarget
);
}
else
{
dpath
=
dpath
+
'
/d
'
+
randomString
(
248
)
;
dpath
=
dpath
+
'
/d
'
+
i
;
fileio
.
mkdirSync
(
dpath
);
}
}
...
...
@@ -2317,6 +2324,7 @@ describe('fileIOTest', function () {
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_copy_file_sync_008 has failed for
'
+
err
);
forceRemoveDir
(
dpath
,
15
);
}
});
...
...
@@ -2347,22 +2355,25 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_copy_file_sync_010
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_copy_file_sync_010
'
);
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
let
dpath
=
await
nextFileName
(
'
prop
'
)
;
let
dpath
=
await
nextFileName
(
'
fileio_test_copy_file_sync_010
'
)
+
'
d
'
;
fileio
.
mkdirSync
(
dpath
);
try
{
for
(
let
i
=
0
;
i
<
113
;
i
++
)
{
if
(
i
==
112
)
{
let
fpathTarget
=
dpath
+
'
/f
'
+
i
fileio
.
copyFileSync
(
fpath
,
fpathTarget
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
fpathTarget
);
}
else
{
dpath
=
dpath
+
'
/
'
+
i
dpath
=
dpath
+
'
/
d
'
+
i
fileio
.
mkdirSync
(
dpath
);
}
}
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
fileio_test_copy_file_sync_010 has failed for
'
+
err
);
forceRemoveDir
(
dpath
,
112
);
}
});
...
...
@@ -2410,17 +2421,17 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_copy_file_async_001
* @tc.desc Function of API, copy. fpatch is vaild, fpathTarget is vaild, same path, file not same, mode is 0.
*/
it
(
'
fileio_test_copy_file_async_001
'
,
0
,
async
function
()
{
it
(
'
fileio_test_copy_file_async_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_copy_file_async_001
'
);
let
fpathTarget
=
fpath
+
'
tgt
'
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
await
fileio
.
copyFile
(
fpath
,
fpathTarget
).
then
(()
=>
{
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
expect
(
fileio
.
unlinkSync
(
fpathTarget
)
!==
null
).
assertTrue
();
console
.
log
(
'
fileio_test_copy_file_async_001 Success
'
);
console
.
info
(
'
fileio_test_copy_file_async_001 Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
fileio_test_copy_file_async_001 err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
fileio_test_copy_file_async_001 err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -3119,6 +3130,7 @@ describe('fileIOTest', function () {
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_ftruncate_sync_004 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid argument
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
...
...
@@ -3838,13 +3850,13 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_promise_000
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o660
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o660
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o660
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -3853,16 +3865,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_001
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_001
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o777
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o777
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o777
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -3871,16 +3883,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_002
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_002
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_002
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o774
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o774
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o774
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -3889,16 +3901,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_003
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_003
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_003
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_003
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o772
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o772
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o772
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -3907,16 +3919,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_004
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_004
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_004
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_004
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o771
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o771
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o771
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -3925,16 +3937,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_005
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_005
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_005
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_005
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o770
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o770
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o770
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -3943,16 +3955,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_006
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_006
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_006
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_006
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o666
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o666
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o666
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -3961,16 +3973,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_007
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_007
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_007
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_007
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o664
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o664
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o664
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -3979,16 +3991,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_008
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_008
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_008
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_008
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o662
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o662
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o662
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -3997,16 +4009,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_009
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_009
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_009
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_009
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o661
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o661
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o661
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -4015,16 +4027,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_010
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_010
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_010
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_010
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o660
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o660
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o660
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -4033,16 +4045,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_011
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_011
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_011
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_011
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o640
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o640
);
await
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o640
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -4051,16 +4063,16 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_stat_async_012
* @tc.desc obtain file propertys by stat promise
*/
it
(
'
fileio_test_stat_promise_012
'
,
0
,
async
function
()
{
it
(
'
fileio_test_stat_promise_012
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_promise_012
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o600
)
!==
null
).
assertTrue
(
);
let
stat
=
await
fileio
.
stat
(
fpath
).
then
((
)
=>
{
fileio
.
chmodSync
(
fpath
,
0o600
);
fileio
.
stat
(
fpath
).
then
((
stat
)
=>
{
expect
((
stat
.
mode
&
0o777
)
==
0o600
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
file stat Success
'
);
fileio
.
unlinkSync
(
fpath
);
console
.
info
(
'
file stat Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
file stat err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -4072,10 +4084,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_013
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_013
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o660
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o660
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o660
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4087,10 +4099,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_014
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_014
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o777
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o777
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o777
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4102,10 +4114,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_015
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_015
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o776
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o776
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o776
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4117,10 +4129,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_016
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_016
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o774
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o774
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o774
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4132,10 +4144,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_017
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_017
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o772
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o772
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o772
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4147,10 +4159,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_018
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_018
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o771
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o771
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o771
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4162,10 +4174,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_019
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_019
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o770
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o770
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o770
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4177,10 +4189,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_020
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_020
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o666
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o666
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o666
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4192,10 +4204,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_021
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_021
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o664
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o664
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o664
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4207,10 +4219,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_022
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_022
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o662
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o662
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o662
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4222,10 +4234,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_023
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_023
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o640
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o640
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o640
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4237,10 +4249,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_024
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_024
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o600
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o600
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o600
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4252,10 +4264,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_025
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_025
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o400
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o400
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o400
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4267,10 +4279,10 @@ describe('fileIOTest', function () {
it
(
'
fileio_test_stat_async_026
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stat_async_026
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
fileio
.
chmodSync
(
fpath
,
0o200
)
!==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o200
);
fileio
.
stat
(
fpath
,
function
(
err
,
stat
)
{
expect
((
stat
.
mode
&
0o777
)
==
0o200
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
...
...
@@ -4285,7 +4297,7 @@ describe('fileIOTest', function () {
let
fd
=
fileio
.
openSync
(
fpath
);
expect
(
fd
!==
null
).
assertTrue
();
await
fileio
.
close
(
fd
);
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
/**
...
...
@@ -4293,12 +4305,12 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_close_async_001
* @tc.desc Function of API close
*/
it
(
'
fileio_test_close_async_001
'
,
0
,
async
function
()
{
it
(
'
fileio_test_close_async_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_close_async_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
fd
=
fileio
.
openSync
(
fpath
);
await
fileio
.
close
(
fd
,
function
(
err
)
{
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
});
});
});
\ No newline at end of file
storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js
浏览文件 @
9b15c832
...
...
@@ -19,7 +19,8 @@ import {
FILE_CONTENT
,
prepareFile
,
nextFileName
,
randomString
randomString
,
forceRemoveDir
}
from
'
./Common
'
...
...
@@ -40,7 +41,7 @@ describe('fileIOTestDir', function () {
fileio
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_open_sync_000 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_open_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
...
...
@@ -56,7 +57,7 @@ describe('fileIOTestDir', function () {
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_open_sync_001 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_open_sync_001 has failed for
'
+
e
);
}
});
...
...
@@ -72,7 +73,7 @@ describe('fileIOTestDir', function () {
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_open_sync_002 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_open_sync_002 has failed for
'
+
e
);
expect
(
e
.
message
==
'
No such file or directory
'
).
assertTrue
();
}
});
...
...
@@ -87,14 +88,15 @@ describe('fileIOTestDir', function () {
fileio
.
mkdirSync
(
dpath
);
try
{
for
(
let
i
=
0
;
i
<
16
;
i
++
)
{
console
.
log
(
'
time
'
+
i
);
dpath
=
dpath
+
'
/
f
'
+
randomString
(
248
)
;
console
.
info
(
'
time
'
+
i
);
dpath
=
dpath
+
'
/
d
'
+
i
;
fileio
.
mkdirSync
(
dpath
);
}
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_open_sync_003 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_open_sync_003 has failed for
'
+
e
);
forceRemoveDir
(
dpath
,
16
);
}
});
...
...
@@ -110,7 +112,7 @@ describe('fileIOTestDir', function () {
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_open_sync_004 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_open_sync_004 has failed for
'
+
e
);
}
});
...
...
@@ -123,15 +125,16 @@ describe('fileIOTestDir', function () {
let
dpath
=
await
nextFileName
(
'
fileio_test_dir_open_sync_005
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
for
(
let
i
=
0
;
i
<
1
024
;
i
++
)
{
console
.
log
(
'
time
'
+
i
);
dpath
=
dpath
+
'
/
'
+
i
for
(
let
i
=
0
;
i
<
1
13
;
i
++
)
{
console
.
info
(
'
time
'
+
i
);
dpath
=
dpath
+
'
/
d
'
+
i
fileio
.
mkdirSync
(
dpath
);
}
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_open_sync_005 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_open_sync_005 has failed for
'
+
e
);
forceRemoveDir
(
dpath
,
113
);
}
});
...
...
@@ -147,7 +150,7 @@ describe('fileIOTestDir', function () {
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_open_sync_006 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_open_sync_006 has failed for
'
+
e
);
expect
(
e
.
message
==
'
No such file or directory
'
).
assertTrue
();
}
});
...
...
@@ -157,13 +160,13 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_open_async_001
* @tc.desc Function of API, file name contain special character.
*/
it
(
'
fileio_test_dir_open_async_001
'
,
0
,
async
function
()
{
it
(
'
fileio_test_dir_open_async_001
'
,
0
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
fileio_test_dir_open_async_001
'
)
+
'
d
'
expect
(
fileio
.
mkdirSync
(
dpath
)
!==
null
).
assertTrue
(
);
fileio
.
mkdirSync
(
dpath
);
fileio
.
opendir
(
dpath
,
function
(
err
,
dir
)
{
expect
(
dir
!==
null
).
assertTrue
();
expect
(
dir
.
closeSync
()
==
null
).
assertTrue
();
expect
(
fileio
.
rmdirSync
(
dpath
)
!==
null
).
assertTrue
(
);
dir
.
closeSync
();
fileio
.
rmdirSync
(
dpath
);
});
});
...
...
@@ -174,14 +177,14 @@ describe('fileIOTestDir', function () {
*/
it
(
'
fileio_test_dir_open_async_002
'
,
0
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
fileio_test_dir_open_async_002
'
)
+
'
d
'
expect
(
fileio
.
mkdirSync
(
dpath
)
!==
null
).
assertTrue
(
);
let
dir
=
await
fileio
.
opendir
(
dpath
).
then
((
)
=>
{
fileio
.
mkdirSync
(
dpath
);
fileio
.
opendir
(
dpath
).
then
((
dir
)
=>
{
expect
(
dir
!==
null
).
assertTrue
();
expect
(
dir
.
closeSync
()
==
null
).
assertTrue
();
expect
(
fileio
.
rmdirSync
(
dpath
)
!==
null
).
assertTrue
(
);
console
.
log
(
'
fileio opendir Success
'
);
dir
.
closeSync
();
fileio
.
rmdirSync
(
dpath
);
console
.
info
(
'
fileio opendir Success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
fileio opendir err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
"
fileio opendir err:
"
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -204,7 +207,7 @@ describe('fileIOTestDir', function () {
fileio
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_read_sync_000 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_read_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
...
...
@@ -231,7 +234,7 @@ describe('fileIOTestDir', function () {
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
let
bool
=
typeof
(
dd
.
readSync
());
expect
(
bool
==
'
object
'
).
assertTrue
();
console
.
log
(
'
---bool=
'
+
bool
);
console
.
info
(
'
---bool=
'
+
bool
);
}
dd
.
closeSync
();
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
...
...
@@ -244,7 +247,7 @@ describe('fileIOTestDir', function () {
fileio
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_read_sync_001 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_read_sync_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
...
...
@@ -283,7 +286,7 @@ describe('fileIOTestDir', function () {
fileio
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_read_sync_002 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_read_sync_002 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
...
...
@@ -305,7 +308,7 @@ describe('fileIOTestDir', function () {
fileio
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_read_sync_003 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_read_sync_003 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
...
...
@@ -328,7 +331,7 @@ describe('fileIOTestDir', function () {
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_read_sync_004 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_read_sync_004 has failed for
'
+
e
);
expect
(
e
.
message
==
'
Number of arguments unmatched
'
).
assertTrue
();
dd
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
...
...
@@ -359,7 +362,7 @@ describe('fileIOTestDir', function () {
fileio
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_read_sync_005 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_read_sync_005 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
...
...
@@ -379,7 +382,7 @@ describe('fileIOTestDir', function () {
fileio
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_close_sync_000 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_close_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
...
...
@@ -399,7 +402,7 @@ describe('fileIOTestDir', function () {
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_dir_close_sync_001 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_dir_close_sync_001 has failed for
'
+
e
);
expect
(
e
.
message
==
'
Dir has been closed yet
'
).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
}
...
...
storage/storagefileiojstest/src/main/js/default/test/FileIOStat.test.js
浏览文件 @
9b15c832
...
...
@@ -19,7 +19,8 @@ import {
FILE_CONTENT
,
prepareFile
,
nextFileName
,
randomString
randomString
,
forceRemoveDir
}
from
'
./Common
'
...
...
@@ -86,20 +87,23 @@ describe('fileIOTestStat', function () {
* @tc.desc Function of API, statSync. The file path is greater than 4096.
*/
it
(
'
fileio_test_stat_stat_sync_003
'
,
0
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
fileio_stat1
'
);
let
dpath
=
await
nextFileName
(
'
fileio_test_stat_stat_sync_003
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
for
(
let
i
=
0
;
i
<
16
;
i
++
)
{
if
(
i
==
15
)
{
let
fpath
=
dpath
+
'
/f
'
+
randomString
(
252
)
;
let
fpath
=
dpath
+
'
/f
'
+
i
;
fileio
.
statSync
(
fpath
);
}
else
{
dpath
=
dpath
+
'
/d
'
+
randomString
(
252
);
dpath
=
dpath
+
'
/d
'
+
i
;
fileio
.
mkdirSync
(
dpath
);
}
}
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_stat_stat_sync_003 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_stat_stat_sync_003 has failed for
'
+
e
);
forceRemoveDir
(
dpath
,
15
);
}
});
...
...
storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js
浏览文件 @
9b15c832
...
...
@@ -21,7 +21,8 @@ import {
fileToReadOnly
,
fileToWriteOnly
,
nextFileName
,
randomString
randomString
,
forceRemoveDir
}
from
'
./Common
'
...
...
@@ -594,22 +595,24 @@ describe('fileIOTestStream', function () {
* @tc.desc Function of API, fpath too long.
*/
it
(
'
fileio_test_stream_create_stream_sync_026
'
,
0
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
fileio_
stream
'
);
let
dpath
=
await
nextFileName
(
'
fileio_
test_stream_create_stream_sync_026
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
for
(
let
i
=
0
;
i
<
16
;
i
++
)
{
if
(
i
==
15
)
{
let
fpath
=
dpath
+
'
/f
'
+
randomString
(
248
)
;
let
fpath
=
dpath
+
'
/f
'
+
i
;
fileio
.
createStreamSync
(
fpath
,
'
w+
'
);
fileio
.
unlinkSync
(
fpath
);
}
else
{
dpath
=
dpath
+
'
/d
'
+
randomString
(
248
)
;
dpath
=
dpath
+
'
/d
'
+
i
;
fileio
.
mkdirSync
(
dpath
);
}
}
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_stream_create_stream_sync_026 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_stream_create_stream_sync_026 has failed for
'
+
e
);
forceRemoveDir
(
dpath
,
15
);
}
});
...
...
@@ -634,23 +637,25 @@ describe('fileIOTestStream', function () {
* @tc.name fileio_test_stream_create_stream_sync_028
* @tc.desc Function of API, path too deep.
*/
it
(
'
fileio_test_stream_create_stream_sync_028
'
,
0
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
stream
'
);
it
(
'
fileio_test_stream_create_stream_sync_028
'
,
0
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
fileio_test_stream_create_stream_sync_028
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
for
(
let
i
=
0
;
i
<
113
;
i
++
)
{
if
(
i
==
112
)
{
let
fpath
=
dpath
+
'
/f
'
+
i
fileio
.
createStreamSync
(
fpath
,
'
w+
'
);
fileio
.
unlinkSync
(
fpath
);
}
else
{
dpath
=
dpath
+
'
/
'
+
i
dpath
=
dpath
+
'
/
d
'
+
i
fileio
.
mkdirSync
(
dpath
);
}
}
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_stream_create_stream_sync_028 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_stream_create_stream_sync_028 has failed for
'
+
e
);
forceRemoveDir
(
dpath
,
112
);
}
});
...
...
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/copyFile.test.js
浏览文件 @
9b15c832
...
...
@@ -170,6 +170,7 @@ describe('fileio_copyfile', function () {
fileio
.
copyFile
(
1
,
fpath
)
.
then
(
function
(
err
)
{
fileio
.
unlinkSync
(
fpath
);
done
();
})
}
catch
(
e
)
{
...
...
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/createStream.test.js
浏览文件 @
9b15c832
...
...
@@ -134,11 +134,12 @@ describe('fileio_createStream', function () {
try
{
fileio
.
createStream
(
fpath
,
'
ohos
'
,
function
(
err
)
{
fileio
.
unlinkSync
(
fpath
);
done
();
});
}
catch
(
e
)
{
expect
(
!!
e
).
assertTrue
(
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
console
.
info
(
"
fileio_test_stream_create_stream_async_004 has failed for
"
+
e
);
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
...
...
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/fdatasync.test.js
浏览文件 @
9b15c832
...
...
@@ -85,17 +85,13 @@ describe('fileio_fdatasync', async function () {
* @tc.require
*/
it
(
'
fileio_test_fdatasync_async_002
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fdatasync_async_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
-
1
;
await
fileio
.
fdatasync
(
fd
);
expect
(
null
).
assertFail
();
done
()
}
catch
(
e
)
{
expect
(
!!
e
).
assertTrue
();
console
.
log
(
'
fileio_test_fdatasync_async_002 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_fdatasync_async_002 has failed for
'
+
e
);
done
();
}
});
...
...
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/read.test.js
浏览文件 @
9b15c832
...
...
@@ -508,18 +508,11 @@ describe('fileio_read', function () {
* @tc.require
*/
it
(
'
fileio_test_read_async_008
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_read_async_008
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
err
=
await
fileio
.
read
(
-
1
,
new
ArrayBuffer
(
4096
));
expect
(
!!
err
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
await
fileio
.
read
(
-
1
,
new
ArrayBuffer
(
4096
));
expect
(
null
).
assertFail
();
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_read_async_008 has failed for
'
+
e
);
expect
(
!!
e
).
assertTrue
();
console
.
info
(
'
fileio_test_read_async_008 has failed for
'
+
e
);
done
();
}
});
...
...
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/symlink.test.js
浏览文件 @
9b15c832
...
...
@@ -35,11 +35,11 @@ describe('fileio_symlink', function () {
try
{
fileio
.
symlinkSync
(
fpath
,
fpath
+
'
aaaa
'
);
expect
(
fileio
.
accessSync
(
fpath
+
'
aaaa
'
)
==
null
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
+
'
aaaa
'
);
fileio
.
accessSync
(
fpath
+
'
aaaa
'
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_symlink_sync_000 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_symlink_sync_000 has failed for
'
+
e
);
fileio
.
unlinkSync
(
fpath
+
'
aaaa
'
);
}
});
...
...
@@ -58,18 +58,14 @@ describe('fileio_symlink', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlink
(
fpath
,
fpath
+
'
1067
'
)
.
then
(
function
(
err
)
{
expect
(
fileio
.
accessSync
(
fpath
+
'
1067
'
)
==
null
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
+
'
1067
'
);
expect
(
err
==
null
).
assertTrue
();
})
.
catch
(
function
(
e
)
{
expect
(
e
==
null
).
assertTrue
();
});
fileio
.
symlink
(
fpath
,
fpath
+
'
1067
'
).
then
(
function
(
err
)
{
fileio
.
accessSync
(
fpath
+
'
1067
'
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
fpath
+
'
1067
'
);
})
done
();
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_symlink_async_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
...
...
@@ -85,16 +81,18 @@ describe('fileio_symlink', function () {
* @tc.require
*/
it
(
'
fileio_test_symlink_async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_symlink_async_0
10
'
);
let
fpath
=
await
nextFileName
(
'
fileio_test_symlink_async_0
01
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
await
fileio
.
symlink
(
fpath
,
fpath
+
'
pass2
'
,
function
(
err
)
{
expect
(
fileio
.
accessSync
(
fpath
+
'
pass2
'
)
==
null
).
assertTrue
();
fileio
.
accessSync
(
fpath
+
'
pass2
'
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
fpath
+
'
pass2
'
);
done
();
});
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_symlink_async_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录