Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
10062de0
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看板
提交
10062de0
编写于
12月 29, 2022
作者:
F
futurezhou
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modified XTS for open and truncate interface
Signed-off-by:
N
futurezhou
<
zhouweilai@huawei.com
>
上级
eb82e5a8
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
766 addition
and
278 deletion
+766
-278
storage/storagefileiov9jstest/src/main/js/test/members/open.test.js
...oragefileiov9jstest/src/main/js/test/members/open.test.js
+672
-187
storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js
...efileiov9jstest/src/main/js/test/members/truncate.test.js
+94
-91
未找到文件。
storage/storagefileiov9jstest/src/main/js/test/members/open.test.js
浏览文件 @
10062de0
此差异已折叠。
点击以展开。
storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js
浏览文件 @
10062de0
...
...
@@ -24,7 +24,8 @@ import {
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0000
* @tc.name fileIO_truncate_async_000
* @tc.desc Test the truncate() interface that receives the fpath parameter.
* @tc.desc Test the truncate() interface. Promise.
* Truncate the file with path and truncateLen = 5.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
...
...
@@ -53,7 +54,8 @@ import {
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0100
* @tc.name fileIO_truncate_async_001
* @tc.desc Test the truncate() interface that receives the fd parameter.
* @tc.desc Test the truncate() interface. Callback.
* Truncate the file with fd and truncateLen = 5.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
...
...
@@ -62,13 +64,16 @@ import {
it
(
'
fileIO_truncate_async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_truncate_async_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
file
;
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
)
;
let
truncateLen
=
5
;
try
{
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
fileIO
.
truncate
(
file
.
fd
,
truncateLen
,
function
(
err
)
{
fileIO
.
truncate
(
file
.
fd
,
truncateLen
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_truncate_async_001 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
let
len
=
fileIO
.
readSync
(
file
.
fd
,
new
ArrayBuffer
(
4096
));
expect
(
len
==
truncateLen
).
assertTrue
();
fileio
.
closeSync
(
file
.
fd
);
...
...
@@ -84,7 +89,8 @@ import {
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0200
* @tc.name fileIO_truncate_async_002
* @tc.desc Test the truncate() interface that receives the fpath parameter.
* @tc.desc Test the truncate() interface. Promise.then().catch
* Truncate the file with path and truncateLen = 2.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
...
...
@@ -96,23 +102,20 @@ import {
let
truncateLen
=
2
;
try
{
fileIO
.
truncate
(
fpath
,
truncateLen
)
.
then
(
function
(
err
)
{
expect
(
err
==
null
).
assertTrue
();
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
len
=
fileIO
.
readSync
(
file
.
fd
,
new
ArrayBuffer
(
4096
));
expect
(
len
==
truncateLen
).
assertTrue
();
fileio
.
closeSync
(
file
.
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
})
.
catch
(
function
(
e
)
{
console
.
log
(
'
catch
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
});
fileIO
.
truncate
(
fpath
,
truncateLen
).
then
(()
=>
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
len
=
fileIO
.
readSync
(
file
.
fd
,
new
ArrayBuffer
(
4096
));
expect
(
len
==
truncateLen
).
assertTrue
();
fileio
.
closeSync
(
file
.
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
fileIO_truncate_async_002 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_truncate_async_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
console
.
log
(
'
fileIO_truncate_async_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
...
...
@@ -120,7 +123,8 @@ import {
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0300
* @tc.name fileIO_truncate_async_003
* @tc.desc Test the truncate() interface that receives the fd parameter.
* @tc.desc Test the truncate() interface. Promise.then().catch
* Truncate the file with fd and truncateLen = 2.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
...
...
@@ -129,26 +133,23 @@ import {
it
(
'
fileIO_truncate_async_003
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_truncate_async_003
'
);
expect
(
prepareFile
(
fpath
,
'
truncate
'
)).
assertTrue
();
let
file
;
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
)
;
let
truncateLen
=
2
;
try
{
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
fileIO
.
truncate
(
file
.
fd
,
truncateLen
)
.
then
(
function
(
err
)
{
expect
(
err
==
null
).
assertTrue
();
let
len
=
fileIO
.
readSync
(
file
.
fd
,
new
ArrayBuffer
(
4096
));
expect
(
len
==
truncateLen
).
assertTrue
();
fileio
.
closeSync
(
file
.
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
})
.
catch
(
function
(
e
)
{
console
.
log
(
'
catch
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
})
fileIO
.
truncate
(
file
.
fd
,
truncateLen
).
then
(()
=>
{
let
len
=
fileIO
.
readSync
(
file
.
fd
,
new
ArrayBuffer
(
4096
));
expect
(
len
==
truncateLen
).
assertTrue
();
fileio
.
closeSync
(
file
.
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
fileIO_truncate_async_003 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
})
}
catch
(
e
)
{
console
.
log
(
'
fileIO_truncate_async_003 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
console
.
log
(
'
fileIO_truncate_async_003 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
...
...
@@ -156,7 +157,8 @@ import {
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0400
* @tc.name fileIO_truncate_async_004
* @tc.desc Test the truncate() interface that receives the fpath parameter.
* @tc.desc Test the truncate() interface. Callback.
* Truncate the file with path and truncateLen = 2.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
...
...
@@ -167,13 +169,39 @@ import {
let
truncateLen
=
2
;
try
{
fileIO
.
truncate
(
fpath
,
truncateLen
,
function
(
err
)
{
done
();
fileIO
.
truncate
(
fpath
,
truncateLen
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_truncate_async_004 error package: {
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
expect
(
err
.
code
==
13900002
&&
err
.
message
==
'
No such file or directory
'
).
assertTrue
();
done
();
}
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_truncate_async_004 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
!!
e
).
assertTrue
();
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
console
.
log
(
'
fileIO_truncate_async_004 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0500
* @tc.name fileIO_truncate_async_005
* @tc.desc Test the truncate() interface. Promise.
* Truncate the file with path and truncateLen = 2.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_truncate_async_005
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_truncate_async_005
'
);
let
truncateLen
=
2
;
try
{
await
fileIO
.
truncate
(
fpath
,
truncateLen
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_truncate_async_005 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900002
&&
e
.
message
==
'
No such file or directory
'
).
assertTrue
();
done
();
}
});
...
...
@@ -181,7 +209,8 @@ import {
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0000
* @tc.name fileIO_test_truncate_sync_000
* @tc.desc Test the truncateSync() interface that receives the fpath parameter.
* @tc.desc Test the truncateSync() interface.
* Truncate the file with path.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
...
...
@@ -196,7 +225,7 @@ import {
expect
(
fileIO
.
statSync
(
fpath
).
size
==
0
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_truncate_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
console
.
log
(
'
fileIO_test_truncate_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
...
...
@@ -204,7 +233,8 @@ import {
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0100
* @tc.name fileIO_test_truncate_sync_001
* @tc.desc Test the truncateSync() interface that receives the fd parameter.
* @tc.desc Test the truncateSync() interface.
* Truncate the file with fd and truncateLen = 5.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
...
...
@@ -213,11 +243,10 @@ import {
it
(
'
fileIO_test_truncate_sync_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_truncate_sync_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
file
;
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
)
;
let
truncateLen
=
5
;
try
{
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
fileIO
.
truncateSync
(
file
.
fd
,
truncateLen
);
let
len
=
fileIO
.
readSync
(
file
.
fd
,
new
ArrayBuffer
(
4096
));
...
...
@@ -225,7 +254,7 @@ import {
fileio
.
closeSync
(
file
.
fd
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_truncate_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
console
.
log
(
'
fileIO_test_truncate_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
...
...
@@ -233,7 +262,8 @@ import {
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0200
* @tc.name fileIO_test_truncate_sync_002
* @tc.desc Test the truncateSync() interface that receives the fpath parameter.
* @tc.desc Test the truncateSync() interface.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
...
...
@@ -243,10 +273,10 @@ import {
let
fpath
=
await
nextFileName
(
'
fileIO_test_truncate_sync_002
'
);
try
{
let
stat
=
fileIO
.
truncateSync
(
fpath
);
console
.
info
(
'
fileIO_test_truncate_sync_002 =
'
+
stat
);
fileIO
.
truncateSync
(
fpath
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_truncate_sync_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900002
&&
e
.
message
==
'
No such file or directory
'
).
assertTrue
();
}
});
...
...
@@ -254,69 +284,42 @@ import {
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0300
* @tc.name fileIO_test_truncate_sync_003
* @tc.desc Test the truncateSync() interface
that receives the f
d parameter.
* @tc.desc Test the truncateSync() interface
. Invali
d parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_truncate_sync_003
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_truncate_sync_003
'
);
expect
(
prepareFile
(
fpath
,
'
truncate
'
)).
assertTrue
();
let
file
;
let
truncateLen
=
2
;
try
{
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
fileIO
.
truncateSync
(
file
.
fd
,
truncateLen
);
let
len
=
fileIO
.
readSync
(
file
.
fd
,
new
ArrayBuffer
(
4096
));
expect
(
len
==
truncateLen
).
assertTrue
();
fileio
.
closeSync
(
file
.
fd
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_truncate_sync_003 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
fileIO
.
truncateSync
(
-
1
,
truncateLen
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_truncate_sync_003 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0400
* @tc.name fileIO_test_truncate_sync_004
* @tc.desc Test truncateSync() interfaces.
* @tc.desc Test truncateSync() interfaces.
Missing parameters.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_truncate_sync_004
'
,
0
,
function
()
{
try
{
let
stat
=
fileIO
.
truncateSync
();
console
.
info
(
'
fileIO_test_truncate_sync_004 =
'
+
stat
);
fileIO
.
truncateSync
();
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_truncate_sync_004 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0500
* @tc.name fileIO_test_truncate_sync_005
* @tc.desc Test truncateSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_truncate_sync_005
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_truncate_sync_005
'
);
let
truncateLen
=
2
;
try
{
fileIO
.
truncateSync
(
fpath
,
truncateLen
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_truncate_sync_005 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
!!
e
).
assertTrue
();
}
});
});
})
}
鸿蒙社区
@harmonycommunity
mentioned in commit
96a60023
·
1月 17, 2023
mentioned in commit
96a60023
mentioned in commit 96a600233b52f145d253dab16cd1b428c5c6d06c
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录