Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
8e525ed9
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,发现更多精彩内容 >>
未验证
提交
8e525ed9
编写于
3月 17, 2023
作者:
Y
yueye
提交者:
Gitee
3月 17, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[xts-acts][storage][master]补充8条fileio读写速率测试用例
Signed-off-by:
N
yueye
<
yueye2@huawei.com
>
上级
b0ca8538
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
341 addition
and
0 deletion
+341
-0
storage/storagefileiov9jstest/src/main/js/test/Common.js
storage/storagefileiov9jstest/src/main/js/test/Common.js
+19
-0
storage/storagefileiov9jstest/src/main/js/test/List.test.js
storage/storagefileiov9jstest/src/main/js/test/List.test.js
+2
-0
storage/storagefileiov9jstest/src/main/js/test/members/filerw.test.js
...agefileiov9jstest/src/main/js/test/members/filerw.test.js
+320
-0
未找到文件。
storage/storagefileiov9jstest/src/main/js/test/Common.js
浏览文件 @
8e525ed9
...
...
@@ -39,6 +39,25 @@ export function prepareFile(fpath, content) {
}
}
export
function
prepare200MFile
(
fpath
)
{
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
CREATE
|
fileIO
.
OpenMode
.
READ_WRITE
)
fileIO
.
truncateSync
(
file
.
fd
)
let
bf
=
new
ArrayBuffer
(
1024
*
1024
*
20
);
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
let
position
=
bf
.
byteLength
*
i
;
let
writeLen
=
fileIO
.
writeSync
(
file
.
fd
,
bf
,
{
offset
:
0
,
length
:
bf
.
byteLength
,
position
:
position
,
encoding
:
'
utf-8
'
});
}
fileIO
.
fsyncSync
(
file
.
fd
)
fileIO
.
closeSync
(
file
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
Failed to prepare200MFile for
'
+
e
)
return
false
}
}
export
async
function
nextFileName
(
testName
)
{
let
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
getCacheDir
();
...
...
storage/storagefileiov9jstest/src/main/js/test/List.test.js
浏览文件 @
8e525ed9
...
...
@@ -41,6 +41,7 @@ import fileIOSymlink from './members/symlink.test.js'
import
fileIOTruncate
from
'
./members/truncate.test.js
'
import
fileIOUnlink
from
'
./members/unlink.test.js
'
import
fileIOWrite
from
'
./members/write.test.js
'
import
fileIORW
from
'
./members/filerw.test.js
'
export
default
function
testsuite
()
{
fileIOAccess
()
fileIOClose
()
...
...
@@ -70,4 +71,5 @@ export default function testsuite() {
fileIOTruncate
()
fileIOUnlink
()
fileIOWrite
()
fileIORW
()
}
storage/storagefileiov9jstest/src/main/js/test/members/filerw.test.js
0 → 100644
浏览文件 @
8e525ed9
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
fileIO
,
FILE_CONTENT
,
prepareFile
,
prepare200MFile
,
nextFileName
,
isIntNum
,
describe
,
it
,
expect
,
}
from
'
../Common
'
;
export
default
function
FileIOFilerw_test
()
{
describe
(
'
FileIO_fs_filerw_test
'
,
function
()
{
async
function
IOfunc
(
file
,
bf
,
total
,
rand
,
read
,
promise
)
{
let
date
=
new
Date
();
let
startTime
=
new
Date
(
date
.
getUTCFullYear
(),
date
.
getUTCMonth
(),
date
.
getUTCDate
(),
date
.
getUTCHours
(),
date
.
getUTCMinutes
(),
date
.
getUTCSeconds
(),
date
.
getUTCMilliseconds
()).
getTime
();
try
{
var
array
=
new
ArrayBuffer
(
bf
);
var
count
=
total
/
bf
;
for
(
let
i
=
0
;
i
<
count
;
i
++
)
{
var
offset
=
i
*
bf
;
if
(
rand
)
{
offset
=
Math
.
floor
(
Math
.
random
()
*
(
total
-
bf
));
}
if
(
promise
)
{
if
(
read
)
{
fileIO
.
read
(
file
.
fd
,
array
,
{
length
:
bf
,
offset
:
offset
}).
then
((
readLen
)
=>
{
console
.
log
(
'
fileIO_test_read_promise succeed
'
+
readLen
);
}).
catch
((
e
)
=>
{
console
.
log
(
'
fileIO_test_read_promise has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
});
}
else
{
fileIO
.
write
(
file
.
fd
,
array
,
{
length
:
bf
,
offset
:
offset
,
encoding
:
'
utf-8
'
}).
then
((
writeLen
)
=>
{
console
.
log
(
'
fileIO_test_write_promise succeed
'
+
writeLen
);
}).
catch
((
e
)
=>
{
console
.
log
(
'
fileIO_test_write_promise has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
});
}
}
else
{
if
(
read
)
{
fileIO
.
read
(
file
.
fd
,
array
,
{
length
:
bf
,
offset
:
offset
},
(
err
,
readLen
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_read_callback has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
}
});
}
else
{
fileIO
.
write
(
file
.
fd
,
array
,
{
length
:
bf
,
offset
:
offset
,
encoding
:
'
utf-8
'
},
(
err
,
writeLen
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_write_callback has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
}
});
}
}
}
fileIO
.
fsyncSync
(
file
.
fd
);
}
catch
(
e
)
{
console
.
log
(
'
FileIO_fs_filerw_test has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
}
finally
{
date
=
new
Date
();
let
endTime
=
new
Date
(
date
.
getUTCFullYear
(),
date
.
getUTCMonth
(),
date
.
getUTCDate
(),
date
.
getUTCHours
(),
date
.
getUTCMinutes
(),
date
.
getUTCSeconds
(),
date
.
getUTCMilliseconds
()).
getTime
();
console
.
log
(
"
FileIO_fs_filerw_test finally
"
+
JSON
.
stringify
(
endTime
))
var
interval
=
endTime
-
startTime
;
var
average
=
total
*
1000
/
interval
;
var
averagerate
=
average
/
0x100000
;
return
averagerate
;
}
}
/**
* @tc.number SUB_DF_FILEIO_FILERW_READ_RANDOM_PROMISE_0000
* @tc.name fileIO_test_read_random_promise_000
* @tc.desc Test the read() interface. promise.
* Open the file, file read() in the random way.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_read_random_promise_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_read_random_promise_000
'
);
expect
(
prepare200MFile
(
fpath
)).
assertTrue
;
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_ONLY
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
averagerate
=
await
IOfunc
(
file
,
0x1000
,
0xC800000
,
true
,
true
,
true
);
console
.
log
(
"
Rand_Read Rate is
"
+
averagerate
);
expect
(
averagerate
>
3.5
).
assertTrue
();
fileIO
.
closeSync
(
file
);
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_read_random_promise_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FILERW_WRITE_RANDOM_PROMISE_0000
* @tc.name fileIO_test_write_random_promise_000
* @tc.desc Test the write() interface. promise.
* Open the file, file write() in the random way.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_write_random_promise_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_write_random_promise_000
'
);
expect
(
prepare200MFile
(
fpath
)).
assertTrue
;
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
averagerate
=
await
IOfunc
(
file
,
0x1000
,
0xC800000
,
true
,
false
,
true
);
console
.
log
(
"
Rand_Write Rate is
"
+
averagerate
);
expect
(
averagerate
>
0.5
).
assertTrue
();
fileIO
.
closeSync
(
file
);
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_write_random_promise_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FILERW_READ_SEQUENCE_PROMISE_0000
* @tc.name fileIO_test_read_sequence_promise_000
* @tc.desc Test the read() interface. promise.
* Open the file, file read() in the sequence way.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_read_sequence_promise_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_read_sequence_promise_000
'
);
expect
(
prepare200MFile
(
fpath
)).
assertTrue
;
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_ONLY
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
averagerate
=
await
IOfunc
(
file
,
0x1000
,
0xC800000
,
false
,
true
,
true
);
console
.
log
(
"
Sequence_Read Rate is
"
+
averagerate
);
expect
(
averagerate
>
15
).
assertTrue
();
fileIO
.
closeSync
(
file
);
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_read_sequence_promise_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FILERW_WRITE_SEQUENCE_PROMISE_0000
* @tc.name fileIO_test_write_sequence_promise_000
* @tc.desc Test the write() interface. promise.
* Open the file, file write() in the sequence way.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_write_sequence_promise_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_write_sequence_promise_000
'
);
expect
(
prepare200MFile
(
fpath
)).
assertTrue
;
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
averagerate
=
await
IOfunc
(
file
,
0x1000
,
0xC800000
,
false
,
false
,
true
);
console
.
log
(
"
Sequence_WRITE Rate is
"
+
averagerate
);
expect
(
averagerate
>
5
).
assertTrue
();
fileIO
.
closeSync
(
file
);
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_write_sequence_promise_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FILERW_READ_RANDOM_CALLBACK_0000
* @tc.name fileIO_test_read_random_callback_000
* @tc.desc Test the read() interface. callback.
* Open the file, file read() in the random way.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_read_random_callback_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_read_random_callback_000
'
);
expect
(
prepare200MFile
(
fpath
)).
assertTrue
;
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_ONLY
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
averagerate
=
await
IOfunc
(
file
,
0x1000
,
0xC800000
,
true
,
true
,
false
);
console
.
log
(
"
Rand_Read Rate is
"
+
averagerate
);
expect
(
averagerate
>
3.5
).
assertTrue
();
fileIO
.
closeSync
(
file
);
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_read_random_callback_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FILERW_WRITE_RANDOM_CALLBACK_0000
* @tc.name fileIO_test_write_random_callback_000
* @tc.desc Test the write() interface. callback.
* Open the file, file write() in the random way.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_write_random_callback_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_write_random_callback_000
'
);
expect
(
prepare200MFile
(
fpath
)).
assertTrue
;
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
averagerate
=
await
IOfunc
(
file
,
0x1000
,
0xC800000
,
true
,
false
,
false
);
console
.
log
(
"
Rand_Write Rate is
"
+
averagerate
);
expect
(
averagerate
>
0.5
).
assertTrue
();
fileIO
.
closeSync
(
file
);
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_write_random_callback_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FILERW_READ_SEQUENCE_CALLBACK_0000
* @tc.name fileIO_test_read_sequence_callback_000
* @tc.desc Test the read() interface. callback.
* Open the file, file read() in the sequence way.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_read_sequence_callback_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_read_sequence_callback_000
'
);
expect
(
prepare200MFile
(
fpath
)).
assertTrue
;
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_ONLY
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
averagerate
=
await
IOfunc
(
file
,
0x1000
,
0xC800000
,
false
,
true
,
false
);
console
.
log
(
"
Sequence_Read Rate is
"
+
averagerate
);
expect
(
averagerate
>
15
).
assertTrue
();
fileIO
.
closeSync
(
file
);
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_read_sequence_callback_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FILERW_WRITE_SEQUENCE_CALLBACK_0000
* @tc.name fileIO_test_write_sequence_callback_000
* @tc.desc Test the write() interface. callback.
* Open the file, file write() in the sequence way.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_write_sequence_callback_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_write_sequence_callback_000
'
);
expect
(
prepare200MFile
(
fpath
)).
assertTrue
;
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
averagerate
=
await
IOfunc
(
file
,
0x1000
,
0xC800000
,
false
,
false
,
false
);
console
.
log
(
"
Sequence_WRITE Rate is
"
+
averagerate
);
expect
(
averagerate
>
5
).
assertTrue
();
fileIO
.
closeSync
(
file
);
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_write_sequence_callback_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
});
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录