Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
eb6e919f
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看板
提交
eb6e919f
编写于
9月 02, 2022
作者:
R
raoxian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增randomaccessfile测试用例
Signed-off-by:
N
raoxian
<
raoxian@huawei.com
>
上级
6090e20d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
152 addition
and
1 deletion
+152
-1
storage/storagefileiojstest/src/main/js/test/module_fileio/members/createRandomAccessFile.test.js
...test/module_fileio/members/createRandomAccessFile.test.js
+152
-1
未找到文件。
storage/storagefileiojstest/src/main/js/test/module_fileio/members/createRandomAccessFile.test.js
浏览文件 @
eb6e919f
...
...
@@ -382,11 +382,61 @@ describe('fileio_create_randomAccessFile', function () {
randomaccessfile
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_create_randomaccessfile_sync_01
5
has failed for
'
+
err
);
console
.
info
(
'
fileio_create_randomaccessfile_sync_01
4
has failed for
'
+
err
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_STORAGE_FILEIO_CREATE_RANDOMACCESSFILE_SYNC_1500
* @tc.name fileio_create_randomaccessfile_sync_015
* @tc.desc Test createRandomAccessFileSync() interface. flags=0o200002. Invalid filepath.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_create_randomaccessfile_sync_015
'
,
0
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
fileio_create_randomaccessfile_sync_015
'
)
+
'
d
'
;
fileio
.
mkdirSync
(
dpath
);
try
{
fileio
.
createRandomAccessFileSync
(
dpath
,
0
,
0o200002
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_create_randomaccessfile_sync_015 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid filepath
"
).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
}
});
/**
* @tc.number SUB_STORAGE_FILEIO_CREATE_RANDOMACCESSFILE_SYNC_1600
* @tc.name fileio_create_randomaccessfile_sync_016
* @tc.desc Test createRandomAccessFileSync() interface. flags=0o400002. Symbolic link loop.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_create_randomaccessfile_sync_016
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_create_randomaccessfile_sync_016
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlinkSync
(
fpath
,
ffpath
);
fileio
.
createRandomAccessFileSync
(
ffpath
,
0
,
0o400002
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_create_randomaccessfile_sync_016 has failed for
'
+
err
);
expect
(
err
.
message
==
'
Symbolic link loop
'
||
err
.
message
==
'
Too many symbolic links encountered
'
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
}
});
/**
* @tc.number SUB_STORAGE_FILEIO_CREATE_RANDOMACCESSFILE_ASYNC_0000
* @tc.name fileio_create_randomaccessfile_async_000
...
...
@@ -765,5 +815,106 @@ describe('fileio_create_randomAccessFile', function () {
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_STORAGE_FILEIO_CREATE_RANDOMACCESSFILE_ASYNC_1500
* @tc.name fileio_create_randomaccessfile_async_015
* @tc.desc Test createRandomAccessFile() interface. flags=0o200002. Invalid filepath.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_create_randomaccessfile_async_015
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
nextFileName
(
'
fileio_create_randomaccessfile_async_015
'
)
+
'
d
'
;
fileio
.
mkdirSync
(
dpath
);
try
{
await
fileio
.
createRandomAccessFile
(
dpath
,
0
,
0o200002
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_create_randomaccessfile_async_015 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid filepath
"
).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
done
();
}
});
/**
* @tc.number SUB_STORAGE_FILEIO_CREATE_RANDOMACCESSFILE_ASYNC_1600
* @tc.name fileio_create_randomaccessfile_async_016
* @tc.desc Test createRandomAccessFile() interface. flags=0o400002. Symbolic link loop.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_create_randomaccessfile_async_016
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_create_randomaccessfile_async_016
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlinkSync
(
fpath
,
ffpath
);
await
fileio
.
createRandomAccessFile
(
ffpath
,
0
,
0o400002
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_create_randomaccessfile_async_016 has failed for
'
+
err
);
expect
(
err
.
message
==
'
Symbolic link loop
'
||
err
.
message
==
'
Too many symbolic links encountered
'
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
done
();
}
});
/**
* @tc.number SUB_STORAGE_FILEIO_RANDOMACCESSFILE_MULTITHREADED_REPLICATION_0000
* @tc.name fileio_randomaccessfile_multithreaded_replication_000
* @tc.desc Test createRandomAccessFileSync() interface. Test multi-threaded replication.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_randomaccessfile_multithreaded_replication_000
'
,
0
,
async
function
(
done
)
{
let
srcpath
=
await
nextFileName
(
'
fileio_randomaccessfile_multithreaded_replication_000
'
);
let
dstpath
=
await
nextFileName
(
'
fileio_randomaccessfile_multithreaded_replication_000_1
'
);
let
length
=
4096
;
let
buffer
=
new
ArrayBuffer
(
length
);
expect
(
prepareFile
(
srcpath
,
buffer
)).
assertTrue
();
try
{
let
fileSize
=
fileio
.
statSync
(
srcpath
).
size
;
// init randomaccessfiles
let
threadNums
=
4
;
let
srcfiles
=
new
Array
();
let
dstfiles
=
new
Array
();
for
(
let
i
=
0
;
i
<
threadNums
;
i
++
)
{
srcfiles
[
i
]
=
fileio
.
createRandomAccessFileSync
(
srcpath
,
fileSize
/
threadNums
*
i
,
0o2
);
dstfiles
[
i
]
=
fileio
.
createRandomAccessFileSync
(
dstpath
,
fileSize
/
threadNums
*
i
,
0o102
);
}
// copy in every thread i from multi-thread
let
bufs
=
new
Array
(
threadNums
);
let
len
=
length
/
threadNums
;
for
(
let
i
=
0
;
i
<
threadNums
;
i
++
)
{
bufs
[
i
]
=
new
ArrayBuffer
(
len
);
srcfiles
[
i
].
read
(
bufs
[
i
]).
then
(
async
function
(
readOut
)
{
let
writeLen
=
await
dstfiles
[
i
].
write
(
readOut
.
buffer
);
expect
(
writeLen
==
len
).
assertTrue
();
dstfiles
[
i
].
closeSync
();
srcfiles
[
i
].
closeSync
();
if
(
i
==
threadNums
-
1
)
{
let
size
=
fileio
.
statSync
(
dstpath
).
size
;
expect
(
size
==
fileSize
).
assertTrue
();
fileio
.
unlinkSync
(
srcpath
);
fileio
.
unlinkSync
(
dstpath
);
done
();
}
});
}
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_multithreaded_replication_000 has failed for
'
+
err
);
expect
(
null
).
assertFail
();
}
});
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录