Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
f78121ab
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
f78121ab
编写于
5月 17, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3175 update storagefileioerrorjstest
Merge pull request !3175 from raoxian/master
上级
cb841942
19f61101
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
100 deletion
+47
-100
storage/storagefileioerrorjstest/src/main/js/default/test/Common.js
...oragefileioerrorjstest/src/main/js/default/test/Common.js
+5
-1
storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js
...oerrorjstest/src/main/js/default/test/FileIOError.test.js
+42
-99
未找到文件。
storage/storagefileioerrorjstest/src/main/js/default/test/Common.js
浏览文件 @
f78121ab
...
...
@@ -34,7 +34,7 @@ export function prepareFile(fpath, content) {
export
function
nextFileName
(
testName
)
{
const
BASE_PATH
=
'
/data/storage/el2/base/haps/entry/cache/
'
return
BASE_PATH
+
testName
+
'
_
'
+
randomString
(
testName
.
length
);
return
BASE_PATH
+
testName
}
export
function
fileName
(
testName
)
{
const
BASE_PATH
=
'
/data/storage/el2/base/haps/entry/files/
'
...
...
@@ -54,4 +54,8 @@ export function randomString(num) {
export
function
isIntNum
(
val
)
{
return
typeof
val
===
'
number
'
&&
val
%
1
===
0
;
}
export
function
isInclude
(
error
,
message
)
{
return
error
.
toString
().
indexOf
(
message
)
!=
-
1
;
}
\ No newline at end of file
storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js
浏览文件 @
f78121ab
...
...
@@ -26,7 +26,8 @@ import {
fileName
,
nextFileName
,
randomString
,
isIntNum
isIntNum
,
isInclude
}
from
'
./Common
'
...
...
@@ -47,8 +48,9 @@ describe('FileIOError', function () {
expect
(
isIntNum
(
fd
)).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_009 has failed for
'
+
e
);
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_009 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
Directory not empty
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
rmdirSync
(
dpath
);
}
...
...
@@ -68,38 +70,9 @@ describe('FileIOError', function () {
fileio
.
rmdirSync
(
fpath
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_010 has failed for
'
+
e
);
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_1100
* @tc.name FileIo_test_error_011
* @tc.desc Function of API, Pass in a
* path that exceeds 4096 bytes to copy the file
*/
it
(
'
FileIo_test_error_011
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
fileio_test_error_011
'
);
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
expect
(
isIntNum
(
fd
)).
assertTrue
();
let
dpath
=
nextFileName
(
'
fileio_error_011d
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
for
(
let
i
=
0
;
i
<
16
;
i
++
)
{
if
(
i
==
15
)
{
let
fpathTarget
=
dpath
+
'
/f
'
+
randomString
(
248
);
fileio
.
copyFileSync
(
fpath
,
fpathTarget
);
expect
(
null
).
assertFail
();
}
else
{
dpath
=
dpath
+
'
/d
'
+
randomString
(
248
);
fileio
.
mkdirSync
(
dpath
);
}
}
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_011 has failed for
'
+
e
);
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_010 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
Not a directory
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
...
...
@@ -107,7 +80,7 @@ describe('FileIOError', function () {
/**
* @tc.number SUB_STORAGE_FileIo_test_error_1200
* @tc.name FileIo_test_error_012
* @tc.desc Function of API, flags=0o102.
The test file is exist
.
* @tc.desc Function of API, flags=0o102.
missing mode parameter
.
*/
it
(
'
FileIo_test_error_012
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
FileIo_test_error_012
'
);
...
...
@@ -116,8 +89,9 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o102
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_012 has failed for
'
+
e
);
catch
(
err
)
{
console
.
log
(
'
FileIo_test_error_012 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
...
...
@@ -125,7 +99,7 @@ describe('FileIOError', function () {
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_1300
* @tc.name FileIo_test_error_013
* @tc.desc Function of API, flags=0o102
* @tc.desc Function of API, flags=0o102
, missing mode parameter.
*/
it
(
'
FileIo_test_error_013
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
FileIo_test_error_013
'
);
...
...
@@ -133,26 +107,9 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o102
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_013 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_1400
* @tc.name FileIo_test_error_014
* @tc.desc Function of API, flags=0o202. The test file is exist.
*/
it
(
'
FileIo_test_error_014
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
FileIo_test_error_014
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o202
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_014 has failed for
'
+
e
);
fileio
.
unlinkSync
(
fpath
);
catch
(
err
)
{
console
.
log
(
'
FileIo_test_error_013 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
}
});
...
...
@@ -167,8 +124,9 @@ describe('FileIOError', function () {
try
{
fileio
.
openSync
(
fpath
,
0o302
,
0o666
);
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_015 has failed for
'
+
e
);
catch
(
err
)
{
console
.
log
(
'
FileIo_test_error_015 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
File exists
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
...
...
@@ -185,8 +143,8 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o100002
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_016 has failed for
'
+
e
);
catch
(
e
rr
)
{
console
.
log
(
'
FileIo_test_error_016 has failed for
'
+
e
rr
);
fileio
.
unlinkSync
(
fpath
);
}
});
...
...
@@ -203,28 +161,13 @@ describe('FileIOError', function () {
fileio
.
openSync
(
dpath
,
0o40002
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_017 has failed for
'
+
e
);
catch
(
err
)
{
console
.
log
(
'
FileIo_test_error_017 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_1800
* @tc.name FileIo_test_error_018
* @tc.desc Function of API, flags=0o20040002. The test file is exist.
*/
it
(
'
FileIo_test_error_018
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
FileIo_test_error_018
'
);
try
{
fileio
.
openSync
(
fpath
,
0o20040002
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_018 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_1900
* @tc.name FileIo_test_error_019
...
...
@@ -238,8 +181,8 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o400002
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_019 has failed for
'
+
e
);
catch
(
e
rr
)
{
console
.
log
(
'
FileIo_test_error_019 has failed for
'
+
e
rr
);
fileio
.
unlinkSync
(
fpath
);
}
});
...
...
@@ -257,8 +200,8 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o400002
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_020 has failed for
'
+
e
);
catch
(
e
rr
)
{
console
.
log
(
'
FileIo_test_error_020 has failed for
'
+
e
rr
);
fileio
.
unlinkSync
(
fpath
);
}
});
...
...
@@ -274,28 +217,28 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o10000102
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_021 has failed for
'
+
e
);
catch
(
err
)
{
console
.
log
(
'
FileIo_test_error_021 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_2
2
00
* @tc.name FileIo_test_error_02
2
* @tc.desc Function of API,
mode=1 The test file is exis
t.
* @tc.number SUB_STORAGE_FileIO_OpenSync_2
3
00
* @tc.name FileIo_test_error_02
3
* @tc.desc Function of API,
flags=0o200000. Invalid argumen
t.
*/
it
(
'
FileIo_test_error_022
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
FileIo_test_error_022
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
fpathTarget
=
fpath
+
'
f1
'
;
it
(
'
FileIo_test_error_023
'
,
0
,
function
()
{
let
dpath
=
fileName
(
'
FileIo_test_error_023d
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
fileio
.
copyFileSync
(
fpath
,
fpathTarget
,
1
);
fileio
.
openSync
(
dpath
,
0o200000
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_02
2 has failed for
'
+
e
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
fpathTarget
);
catch
(
e
rr
)
{
console
.
log
(
'
FileIo_test_error_02
3 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
Invalid argument
'
)).
assertTrue
(
);
fileio
.
rmdirSync
(
dpath
);
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录