Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
bbc6d47e
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,发现更多精彩内容 >>
未验证
提交
bbc6d47e
编写于
6月 25, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3748 update fileioerror
Merge pull request !3748 from raoxian/OpenHarmony-3.1-Release
上级
dd9808e9
3d72a168
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
140 deletion
+29
-140
storage/storagefileioerrorjstest/src/main/js/default/test/Common.js
...oragefileioerrorjstest/src/main/js/default/test/Common.js
+0
-11
storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js
...oerrorjstest/src/main/js/default/test/FileIOError.test.js
+17
-114
storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js
...oragefileiojstest/src/main/js/default/test/FileIO.test.js
+12
-15
未找到文件。
storage/storagefileioerrorjstest/src/main/js/default/test/Common.js
浏览文件 @
bbc6d47e
...
...
@@ -46,17 +46,6 @@ export async function fileName(testName) {
return
BASE_PATH
+
testName
}
export
function
randomString
(
num
)
{
let
len
=
num
;
var
$chars
=
'
aaaabbbbcccc
'
;
var
maxPos
=
$chars
.
length
;
var
pwd
=
''
;
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
pwd
+=
$chars
.
charAt
(
Math
.
floor
(
Math
.
random
()
*
maxPos
));
}
return
pwd
;
}
export
function
isIntNum
(
val
)
{
return
typeof
val
===
'
number
'
&&
val
%
1
===
0
;
}
...
...
storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js
浏览文件 @
bbc6d47e
...
...
@@ -25,7 +25,6 @@ import {
prepareFile
,
fileName
,
nextFileName
,
randomString
,
isIntNum
,
isInclude
}
...
...
@@ -69,7 +68,6 @@ describe('FileIOError', function () {
let
fd
=
fileio
.
openSync
(
fpath
);
expect
(
isIntNum
(
fd
)).
assertTrue
();
fileio
.
rmdirSync
(
fpath
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_error_001 has failed for
'
+
err
);
...
...
@@ -82,14 +80,13 @@ describe('FileIOError', function () {
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0200
* @tc.name fileio_test_error_002
* @tc.desc Function of API, flags=0o10
2
. missing mode parameter.
* @tc.desc Function of API, flags=0o10
0
. missing mode parameter.
*/
it
(
'
fileio_test_error_002
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o102
);
expect
(
null
).
assertFail
();
fileio
.
openSync
(
fpath
,
0o100
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_error_002 has failed for
'
+
err
);
...
...
@@ -102,17 +99,18 @@ describe('FileIOError', function () {
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_0300
* @tc.name fileio_test_error_003
* @tc.desc Function of API,
flags=0o102, missing mode parameter
.
* @tc.desc Function of API,
flags=0o302. The test file is exist
.
*/
it
(
'
fileio_test_error_003
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_003
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o102
);
expect
(
null
).
assertFail
();
fileio
.
openSync
(
fpath
,
0o302
,
0o666
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_error_003 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
expect
(
isInclude
(
err
.
message
,
'
File exists
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
...
...
@@ -120,18 +118,22 @@ describe('FileIOError', function () {
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_0400
* @tc.name fileio_test_error_004
* @tc.desc Function of API,
flags=0o302. The test file is exist
.
* @tc.desc Function of API,
flags=0o400000. Symbolic link loop
.
*/
it
(
'
fileio_test_error_004
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_004
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o302
,
0o666
);
fileio
.
symlinkSync
(
fpath
,
ffpath
);
fileio
.
openSync
(
ffpath
,
0o400000
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_error_004 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
File exists
'
)).
assertTrue
();
expect
(
isInclude
(
err
.
message
,
'
Symbolic link loop
'
)
||
isInclude
(
err
.
message
,
'
Too many symbolic links encountered
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
done
();
}
});
...
...
@@ -139,118 +141,19 @@ describe('FileIOError', function () {
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_0500
* @tc.name fileio_test_error_005
* @tc.desc Function of API,
flags=0o100002. The test file is exist
.
* @tc.desc Function of API,
flags=0o200000. Not a directory
.
*/
it
(
'
fileio_test_error_005
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_005
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o100002
);
expect
(
null
).
assertFail
();
fileio
.
openSync
(
fpath
,
0o200000
,
0o666
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_error_005 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
Not a directory
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_0600
* @tc.name fileio_test_error_006
* @tc.desc Function of API, flags=0o40002 The test file is exist.
*/
it
(
'
fileio_test_error_006
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
nextFileName
(
'
fileio_test_error_006
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
fileio
.
openSync
(
dpath
,
0o40002
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_error_006 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
done
();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_0700
* @tc.name fileio_test_error_007
* @tc.desc Function of API, flags=0o400002. The test file is exist.
*/
it
(
'
fileio_test_error_007
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_007
'
);
let
txt
=
'
h
'
expect
(
prepareFile
(
fpath
,
txt
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o400002
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_error_007 has failed for
'
+
err
);
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_0800
* @tc.name fileio_test_error_008
* @tc.desc Function of API, flags=0o400002. The test file is exist.
*/
it
(
'
fileio_test_error_008
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_008
'
);
let
txt
=
randomString
(
5000
);
expect
(
prepareFile
(
fpath
,
txt
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o400002
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_error_008 has failed for
'
+
err
);
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_0900
* @tc.name fileio_test_error_009
* @tc.desc Function of API, flags=0o10000102. The test file is exist.
*/
it
(
'
fileio_test_error_009
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_009
'
);
try
{
fileio
.
openSync
(
fpath
,
0o10000102
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_error_009 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_1000
* @tc.name fileio_test_error_010
* @tc.desc Function of API, flags=0o200000. Invalid argument.
*/
it
(
'
fileio_test_error_010
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
fileName
(
'
fileio_test_error_010d
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
fileio
.
openSync
(
dpath
,
0o200000
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_error_010 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
Invalid argument
'
)).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
done
();
}
});
});
storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js
浏览文件 @
bbc6d47e
...
...
@@ -495,16 +495,15 @@ describe('fileIOTest', function () {
* @tc.name fileio_test_open_019
* @tc.desc Function of API, flags=0o40002. mode=0o700
*/
it
(
'
fileio_test_open_019
'
,
0
,
async
function
()
{
it
(
'
fileio_test_open_019
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_open_019
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o40002
,
0o700
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_open_019 has failed for
'
+
err
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_open_019 has failed for
'
+
e
);
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
();
}
});
...
...
@@ -531,19 +530,17 @@ describe('fileIOTest', function () {
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_2200
* @tc.name fileio_test_open_022
* @tc.desc Function of API, flags=0o20000
2
.
* @tc.desc Function of API, flags=0o20000
0
.
*/
it
(
'
fileio_test_open_022
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_open_022
'
)
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
(
);
let
dpath
=
await
nextFileName
(
'
fileio_test_open_022
'
)
+
'
d
'
;
fileio
.
mkdirSync
(
dpath
);
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o200002
);
expect
(
fd
!==
null
).
assertTrue
();
expect
(
fileio
.
closeSync
(
fd
)
!==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_open_022 has failed for
'
+
e
);
fileio
.
openSync
(
dpath
,
0o200000
,
0o666
);
fileio
.
rmdirSync
(
dpath
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_open_022 has failed for
'
+
err
);
expect
(
null
).
assertFail
();
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录