Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
91b52137
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看板
提交
91b52137
编写于
6月 22, 2022
作者:
R
raoxian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update fileio close,copyfile
Signed-off-by:
N
raoxian
<
raoxian@huawei.com
>
上级
8c29313a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
188 addition
and
74 deletion
+188
-74
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/close.test.js
.../main/js/default/test/module_fileio/members/close.test.js
+67
-28
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/copyFile.test.js
...in/js/default/test/module_fileio/members/copyFile.test.js
+121
-46
未找到文件。
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/close.test.js
浏览文件 @
91b52137
...
...
@@ -20,32 +20,33 @@ import {
describe
(
'
fileio_close
'
,
function
()
{
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0000
* @tc.name fileio_test_close_sync_000
* @tc.desc Test closeSync() interfaces
* @tc.desc Test closeSync() interfaces
. Test file has been closed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_close_sync_000
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_close_
a
sync_000
'
);
let
fpath
=
await
nextFileName
(
'
fileio_test_close_sync_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
closeSync
(
fd
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_close_sync_000 has failed for
'
+
e
);
expect
(
e
.
message
==
'
Bad file descriptor
'
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
})
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0100
* @tc.name fileio_test_close_sync_001
* @tc.desc Test closeSync() interfaces,No parameters.
* @tc.desc Test closeSync() interfaces,
No parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -61,9 +62,9 @@ describe('fileio_close', function () {
})
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0
01
0
* @tc.name fileio_test_close_sync_00
1
* @tc.desc Test closeSync() interfaces,fd is illegal.
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0
20
0
* @tc.name fileio_test_close_sync_00
2
* @tc.desc Test closeSync() interfaces,
fd is illegal.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -81,7 +82,7 @@ describe('fileio_close', function () {
/**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0000
* @tc.name fileio_test_close_async_000
* @tc.desc Test close() interfaces,
return in callback mode
.
* @tc.desc Test close() interfaces,
return in callback mode. Test file has been closed
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -90,23 +91,23 @@ describe('fileio_close', function () {
it
(
'
fileio_test_close_async_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_close_async_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
fileio
.
close
(
fd
,
function
(
err
)
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
fileio
.
close
(
fd
,
function
(
err
)
{
try
{
fileio
.
closeSync
(
fd
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_close_async_000 has failed for
'
+
e
);
expect
(
e
.
message
==
'
Bad file descriptor
'
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
});
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_close_async_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
}
});
})
/**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0
01
0
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0
10
0
* @tc.name fileio_test_close_async_001
* @tc.desc Test close() interfaces,
return in promise mode
.
* @tc.desc Test close() interfaces,
return in promise mode. Test file has been closed
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -119,31 +120,31 @@ describe('fileio_close', function () {
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
await
fileio
.
close
(
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
fileio
.
closeSync
(
fd
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_close_async_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
expect
(
e
.
message
==
'
Bad file descriptor
'
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
})
/**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0
02
0
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0
20
0
* @tc.name fileio_test_close_async_002
* @tc.desc Test close() interfaces,there are multiple parameters.
* @tc.desc Test close() interfaces,
there are multiple parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_close_async_002
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_close_async_001
'
);
let
fpath
=
await
nextFileName
(
'
fileio_test_close_async_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
fileio
.
close
(
fd
,
2
,
function
(
err
)
{
fileio
.
close
(
fd
,
2
,
function
(
err
)
{
});
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_close_async_002 has failed for
'
+
e
);
...
...
@@ -152,4 +153,42 @@ describe('fileio_close', function () {
done
();
}
})
/**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0300
* @tc.name fileio_test_close_async_003
* @tc.desc Test close() interfaces, fd is illegal.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_close_async_003
'
,
0
,
async
function
(
done
)
{
try
{
await
fileio
.
close
(
-
1
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_close_async_003 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Bad file descriptor
"
).
assertTrue
();
done
();
}
})
/**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0400
* @tc.name fileio_test_close_async_004
* @tc.desc Test close() interfaces, No parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_close_async_004
'
,
0
,
async
function
(
done
)
{
try
{
await
fileio
.
close
();
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_close_async_004 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
done
();
}
})
})
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/copyFile.test.js
浏览文件 @
91b52137
...
...
@@ -23,7 +23,7 @@ describe('fileio_copyfile', function () {
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0000
* @tc.name fileio_copy_file_sync_000
* @tc.desc Test copyFileSync() interfaces.
* @tc.desc Test copyFileSync() interfaces.
Test file copied successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -35,19 +35,20 @@ describe('fileio_copyfile', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
expect
(
fileio
.
copyFileSync
(
fpath
,
fpathTarget
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpathTarget
)
==
null
).
assertTrue
();
fileio
.
copyFileSync
(
fpath
,
fpathTarget
);
fileio
.
accessSync
(
fpathTarget
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
fpathTarget
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_copy_file_sync_000 has failed for
'
+
e
);
console
.
info
(
'
fileio_copy_file_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0
01
0
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0
10
0
* @tc.name fileio_copy_file_sync_001
* @tc.desc Test copyFileSync() interfaces.
* @tc.desc Test copyFileSync() interfaces.
Test file copied successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -56,37 +57,63 @@ describe('fileio_copyfile', function () {
it
(
'
fileio_copy_file_sync_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_copy_file_sync_001
'
);
let
fpathTarget
=
fpath
+
'
tgt
'
;
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
try
{
fileio
.
copyFileSync
(
fpath
,
fpathTarget
);
expect
(
null
).
assertFail
();
fileio
.
copyFileSync
(
fd
,
fpathTarget
);
fileio
.
accessSync
(
fpathTarget
);
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
fpathTarget
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_copy_file_sync_001 has failed for
'
+
e
);
console
.
info
(
'
fileio_copy_file_sync_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0
02
0
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0
20
0
* @tc.name fileio_copy_file_sync_002
* @tc.desc Test copyFileSync() interfaces.
* @tc.desc Test copyFileSync() interfaces, invalid path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_copy_file_sync_002
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_copy_file_sync_002
'
);
let
fpathTarget
=
fpath
+
'
tgt
'
;
try
{
fileio
.
copyFileSync
(
fpath
,
fpathTarget
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_copy_file_sync_002 has failed for
'
+
e
);
expect
(
e
.
message
==
'
No such file or directory
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_SYNC_0300
* @tc.name fileio_copy_file_sync_003
* @tc.desc Test copyFileSync() interfaces, No parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_copy_file_sync_00
2
'
,
0
,
function
()
{
it
(
'
fileio_copy_file_sync_00
3
'
,
0
,
function
()
{
try
{
fileio
.
copyFileSync
();
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_copy_file_sync_002 has failed for
'
+
e
);
console
.
info
(
'
fileio_copy_file_sync_003 has failed for
'
+
e
);
expect
(
e
.
message
==
'
Number of arguments unmatched
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0000
* @tc.name fileio_copy_file_async_000
* @tc.desc Test copyFileAsync() interfaces.
* @tc.desc Test copyFileAsync() interfaces
, return in promise mode. Test file copied successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -98,46 +125,48 @@ describe('fileio_copyfile', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
expect
(
await
fileio
.
copyFile
(
fpath
,
fpathTarget
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpathTarget
)
==
null
).
assertTrue
();
await
fileio
.
copyFile
(
fpath
,
fpathTarget
);
fileio
.
accessSync
(
fpathTarget
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
fpathTarget
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_copy_file_async_000 has failed for
'
+
e
);
console
.
info
(
'
fileio_copy_file_async_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0
01
0
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0
10
0
* @tc.name fileio_copy_file_async_001
* @tc.desc Test copyFileAsync() interfaces.
* @tc.desc Test copyFileAsync() interfaces
, return in callback mode. Test file copied successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_copy_file_async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_copy_file_async_00
0
'
);
let
fpath
=
await
nextFileName
(
'
fileio_copy_file_async_00
1
'
);
let
fpathTarget
=
fpath
+
'
tgt
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
copyFile
(
fpath
,
fpathTarget
,
function
(
error
)
{
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpathTarget
)
==
null
).
assertTrue
();
fileio
.
accessSync
(
fpathTarget
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
fpathTarget
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileio_copy_file_async_000
has failed for
'
+
e
);
console
.
info
(
'
fileio_copy_file_async_001
has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0
02
0
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0
20
0
* @tc.name fileio_copy_file_async_002
* @tc.desc Test copyFileAsync() interfaces.
* @tc.desc Test copyFileAsync() interfaces
, return in promise mode. Test file copied successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -146,18 +175,25 @@ describe('fileio_copyfile', function () {
it
(
'
fileio_copy_file_async_002
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_copy_file_async_002
'
);
let
fpathTarget
=
fpath
+
'
tgt
'
;
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
try
{
expect
(
await
fileio
.
copyFile
(
fpath
,
fpathTarget
).
indexOf
(
'
<pending>
'
)
>
-
1
).
assertTrue
();
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
await
fileio
.
copyFile
(
fd
,
fpathTarget
);
fileio
.
accessSync
(
fpathTarget
);
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
fpathTarget
);
done
();
}
catch
(
e
)
{
console
.
info
(
'
fileio_copy_file_async_002 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0
03
0
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0
30
0
* @tc.name fileio_copy_file_async_003
* @tc.desc Test copyFileAsync() interfaces.
* @tc.desc Test copyFileAsync() interfaces
, Invalid path
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -165,23 +201,20 @@ describe('fileio_copyfile', function () {
*/
it
(
'
fileio_copy_file_async_003
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_copy_file_async_003
'
);
let
fpathTarget
=
fpath
+
'
tgt
'
;
try
{
fileio
.
copyFile
(
1
,
fpath
)
.
then
(
function
(
err
)
{
fileio
.
unlinkSync
(
fpath
);
done
();
});
await
fileio
.
copyFile
(
fpath
,
fpathTarget
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_copy_file_async_003 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
console
.
info
(
'
fileio_copy_file_async_003 has failed for
'
+
e
);
expect
(
e
.
message
==
'
No such file or directory
'
).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0
04
0
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0
40
0
* @tc.name fileio_copy_file_async_004
* @tc.desc Test copyFileAsync() interfaces.
* @tc.desc Test copyFileAsync() interfaces.
Invalid argument.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -189,13 +222,55 @@ describe('fileio_copyfile', function () {
*/
it
(
'
fileio_copy_file_async_004
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_copy_file_async_004
'
);
try
{
await
fileio
.
copyFile
(
-
1
,
fpath
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_copy_file_async_004 has failed for
'
+
e
);
expect
(
e
.
message
==
'
Invalid argument
'
||
e
.
message
==
'
No such file or directory
'
).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0500
* @tc.name fileio_copy_file_async_005
* @tc.desc Test copyFileAsync() interfaces, Invalid mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_copy_file_async_005
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_copy_file_async_005
'
);
let
fpathTarget
=
fpath
+
'
tgt
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
expect
(
await
fileio
.
copyFile
(
fpath
,
1
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
fileio
.
copyFile
(
fpath
,
fpathTarget
,
'
1
'
,
function
(
error
)
{
});
}
catch
(
e
)
{
console
.
info
(
'
fileio_copy_file_async_005 has failed for
'
+
e
);
expect
(
e
.
message
==
'
Invalid mode
'
||
e
.
message
==
'
Invalid arg
'
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPY_FILE_ASYNC_0600
* @tc.name fileio_copy_file_async_006
* @tc.desc Test copyFileAsync() interfaces, No parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_copy_file_async_006
'
,
0
,
async
function
(
done
)
{
try
{
await
fileio
.
copyFile
();
}
catch
(
e
)
{
console
.
info
(
'
fileio_copy_file_async_006 has failed for
'
+
e
);
expect
(
e
.
message
==
'
Number of arguments unmatched
'
).
assertTrue
();
done
();
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录