Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
66bce73b
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,发现更多精彩内容 >>
未验证
提交
66bce73b
编写于
2月 23, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 23, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7643 【file_api】统一修改用例注释标签,除去旧接口的引入
Merge pull request !7643 from zhuhongtao666/modefied_code
上级
e01b0c52
0edfcc10
变更
24
展开全部
隐藏空白更改
内联
并排
Showing
24 changed file
with
2192 addition
and
2203 deletion
+2192
-2203
storage/storagefileiov9jstest/src/main/js/test/Common.js
storage/storagefileiov9jstest/src/main/js/test/Common.js
+3
-64
storage/storagefileiov9jstest/src/main/js/test/class_stream/close.test.js
...ileiov9jstest/src/main/js/test/class_stream/close.test.js
+31
-31
storage/storagefileiov9jstest/src/main/js/test/class_stream/flush.test.js
...ileiov9jstest/src/main/js/test/class_stream/flush.test.js
+29
-29
storage/storagefileiov9jstest/src/main/js/test/class_stream/read.test.js
...fileiov9jstest/src/main/js/test/class_stream/read.test.js
+111
-110
storage/storagefileiov9jstest/src/main/js/test/class_stream/write.test.js
...ileiov9jstest/src/main/js/test/class_stream/write.test.js
+145
-145
storage/storagefileiov9jstest/src/main/js/test/members/access.test.js
...agefileiov9jstest/src/main/js/test/members/access.test.js
+9
-9
storage/storagefileiov9jstest/src/main/js/test/members/close.test.js
...ragefileiov9jstest/src/main/js/test/members/close.test.js
+11
-12
storage/storagefileiov9jstest/src/main/js/test/members/createStream.test.js
...eiov9jstest/src/main/js/test/members/createStream.test.js
+78
-78
storage/storagefileiov9jstest/src/main/js/test/members/fdatasync.test.js
...fileiov9jstest/src/main/js/test/members/fdatasync.test.js
+32
-33
storage/storagefileiov9jstest/src/main/js/test/members/fdopenStream.test.js
...eiov9jstest/src/main/js/test/members/fdopenStream.test.js
+80
-80
storage/storagefileiov9jstest/src/main/js/test/members/fileLock.test.js
...efileiov9jstest/src/main/js/test/members/fileLock.test.js
+625
-626
storage/storagefileiov9jstest/src/main/js/test/members/fsync.test.js
...ragefileiov9jstest/src/main/js/test/members/fsync.test.js
+31
-32
storage/storagefileiov9jstest/src/main/js/test/members/listFile.test.js
...efileiov9jstest/src/main/js/test/members/listFile.test.js
+33
-33
storage/storagefileiov9jstest/src/main/js/test/members/lstat.test.js
...ragefileiov9jstest/src/main/js/test/members/lstat.test.js
+67
-67
storage/storagefileiov9jstest/src/main/js/test/members/mkdir.test.js
...ragefileiov9jstest/src/main/js/test/members/mkdir.test.js
+2
-2
storage/storagefileiov9jstest/src/main/js/test/members/moveFile.test.js
...efileiov9jstest/src/main/js/test/members/moveFile.test.js
+34
-34
storage/storagefileiov9jstest/src/main/js/test/members/open.test.js
...oragefileiov9jstest/src/main/js/test/members/open.test.js
+148
-149
storage/storagefileiov9jstest/src/main/js/test/members/read.test.js
...oragefileiov9jstest/src/main/js/test/members/read.test.js
+157
-163
storage/storagefileiov9jstest/src/main/js/test/members/rmdir.test.js
...ragefileiov9jstest/src/main/js/test/members/rmdir.test.js
+17
-17
storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js
...oragefileiov9jstest/src/main/js/test/members/stat.test.js
+219
-219
storage/storagefileiov9jstest/src/main/js/test/members/symlink.test.js
...gefileiov9jstest/src/main/js/test/members/symlink.test.js
+13
-13
storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js
...efileiov9jstest/src/main/js/test/members/truncate.test.js
+106
-39
storage/storagefileiov9jstest/src/main/js/test/members/unlink.test.js
...agefileiov9jstest/src/main/js/test/members/unlink.test.js
+7
-8
storage/storagefileiov9jstest/src/main/js/test/members/write.test.js
...ragefileiov9jstest/src/main/js/test/members/write.test.js
+204
-210
未找到文件。
storage/storagefileiov9jstest/src/main/js/test/Common.js
浏览文件 @
66bce73b
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 2022
-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
...
...
@@ -13,7 +13,6 @@
* limitations under the License.
*/
import
fileio
from
'
@ohos.fileio
'
;
import
fileIO
from
'
@ohos.file.fs
'
;
import
util
from
'
@ohos.util
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
...
...
@@ -30,8 +29,8 @@ export function prepareFile(fpath, content) {
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
CREATE
|
fileIO
.
OpenMode
.
READ_WRITE
)
fileIO
.
truncateSync
(
file
.
fd
)
fileIO
.
writeSync
(
file
.
fd
,
content
)
file
io
.
fsyncSync
(
file
.
fd
)
file
io
.
closeSync
(
file
.
fd
)
file
IO
.
fsyncSync
(
file
.
fd
)
file
IO
.
closeSync
(
file
)
return
true
}
catch
(
e
)
{
...
...
@@ -40,46 +39,6 @@ export function prepareFile(fpath, content) {
}
}
export
function
prepareEmptyFile
(
fpath
)
{
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
CREATE
|
fileIO
.
OpenMode
.
READ_WRITE
)
fileio
.
closeSync
(
file
.
fd
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
Failed to prepareFile for
'
+
e
)
return
false
}
}
export
function
fileToReadOnly
(
fpath
)
{
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
CREATE
)
fileio
.
fchmodSync
(
file
.
fd
,
0o444
)
fileio
.
fsyncSync
(
file
.
fd
)
fileio
.
closeSync
(
file
.
fd
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
Failed to fileToReadOnly for
'
+
e
);
return
false
}
}
export
function
fileToWriteOnly
(
fpath
)
{
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
CREATE
|
fileIO
.
OpenMode
.
WRITE_ONLY
)
fileio
.
fchmodSync
(
file
.
fd
,
0o222
)
fileio
.
fsyncSync
(
file
.
fd
)
fileio
.
closeSync
(
file
.
fd
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
Failed to fileToWriteOnly
'
+
e
)
return
false
}
}
export
async
function
nextFileName
(
testName
)
{
let
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
getCacheDir
();
...
...
@@ -105,15 +64,6 @@ export function randomString(num) {
return
pwd
;
}
export
function
forceRemoveDir
(
path
,
num
)
{
for
(
let
i
=
num
;
i
>=
0
;
i
--
)
{
if
(
i
<
num
)
{
path
=
path
.
replace
(
`/d
${
i
}
`
,
""
);
}
fileio
.
rmdirSync
(
path
);
}
}
function
isIntNum
(
val
)
{
return
typeof
val
===
'
number
'
&&
val
%
1
===
0
;
}
...
...
@@ -126,22 +76,11 @@ function isString(str) {
return
(
typeof
str
==
'
string
'
)
&&
str
.
constructor
==
String
;
}
function
isBoolean
(
val
)
{
return
typeof
val
==
'
boolean
'
;
}
function
isInclude
(
error
,
message
)
{
return
error
.
toString
().
indexOf
(
message
)
!=
-
1
;
}
export
{
fileio
,
fileIO
,
isIntNum
,
isBigInt
,
isString
,
isBoolean
,
isInclude
,
describe
,
it
,
expect
,
...
...
storage/storagefileiov9jstest/src/main/js/test/class_stream/close.test.js
浏览文件 @
66bce73b
...
...
@@ -21,7 +21,7 @@ export default function fileIOStreamClose() {
describe
(
'
fileIO_fs_stream_close
'
,
function
()
{
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0000
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE
_
SYNC_0000
* @tc.name fileIO_test_stream_close_sync_000
* @tc.desc Test the closeSync() interface of class Stream.
* Open a file stream, close file stream.
...
...
@@ -35,9 +35,9 @@ describe('fileIO_fs_stream_close', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
closeSync
();
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_close_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -46,7 +46,7 @@ describe('fileIO_fs_stream_close', function () {
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0100
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE
_
SYNC_0100
* @tc.name fileIO_test_stream_close_sync_001
* @tc.desc Test the closeSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters.
...
...
@@ -58,14 +58,14 @@ describe('fileIO_fs_stream_close', function () {
it
(
'
fileIO_test_stream_close_sync_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_close_sync_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
closeSync
(
1
);
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
closeSync
(
1
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_close_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
...
...
@@ -73,7 +73,7 @@ describe('fileIO_fs_stream_close', function () {
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0200
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE
_
SYNC_0200
* @tc.name fileIO_test_stream_close_sync_002
* @tc.desc Test the closeSync() interface of class Stream.
* The file stream has been closed.
...
...
@@ -85,12 +85,12 @@ describe('fileIO_fs_stream_close', function () {
it
(
'
fileIO_test_stream_close_sync_002
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_close_sync_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
closeSync
();
s
s
.
closeSync
();
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
closeSync
();
s
r
.
closeSync
();
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
unlinkSync
(
fpath
);
...
...
@@ -100,7 +100,7 @@ describe('fileIO_fs_stream_close', function () {
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0000
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE
_
ASYNC_0000
* @tc.name fileIO_test_stream_close_async_000
* @tc.desc Test the close() interface of class Stream. Promise.
* Open a file stream, close file stream.
...
...
@@ -114,9 +114,9 @@ describe('fileIO_fs_stream_close', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
s
s
!==
null
).
assertTrue
();
await
s
s
.
close
();
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
s
r
!==
null
).
assertTrue
();
await
s
r
.
close
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -126,7 +126,7 @@ describe('fileIO_fs_stream_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0100
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE
_
ASYNC_0100
* @tc.name fileIO_test_stream_close_async_001
* @tc.desc Test the close() interface of class Stream. Callback.
* Open a file stream, close file stream.
...
...
@@ -140,9 +140,9 @@ describe('fileIO_fs_stream_close', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
close
((
err
)
=>
{
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
close
((
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_stream_close_async_001 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
...
...
@@ -157,7 +157,7 @@ describe('fileIO_fs_stream_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0200
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE
_
ASYNC_0200
* @tc.name fileIO_test_stream_close_async_002
* @tc.desc Test the close() interface of class Stream. Promise.
* The file stream has been closed.
...
...
@@ -171,10 +171,10 @@ describe('fileIO_fs_stream_close', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
s
s
!==
null
).
assertTrue
();
await
s
s
.
close
();
await
s
s
.
close
();
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
s
r
!==
null
).
assertTrue
();
await
s
r
.
close
();
await
s
r
.
close
();
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
unlinkSync
(
fpath
);
...
...
@@ -185,7 +185,7 @@ describe('fileIO_fs_stream_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0300
* @tc.number SUB_DF_FILEIO_STREAM_CLOSE
_
ASYNC_0300
* @tc.name fileIO_test_stream_close_async_003
* @tc.desc Test the close() interface of class Stream. Promise.
* Invalid parameter, don't requrie any parameters.
...
...
@@ -199,9 +199,9 @@ describe('fileIO_fs_stream_close', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
s
s
!==
null
).
assertTrue
();
await
s
s
.
close
(
1
);
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
s
r
!==
null
).
assertTrue
();
await
s
r
.
close
(
1
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
unlinkSync
(
fpath
);
...
...
storage/storagefileiov9jstest/src/main/js/test/class_stream/flush.test.js
浏览文件 @
66bce73b
...
...
@@ -21,7 +21,7 @@ export default function fileIOStreamFlush() {
describe
(
'
fileIO_fs_stream_flush
'
,
function
()
{
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0000
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH
_
SYNC_0000
* @tc.name fileIO_test_stream_flush_sync_000
* @tc.desc Test the flushSync() interface of class Stream.
* Refresh file stream.
...
...
@@ -35,11 +35,11 @@ describe('fileIO_fs_stream_flush', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
flushSync
();
s
s
.
closeSync
();
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
expect
(
s
r
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
flushSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_flush_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -48,7 +48,7 @@ describe('fileIO_fs_stream_flush', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0100
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH
_
SYNC_0100
* @tc.name fileIO_test_stream_flush_sync_001
* @tc.desc Test the flushSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters.
...
...
@@ -60,14 +60,14 @@ describe('fileIO_fs_stream_flush', function () {
it
(
'
fileIO_test_stream_flush_sync_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_flush_sync_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
flushSync
(
1
);
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
flushSync
(
1
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_flush_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
...
...
@@ -75,7 +75,7 @@ describe('fileIO_fs_stream_flush', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0000
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH
_
ASYNC_0000
* @tc.name fileIO_test_stream_flush_async_000
* @tc.desc Test the flush() interface of class Stream. Promise.then().catch()
* Refresh the file stream.
...
...
@@ -89,11 +89,11 @@ describe('fileIO_fs_stream_flush', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
await
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
flush
().
then
(()
=>
{
s
s
.
closeSync
();
let
s
r
=
await
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
expect
(
s
r
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
flush
().
then
(()
=>
{
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}).
catch
((
err
)
=>
{
...
...
@@ -107,7 +107,7 @@ describe('fileIO_fs_stream_flush', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0100
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH
_
ASYNC_0100
* @tc.name fileIO_test_stream_flush_async_001
* @tc.desc Test the flush() interface of class Stream. Callback.
* Refresh the file stream.
...
...
@@ -121,15 +121,15 @@ describe('fileIO_fs_stream_flush', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
await
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
flush
((
err
)
=>
{
let
s
r
=
await
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
expect
(
s
r
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
flush
((
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_stream_flush_async_001 error package
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
})
...
...
@@ -140,7 +140,7 @@ describe('fileIO_fs_stream_flush', function () {
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0100
* @tc.number SUB_DF_FILEIO_STREAM_FLUSH
_
ASYNC_0100
* @tc.name fileIO_test_stream_flush_async_001
* @tc.desc Test the flush() interface of class Stream. Promise.
* Refresh the file stream.
...
...
@@ -153,14 +153,14 @@ describe('fileIO_fs_stream_flush', function () {
it
(
'
fileIO_test_stream_flush_sync_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_flush_sync_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
await
s
s
.
flush
(
1
);
expect
(
s
r
!==
null
).
assertTrue
();
await
s
r
.
flush
(
1
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_flush_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
...
...
storage/storagefileiov9jstest/src/main/js/test/class_stream/read.test.js
浏览文件 @
66bce73b
...
...
@@ -35,11 +35,11 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
let
read
out
=
ss
.
readSync
(
new
ArrayBuffer
(
4096
));
expect
(
read
out
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
let
read
Len
=
sr
.
readSync
(
new
ArrayBuffer
(
4096
));
expect
(
read
Len
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_read_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -62,11 +62,11 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
let
read
out
=
ss
.
readSync
(
new
ArrayBuffer
(
4096
),
{
length
:
2
});
expect
(
read
out
==
2
).
assertTrue
();
s
s
.
closeSync
();
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
let
read
Len
=
sr
.
readSync
(
new
ArrayBuffer
(
4096
),
{
length
:
2
});
expect
(
read
Len
==
2
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_read_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -89,11 +89,11 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
let
read
out
=
ss
.
readSync
(
new
ArrayBuffer
(
4096
),
{
offset
:
2
});
expect
(
read
out
==
FILE_CONTENT
.
length
-
2
).
assertTrue
();
s
s
.
closeSync
();
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
let
read
Len
=
sr
.
readSync
(
new
ArrayBuffer
(
4096
),
{
offset
:
2
});
expect
(
read
Len
==
FILE_CONTENT
.
length
-
2
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_read_sync_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -116,14 +116,14 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
let
read
out
=
ss
.
readSync
(
new
ArrayBuffer
(
4096
),
{
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
let
read
Len
=
sr
.
readSync
(
new
ArrayBuffer
(
4096
),
{
offset
:
1
,
length
:
FILE_CONTENT
.
length
});
expect
(
read
out
==
FILE_CONTENT
.
length
-
1
).
assertTrue
();
s
s
.
closeSync
();
expect
(
read
Len
==
FILE_CONTENT
.
length
-
1
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_read_sync_003 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -144,14 +144,14 @@ describe('fileIO_fs_stream_read', function () {
it
(
'
fileIO_test_stream_read_sync_004
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_read_sync_004
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
readSync
(
""
);
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
readSync
(
""
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_read_sync_004 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
...
...
@@ -171,15 +171,15 @@ describe('fileIO_fs_stream_read', function () {
it
(
'
fileIO_test_stream_read_sync_005
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_read_sync_005
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
let
sr
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
const
invalidLength
=
4097
;
try
{
expect
(
ss
!==
null
).
assertTrue
();
const
invalidLength
=
4097
;
ss
.
readSync
(
new
ArrayBuffer
(
4096
),
{
length
:
invalidLength
});
expect
(
sr
!==
null
).
assertTrue
();
sr
.
readSync
(
new
ArrayBuffer
(
4096
),
{
length
:
invalidLength
});
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_read_sync_005 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
...
...
@@ -199,15 +199,15 @@ describe('fileIO_fs_stream_read', function () {
it
(
'
fileIO_test_stream_read_sync_006
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_read_sync_006
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
let
sr
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
const
invalidOffset
=
-
1
;
try
{
expect
(
ss
!==
null
).
assertTrue
();
const
invalidOffset
=
-
1
;
ss
.
readSync
(
new
ArrayBuffer
(
4096
),
{
offset
:
invalidOffset
});
expect
(
sr
!==
null
).
assertTrue
();
sr
.
readSync
(
new
ArrayBuffer
(
4096
),
{
offset
:
invalidOffset
});
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_read_sync_006 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
...
...
@@ -229,11 +229,11 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
let
read
out
=
await
ss
.
read
(
new
ArrayBuffer
(
4096
));
expect
(
read
out
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
let
read
Len
=
await
sr
.
read
(
new
ArrayBuffer
(
4096
));
expect
(
read
Len
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -257,15 +257,15 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
read
(
new
ArrayBuffer
(
4096
),
(
err
,
readout
)
=>
{
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
read
(
new
ArrayBuffer
(
4096
),
(
err
,
readLen
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_stream_read_async_001 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
read
out
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
expect
(
read
Len
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
});
...
...
@@ -290,13 +290,13 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
let
read
out
=
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
{
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
let
read
Len
=
await
sr
.
read
(
new
ArrayBuffer
(
4096
),
{
length
:
5
});
expect
(
read
out
==
5
).
assertTrue
();
s
s
.
closeSync
();
expect
(
read
Len
==
5
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -320,17 +320,17 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
read
(
new
ArrayBuffer
(
4096
),
{
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
read
(
new
ArrayBuffer
(
4096
),
{
length
:
5
},
(
err
,
read
out
)
=>
{
},
(
err
,
read
Len
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_stream_read_async_003 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
read
out
==
5
).
assertTrue
();
s
s
.
closeSync
();
expect
(
read
Len
==
5
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
});
...
...
@@ -355,13 +355,13 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
let
read
out
=
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
{
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
let
read
Len
=
await
sr
.
read
(
new
ArrayBuffer
(
4096
),
{
offset
:
5
});
expect
(
read
out
==
FILE_CONTENT
.
length
-
5
).
assertTrue
();
s
s
.
closeSync
();
expect
(
read
Len
==
FILE_CONTENT
.
length
-
5
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -385,17 +385,17 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
read
(
new
ArrayBuffer
(
4096
),
{
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
read
(
new
ArrayBuffer
(
4096
),
{
offset
:
5
},
(
err
,
read
out
)
=>
{
},
(
err
,
read
Len
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_stream_read_async_005 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
read
out
==
FILE_CONTENT
.
length
-
5
).
assertTrue
();
s
s
.
closeSync
();
expect
(
read
Len
==
FILE_CONTENT
.
length
-
5
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
});
...
...
@@ -418,15 +418,15 @@ describe('fileIO_fs_stream_read', function () {
it
(
'
fileIO_test_stream_read_async_006
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_read_async_006
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
r
!==
null
).
assertTrue
();
const
invalidLength
=
4097
;
await
s
s
.
read
(
new
ArrayBuffer
(
4096
),
{
length
:
invalidLength
});
await
s
r
.
read
(
new
ArrayBuffer
(
4096
),
{
length
:
invalidLength
});
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_read_async_006 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
...
...
@@ -447,18 +447,18 @@ describe('fileIO_fs_stream_read', function () {
it
(
'
fileIO_test_stream_read_async_007
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_read_async_007
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
r
!==
null
).
assertTrue
();
const
invalidOffset
=
-
1
;
s
s
.
read
(
new
ArrayBuffer
(
4096
),
{
s
r
.
read
(
new
ArrayBuffer
(
4096
),
{
offset
:
invalidOffset
},
(
err
)
=>
{
expect
(
false
).
assertTrue
();
});
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_read_async_007 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
...
...
@@ -481,14 +481,14 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
let
read
out
=
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
{
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
let
read
Len
=
await
sr
.
read
(
new
ArrayBuffer
(
4096
),
{
offset
:
1
,
length
:
FILE_CONTENT
.
length
});
expect
(
read
out
==
FILE_CONTENT
.
length
-
1
).
assertTrue
();
s
s
.
closeSync
();
expect
(
read
Len
==
FILE_CONTENT
.
length
-
1
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -512,18 +512,18 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
read
(
new
ArrayBuffer
(
4096
),
{
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
read
(
new
ArrayBuffer
(
4096
),
{
offset
:
1
,
length
:
FILE_CONTENT
.
length
},
(
err
,
read
out
)
=>
{
},
(
err
,
read
Len
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_stream_read_async_009 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
read
out
==
FILE_CONTENT
.
length
-
1
).
assertTrue
();
s
s
.
closeSync
();
expect
(
read
Len
==
FILE_CONTENT
.
length
-
1
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
});
...
...
@@ -548,11 +548,11 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
let
read
out
=
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
{});
expect
(
read
out
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
let
read
Len
=
await
sr
.
read
(
new
ArrayBuffer
(
4096
),
{});
expect
(
read
Len
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -576,16 +576,16 @@ describe('fileIO_fs_stream_read', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
read
(
new
ArrayBuffer
(
4096
),
{
},
(
err
,
read
out
)
=>
{
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
read
(
new
ArrayBuffer
(
4096
),
{
},
(
err
,
read
Len
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_stream_read_async_011 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
read
out
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
expect
(
read
Len
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
});
...
...
@@ -607,14 +607,14 @@ describe('fileIO_fs_stream_read', function () {
it
(
'
fileIO_test_stream_read_async_012
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_read_async_012
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
await
s
s
.
read
();
expect
(
s
r
!==
null
).
assertTrue
();
await
s
r
.
read
();
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_read_async_012 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
...
...
@@ -635,13 +635,14 @@ describe('fileIO_fs_stream_read', function () {
it
(
'
fileIO_test_stream_read_async_013
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_read_async_013
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
try
{
await
ss
.
read
(
""
);
expect
(
sr
!==
null
).
assertTrue
();
await
sr
.
read
(
""
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_read_async_013 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
...
...
@@ -662,15 +663,15 @@ describe('fileIO_fs_stream_read', function () {
it
(
'
fileIO_test_stream_read_async_014
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_read_async_014
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
s
s
.
read
(
""
,
(
err
)
=>
{
expect
(
s
r
!==
null
).
assertTrue
();
s
r
.
read
(
""
,
(
err
)
=>
{
expect
(
false
).
assertTrue
();
});
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_read_async_014 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
...
...
storage/storagefileiov9jstest/src/main/js/test/class_stream/write.test.js
浏览文件 @
66bce73b
此差异已折叠。
点击以展开。
storage/storagefileiov9jstest/src/main/js/test/members/access.test.js
浏览文件 @
66bce73b
...
...
@@ -21,7 +21,7 @@ export default function fileIOAccess() {
describe
(
'
fileIO_fs_access
'
,
function
()
{
/**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0000
* @tc.number SUB_DF_FILEIO_ACCESS
_
SYNC_0000
* @tc.name fileIO_test_access_sync_000
* @tc.desc Test accessSync() interface.
* This interface shall work properly in normal case.
...
...
@@ -49,7 +49,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0100
* @tc.number SUB_DF_FILEIO_ACCESS
_
SYNC_0100
* @tc.name fileIO_test_access_sync_001
* @tc.desc Test accessSync() interface.
* The test file is not exist.
...
...
@@ -71,7 +71,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0200
* @tc.number SUB_DF_FILEIO_ACCESS
_
SYNC_0200
* @tc.name fileIO_test_access_sync_002
* @tc.desc Test accessSync() interface.
* The test file path is illegal.
...
...
@@ -92,7 +92,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0000
* @tc.number SUB_DF_FILEIO_ACCESS
_
ASYNC_0000
* @tc.name fileIO_test_access_async_000
* @tc.desc Test access() interface. Promise.
* Use promise to test that the file is exist. Sync method reads data from file.
...
...
@@ -122,7 +122,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0100
* @tc.number SUB_DF_FILEIO_ACCESS
_
ASYNC_0100
* @tc.name fileIO_test_access_async_001
* @tc.desc Test access() interface. Callback.
* Use callback to test that the file is exist. Sync method reads data from file.
...
...
@@ -157,7 +157,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0200
* @tc.number SUB_DF_FILEIO_ACCESS
_
ASYNC_0200
* @tc.name fileIO_test_access_async_002
* @tc.desc Test access() interface. Promise.
* Async test file does not exist.
...
...
@@ -180,7 +180,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0300
* @tc.number SUB_DF_FILEIO_ACCESS
_
ASYNC_0300
* @tc.name fileIO_test_access_async_003
* @tc.desc Test access() interface. Callback.
* Async test file does not exist.
...
...
@@ -208,7 +208,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0400
* @tc.number SUB_DF_FILEIO_ACCESS
_
ASYNC_0400
* @tc.name fileIO_test_access_async_004
* @tc.desc Test access() interface. Promise.
* Invalid path parameter.
...
...
@@ -230,7 +230,7 @@ describe('fileIO_fs_access', function () {
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0500
* @tc.number SUB_DF_FILEIO_ACCESS
_
ASYNC_0500
* @tc.name fileIO_test_access_async_005
* @tc.desc Test access() interface. Callback.
* Invalid path parameter.
...
...
storage/storagefileiov9jstest/src/main/js/test/members/close.test.js
浏览文件 @
66bce73b
...
...
@@ -14,15 +14,14 @@
*/
import
{
fileIO
,
FILE_CONTENT
,
nextFileName
,
prepareFile
,
describe
,
it
,
expect
,
fileIO
,
FILE_CONTENT
,
nextFileName
,
prepareFile
,
describe
,
it
,
expect
,
}
from
'
../Common
'
;
export
default
function
fileIOClose
()
{
describe
(
'
fileIO_fs_close
'
,
function
()
{
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0000
* @tc.number SUB_DF_FILEIO_CLOSE
_
SYNC_0000
* @tc.name fileIO_test_close_sync_000
* @tc.desc Test closeSync() interfaces.
* Open file and close file by fd.
...
...
@@ -45,7 +44,7 @@ describe('fileIO_fs_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0100
* @tc.number SUB_DF_FILEIO_CLOSE
_
SYNC_0100
* @tc.name fileIO_test_close_sync_001
* @tc.desc Test closeSync() interfaces.
* Open file and close file by file object.
...
...
@@ -68,7 +67,7 @@ describe('fileIO_fs_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0200
* @tc.number SUB_DF_FILEIO_CLOSE
_
SYNC_0200
* @tc.name fileIO_test_close_sync_002
* @tc.desc Test closeSync() interfaces.
* Test fd has been closed.
...
...
@@ -94,7 +93,7 @@ describe('fileIO_fs_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0300
* @tc.number SUB_DF_FILEIO_CLOSE
_
SYNC_0300
* @tc.name fileIO_test_close_sync_003
* @tc.desc Test closeSync() interfaces.
* Test file has been closed.
...
...
@@ -120,7 +119,7 @@ describe('fileIO_fs_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0400
* @tc.number SUB_DF_FILEIO_CLOSE
_
SYNC_0400
* @tc.name fileIO_test_close_sync_004
* @tc.desc Test closeSync() interfaces.
* No parameters.
...
...
@@ -141,7 +140,7 @@ describe('fileIO_fs_close', function () {
});
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0500
* @tc.number SUB_DF_FILEIO_CLOSE
_
SYNC_0500
* @tc.name fileIO_test_close_sync_005
* @tc.desc Test closeSync() interfaces.
* Illegal type of parameter.
...
...
@@ -301,7 +300,7 @@ describe('fileIO_fs_close', function () {
/**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0500
* @tc.name fileIO_test_close_async_005
* @tc.desc Test close() interfaces. Promise.
* @tc.desc Test close() interfaces. Promise.
* Test file has been closed.
* @tc.size MEDIUM
* @tc.type Function
...
...
@@ -315,12 +314,12 @@ describe('fileIO_fs_close', function () {
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
await
fileIO
.
close
(
file
);
fileIO
.
close
(
file
);
await
fileIO
.
close
(
file
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_close_async_005 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
});
...
...
@@ -335,7 +334,7 @@ describe('fileIO_fs_close', function () {
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_close_async_006
'
,
0
,
async
function
(
done
)
{
it
(
'
fileIO_test_close_async_006
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_close_async_006
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
...
...
storage/storagefileiov9jstest/src/main/js/test/members/createStream.test.js
浏览文件 @
66bce73b
...
...
@@ -33,15 +33,15 @@ describe('fileIO_fs_createStream', function () {
it
(
'
fileIO_test_create_stream_sync_000
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_create_stream_sync_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
writeSync
(
FILE_CONTENT
);
expect
(
s
r
!==
null
).
assertTrue
();
expect
(
s
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
writeSync
(
FILE_CONTENT
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_create_stream_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900005
&&
e
.
message
==
'
I/O error
'
).
assertTrue
();
...
...
@@ -85,11 +85,11 @@ describe('fileIO_fs_createStream', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
r
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
expect
(
s
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
r
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_create_stream_sync_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -263,11 +263,11 @@ describe('fileIO_fs_createStream', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
w+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
w
=
fileIO
.
createStreamSync
(
fpath
,
'
w+
'
);
expect
(
s
w
!==
null
).
assertTrue
();
expect
(
s
w
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
w
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
w
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_create_stream_sync_009 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -289,11 +289,11 @@ describe('fileIO_fs_createStream', function () {
let
fpath
=
await
nextFileName
(
'
fileIO_test_create_stream_sync_010
'
);
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
w+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
w
=
fileIO
.
createStreamSync
(
fpath
,
'
w+
'
);
expect
(
s
w
!==
null
).
assertTrue
();
expect
(
s
w
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
w
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
w
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_create_stream_sync_010 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -316,10 +316,10 @@ describe('fileIO_fs_createStream', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
a
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
a
=
fileIO
.
createStreamSync
(
fpath
,
'
a
'
);
expect
(
s
a
!==
null
).
assertTrue
();
expect
(
s
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
a
.
closeSync
();
let
sr
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
sr
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
...
...
@@ -345,10 +345,10 @@ describe('fileIO_fs_createStream', function () {
let
fpath
=
await
nextFileName
(
'
fileIO_test_create_stream_sync_012
'
);
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
a
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
a
=
fileIO
.
createStreamSync
(
fpath
,
'
a
'
);
expect
(
s
a
!==
null
).
assertTrue
();
expect
(
s
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
a
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_create_stream_sync_012 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -369,15 +369,15 @@ describe('fileIO_fs_createStream', function () {
it
(
'
fileIO_test_create_stream_sync_013
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_create_stream_sync_013
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
a
'
);
let
s
a
=
fileIO
.
createStreamSync
(
fpath
,
'
a
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
readSync
(
new
ArrayBuffer
(
4096
));
expect
(
s
a
!==
null
).
assertTrue
();
expect
(
s
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
a
.
readSync
(
new
ArrayBuffer
(
4096
));
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
a
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_create_stream_sync_013 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900005
&&
e
.
message
==
'
I/O error
'
).
assertTrue
();
...
...
@@ -399,11 +399,11 @@ describe('fileIO_fs_createStream', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
a+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
s
s
.
closeSync
();
let
s
a
=
fileIO
.
createStreamSync
(
fpath
,
'
a+
'
);
expect
(
s
a
!==
null
).
assertTrue
();
expect
(
s
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
a
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
s
a
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_create_stream_sync_014 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -425,11 +425,11 @@ describe('fileIO_fs_createStream', function () {
let
fpath
=
await
nextFileName
(
'
fileIO_test_create_stream_sync_015
'
);
try
{
let
s
s
=
fileIO
.
createStreamSync
(
fpath
,
'
a+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
a
=
fileIO
.
createStreamSync
(
fpath
,
'
a+
'
);
expect
(
s
a
!==
null
).
assertTrue
();
expect
(
s
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
a
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
a
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_create_stream_sync_015 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -450,15 +450,15 @@ describe('fileIO_fs_createStream', function () {
it
(
'
fileIO_test_create_stream_async_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_create_stream_async_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
s
s
=
await
fileIO
.
createStream
(
fpath
,
'
r
'
);
let
s
r
=
await
fileIO
.
createStream
(
fpath
,
'
r
'
);
try
{
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
writeSync
(
FILE_CONTENT
);
expect
(
s
r
!==
null
).
assertTrue
();
expect
(
s
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
writeSync
(
FILE_CONTENT
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_create_stream_async_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900005
&&
e
.
message
==
'
I/O error
'
).
assertTrue
();
...
...
@@ -481,16 +481,16 @@ describe('fileIO_fs_createStream', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
createStream
(
fpath
,
'
r
'
,
(
err
,
s
s
)
=>
{
fileIO
.
createStream
(
fpath
,
'
r
'
,
(
err
,
s
r
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_create_stream_async_001 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
write
(
FILE_CONTENT
,
(
err
)
=>
{
expect
(
s
r
!==
null
).
assertTrue
();
expect
(
s
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
write
(
FILE_CONTENT
,
(
err
)
=>
{
if
(
err
)
{
s
s
.
closeSync
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_create_stream_async_001 error: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
...
...
@@ -573,11 +573,11 @@ describe('fileIO_fs_createStream', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
await
fileIO
.
createStream
(
fpath
,
'
r+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
r
=
await
fileIO
.
createStream
(
fpath
,
'
r+
'
);
expect
(
s
r
!==
null
).
assertTrue
();
expect
(
s
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
r
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -601,15 +601,15 @@ describe('fileIO_fs_createStream', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
createStream
(
fpath
,
'
r+
'
,
(
err
,
s
s
)
=>
{
fileIO
.
createStream
(
fpath
,
'
r+
'
,
(
err
,
s
r
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_create_stream_async_005 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
expect
(
s
r
!==
null
).
assertTrue
();
expect
(
s
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
r
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
});
...
...
@@ -829,11 +829,11 @@ describe('fileIO_fs_createStream', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
s
s
=
await
fileIO
.
createStream
(
fpath
,
'
w+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
w
=
await
fileIO
.
createStream
(
fpath
,
'
w+
'
);
expect
(
s
w
!==
null
).
assertTrue
();
expect
(
s
w
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
w
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
w
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -856,11 +856,11 @@ describe('fileIO_fs_createStream', function () {
let
fpath
=
await
nextFileName
(
'
fileIO_test_create_stream_async_014
'
);
try
{
let
s
s
=
await
fileIO
.
createStream
(
fpath
,
'
w+
'
);
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
let
s
w
=
await
fileIO
.
createStream
(
fpath
,
'
w+
'
);
expect
(
s
w
!==
null
).
assertTrue
();
expect
(
s
w
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
w
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
w
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -884,15 +884,15 @@ describe('fileIO_fs_createStream', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
createStream
(
fpath
,
'
w+
'
,
(
err
,
s
s
)
=>
{
fileIO
.
createStream
(
fpath
,
'
w+
'
,
(
err
,
s
w
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_create_stream_async_015 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
s
s
!==
null
).
assertTrue
();
expect
(
s
s
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
s
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
s
.
closeSync
();
expect
(
s
w
!==
null
).
assertTrue
();
expect
(
s
w
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
w
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
w
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
});
...
...
storage/storagefileiov9jstest/src/main/js/test/members/fdatasync.test.js
浏览文件 @
66bce73b
...
...
@@ -14,8 +14,7 @@
*/
import
{
fileio
,
fileIO
,
FILE_CONTENT
,
prepareFile
,
nextFileName
,
describe
,
it
,
expect
,
fileIO
,
FILE_CONTENT
,
prepareFile
,
nextFileName
,
describe
,
it
,
expect
,
}
from
'
../Common
'
;
export
default
function
fileIOFdatasync
()
{
...
...
@@ -38,8 +37,8 @@ export default function fileIOFdatasync() {
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
fileIO
.
fdatasyncSync
(
file
.
fd
);
file
io
.
closeSync
(
file
.
fd
);
file
io
.
unlinkSync
(
fpath
);
file
IO
.
closeSync
(
file
);
file
IO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_fdatasync_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
...
...
@@ -47,12 +46,12 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0
01
0
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0
10
0
* @tc.name fileIO_test_fdatasync_sync_001
* @tc.desc Test fdatasyncSync() interfaces. Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fdatasync_sync_001
'
,
0
,
async
function
()
{
...
...
@@ -67,12 +66,12 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0
02
0
* @tc.number SUB_DF_FILEIO_FDATASYNC_SYNC_0
20
0
* @tc.name fileIO_test_fdatasync_sync_002
* @tc.desc Test fdatasyncSync() interfaces. Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fdatasync_sync_002
'
,
0
,
async
function
()
{
...
...
@@ -107,8 +106,8 @@ export default function fileIOFdatasync() {
console
.
log
(
'
fileIO_test_fdatasync_async_000 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
file
io
.
closeSync
(
file
.
fd
);
file
io
.
unlinkSync
(
fpath
);
file
IO
.
closeSync
(
file
);
file
IO
.
unlinkSync
(
fpath
);
done
();
});
}
catch
(
e
)
{
...
...
@@ -118,13 +117,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
01
0
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
10
0
* @tc.name fileIO_test_fdatasync_async_001
* @tc.desc Test fdatasync() interfaces. Promise.then().catch().
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fdatasync_async_001
'
,
0
,
async
function
(
done
)
{
...
...
@@ -133,9 +132,9 @@ export default function fileIOFdatasync() {
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
file
io
.
fdatasync
(
file
.
fd
).
then
(()
=>
{
file
io
.
closeSync
(
file
.
fd
);
file
io
.
unlinkSync
(
fpath
);
file
IO
.
fdatasync
(
file
.
fd
).
then
(()
=>
{
file
IO
.
closeSync
(
file
);
file
IO
.
unlinkSync
(
fpath
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
fileIO_test_fdatasync_async_001 error package:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -148,13 +147,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
02
0
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
20
0
* @tc.name fileIO_test_fdatasync_async_002
* @tc.desc Test fdatasync() interfaces. await Promise.
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fdatasync_async_002
'
,
0
,
async
function
(
done
)
{
...
...
@@ -163,9 +162,9 @@ export default function fileIOFdatasync() {
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
await
file
io
.
fdatasync
(
file
.
fd
);
file
io
.
closeSync
(
file
.
fd
);
file
io
.
unlinkSync
(
fpath
);
await
file
IO
.
fdatasync
(
file
.
fd
);
file
IO
.
closeSync
(
file
);
file
IO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_fdatasync_async_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -174,13 +173,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
03
0
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
30
0
* @tc.name fileIO_test_fdatasync_async_003
* @tc.desc Test fdatasync() interfaces. await Promise.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fdatasync_async_003
'
,
0
,
async
function
(
done
)
{
...
...
@@ -196,13 +195,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
04
0
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
40
0
* @tc.name fileIO_test_fdatasync_async_004
* @tc.desc Test fdatasync() interfaces. Callback.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fdatasync_async_004
'
,
0
,
async
function
(
done
)
{
...
...
@@ -210,7 +209,7 @@ export default function fileIOFdatasync() {
try
{
fileIO
.
fdatasync
(
-
1
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_fdatasync_async_004 error
package: {
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
console
.
log
(
'
fileIO_test_fdatasync_async_004 error
: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
expect
(
err
.
code
==
13900008
&&
err
.
message
==
'
Bad file descriptor
'
).
assertTrue
();
done
();
}
...
...
@@ -222,13 +221,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
05
0
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
50
0
* @tc.name fileIO_test_fdatasync_async_005
* @tc.desc Test fdatasync() interfaces. Promise.then().catch()
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fdatasync_async_005
'
,
0
,
async
function
(
done
)
{
...
...
@@ -237,7 +236,7 @@ export default function fileIOFdatasync() {
fileIO
.
fdatasync
(
-
1
).
then
(()
=>
{
expect
(
false
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
fileIO_test_fdatasync_async_005 error
package: {
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
console
.
log
(
'
fileIO_test_fdatasync_async_005 error
: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
expect
(
err
.
code
==
13900008
&&
err
.
message
==
'
Bad file descriptor
'
).
assertTrue
();
done
();
});
...
...
@@ -248,13 +247,13 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
06
0
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
60
0
* @tc.name fileIO_test_fdatasync_async_006
* @tc.desc Test fdatasync() interfaces. Promise.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fdatasync_async_006
'
,
0
,
async
function
(
done
)
{
...
...
@@ -270,19 +269,19 @@ export default function fileIOFdatasync() {
});
/**
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
07
0
* @tc.number SUB_DF_FILEIO_FDATASYNC_ASYNC_0
70
0
* @tc.name fileIO_test_fdatasync_async_007
* @tc.desc Test fdatasync() interfaces. Callback.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fdatasync_async_007
'
,
0
,
async
function
(
done
)
{
try
{
fileIO
.
fdatasync
(()
=>
{
fileIO
.
fdatasync
((
err
)
=>
{
expect
(
false
).
assertTrue
();
});
}
catch
(
e
)
{
...
...
storage/storagefileiov9jstest/src/main/js/test/members/fdopenStream.test.js
浏览文件 @
66bce73b
...
...
@@ -35,15 +35,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
fp
=
fileIO
.
fdopenStreamSync
(
file
.
fd
,
'
r
'
);
let
fp
r
=
fileIO
.
fdopenStreamSync
(
file
.
fd
,
'
r
'
);
try
{
expect
(
fp
!==
null
).
assertTrue
();
expect
(
fp
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
.
writeSync
(
FILE_CONTENT
);
expect
(
fp
r
!==
null
).
assertTrue
();
expect
(
fp
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
r
.
writeSync
(
FILE_CONTENT
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fp
.
closeSync
();
fp
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_fdopenstream_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900005
&&
e
.
message
==
'
I/O error
'
).
assertTrue
();
...
...
@@ -88,11 +88,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try
{
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
fp
=
fileIO
.
fdopenStreamSync
(
file
.
fd
,
'
r+
'
);
expect
(
fp
!==
null
).
assertTrue
();
expect
(
fp
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
fp
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
.
closeSync
();
let
fp
r
=
fileIO
.
fdopenStreamSync
(
file
.
fd
,
'
r+
'
);
expect
(
fp
r
!==
null
).
assertTrue
();
expect
(
fp
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
fp
r
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_fdopenstream_sync_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -224,9 +224,9 @@ describe('fileIO_fs_FdOpenStream', async function () {
fpw
.
closeSync
();
let
file2
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_ONLY
);
let
s
r
=
fileIO
.
fdopenStreamSync
(
file2
.
fd
,
'
r
'
);
expect
(
s
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
closeSync
();
let
fp
r
=
fileIO
.
fdopenStreamSync
(
file2
.
fd
,
'
r
'
);
expect
(
fp
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_fdopenstream_sync_007 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -280,15 +280,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try
{
let
file1
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file1
.
fd
)).
assertTrue
();
let
fp
w
=
fileIO
.
fdopenStreamSync
(
file1
.
fd
,
'
a
'
);
expect
(
fp
w
!==
null
).
assertTrue
();
expect
(
fp
w
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
w
.
closeSync
();
let
fp
a
=
fileIO
.
fdopenStreamSync
(
file1
.
fd
,
'
a
'
);
expect
(
fp
a
!==
null
).
assertTrue
();
expect
(
fp
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
a
.
closeSync
();
let
file2
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
let
s
r
=
fileIO
.
fdopenStreamSync
(
file2
.
fd
,
'
r
'
);
expect
(
s
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
s
r
.
closeSync
();
let
fp
r
=
fileIO
.
fdopenStreamSync
(
file2
.
fd
,
'
r
'
);
expect
(
fp
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
fp
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_fdopenstream_sync_009 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -311,15 +311,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
s
a
=
fileIO
.
fdopenStreamSync
(
file
.
fd
,
'
a
'
);
let
fp
a
=
fileIO
.
fdopenStreamSync
(
file
.
fd
,
'
a
'
);
try
{
expect
(
s
a
!==
null
).
assertTrue
();
expect
(
s
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
a
.
readSync
(
new
ArrayBuffer
(
4096
));
expect
(
fp
a
!==
null
).
assertTrue
();
expect
(
fp
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
a
.
readSync
(
new
ArrayBuffer
(
4096
));
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
a
.
closeSync
();
fp
a
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_fdopenstream_sync_010 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900005
&&
e
.
message
==
'
I/O error
'
).
assertTrue
();
...
...
@@ -343,11 +343,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try
{
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
s
a
=
fileIO
.
fdopenStreamSync
(
file
.
fd
,
'
a+
'
);
expect
(
s
a
!==
null
).
assertTrue
();
expect
(
s
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
a
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
s
a
.
closeSync
();
let
fp
a
=
fileIO
.
fdopenStreamSync
(
file
.
fd
,
'
a+
'
);
expect
(
fp
a
!==
null
).
assertTrue
();
expect
(
fp
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
fp
a
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
fp
a
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_fdopenstream_sync_011 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -369,16 +369,16 @@ describe('fileIO_fs_FdOpenStream', async function () {
let
fpath
=
await
nextFileName
(
'
fileIO_test_fdopenstream_async_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
let
fp
=
await
fileIO
.
fdopenStream
(
file
.
fd
,
'
r
'
);
let
fp
r
=
await
fileIO
.
fdopenStream
(
file
.
fd
,
'
r
'
);
try
{
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
expect
(
fp
!==
null
).
assertTrue
();
expect
(
fp
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
.
writeSync
(
FILE_CONTENT
);
expect
(
fp
r
!==
null
).
assertTrue
();
expect
(
fp
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
r
.
writeSync
(
FILE_CONTENT
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fp
.
closeSync
();
fp
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_fdopenstream_async_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900005
&&
e
.
message
==
'
I/O error
'
).
assertTrue
();
...
...
@@ -403,16 +403,16 @@ describe('fileIO_fs_FdOpenStream', async function () {
try
{
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
fileIO
.
fdopenStream
(
file
.
fd
,
'
r
'
,
(
err
,
fp
)
=>
{
fileIO
.
fdopenStream
(
file
.
fd
,
'
r
'
,
(
err
,
fp
r
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_fdopenstream_async_001 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
fp
!==
null
).
assertTrue
();
expect
(
fp
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
.
write
(
FILE_CONTENT
,
(
err
)
=>
{
expect
(
fp
r
!==
null
).
assertTrue
();
expect
(
fp
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
r
.
write
(
FILE_CONTENT
,
(
err
)
=>
{
if
(
err
)
{
fp
.
closeSync
();
fp
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_fdopenstream_async_001 error: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
...
...
@@ -492,11 +492,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try
{
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
fp
=
await
fileIO
.
fdopenStream
(
file
.
fd
,
'
r+
'
);
expect
(
fp
!==
null
).
assertTrue
();
expect
(
fp
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
fp
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
.
closeSync
();
let
fp
r
=
await
fileIO
.
fdopenStream
(
file
.
fd
,
'
r+
'
);
expect
(
fp
r
!==
null
).
assertTrue
();
expect
(
fp
r
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
fp
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -522,15 +522,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try
{
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
fileIO
.
fdopenStream
(
file
.
fd
,
'
r+
'
,
(
err
,
fp
)
=>
{
fileIO
.
fdopenStream
(
file
.
fd
,
'
r+
'
,
(
err
,
fp
r
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_fdopenstream_async_005 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
fp
!==
null
).
assertTrue
();
expect
(
fp
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
fp
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
.
closeSync
();
expect
(
fp
r
!==
null
).
assertTrue
();
expect
(
fp
r
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
fp
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
});
...
...
@@ -689,9 +689,9 @@ describe('fileIO_fs_FdOpenStream', async function () {
fpw
.
closeSync
();
let
file2
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
let
s
r
=
await
fileIO
.
fdopenStream
(
file2
.
fd
,
'
r
'
);
expect
(
s
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
s
r
.
closeSync
();
let
fp
r
=
await
fileIO
.
fdopenStream
(
file2
.
fd
,
'
r
'
);
expect
(
fp
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -781,15 +781,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try
{
let
file1
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
let
fp
w
=
await
fileIO
.
fdopenStream
(
file1
.
fd
,
'
a
'
);
expect
(
fp
w
!==
null
).
assertTrue
();
expect
(
fp
w
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
w
.
closeSync
();
let
fp
a
=
await
fileIO
.
fdopenStream
(
file1
.
fd
,
'
a
'
);
expect
(
fp
a
!==
null
).
assertTrue
();
expect
(
fp
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
a
.
closeSync
();
let
file2
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
let
s
r
=
await
fileIO
.
fdopenStream
(
file2
.
fd
,
'
r
'
);
expect
(
s
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
s
r
.
closeSync
();
let
fp
r
=
await
fileIO
.
fdopenStream
(
file2
.
fd
,
'
r
'
);
expect
(
fp
r
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
fp
r
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -813,15 +813,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
s
a
=
await
fileIO
.
fdopenStream
(
file
.
fd
,
'
a
'
);
let
fp
a
=
await
fileIO
.
fdopenStream
(
file
.
fd
,
'
a
'
);
try
{
expect
(
s
a
!==
null
).
assertTrue
();
expect
(
s
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
a
.
readSync
(
new
ArrayBuffer
(
4096
));
expect
(
fp
a
!==
null
).
assertTrue
();
expect
(
fp
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
a
.
readSync
(
new
ArrayBuffer
(
4096
));
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
s
a
.
closeSync
();
fp
a
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_fdopenstream_async_014 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900005
&&
e
.
message
==
'
I/O error
'
).
assertTrue
();
...
...
@@ -846,16 +846,16 @@ describe('fileIO_fs_FdOpenStream', async function () {
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
try
{
fileIO
.
fdopenStream
(
file
.
fd
,
'
a
'
,
(
err
,
s
a
)
=>
{
fileIO
.
fdopenStream
(
file
.
fd
,
'
a
'
,
(
err
,
fp
a
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_fdopenstream_async_015 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
s
a
!==
null
).
assertTrue
();
expect
(
s
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
s
a
.
read
(
new
ArrayBuffer
(
4096
),
(
err
)
=>
{
expect
(
fp
a
!==
null
).
assertTrue
();
expect
(
fp
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
fp
a
.
read
(
new
ArrayBuffer
(
4096
),
(
err
)
=>
{
if
(
err
)
{
s
a
.
closeSync
();
fp
a
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_fdopenstream_async_015 error: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
...
...
@@ -890,11 +890,11 @@ describe('fileIO_fs_FdOpenStream', async function () {
try
{
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
let
s
a
=
await
fileIO
.
fdopenStream
(
file
.
fd
,
'
a+
'
);
expect
(
s
a
!==
null
).
assertTrue
();
expect
(
s
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
a
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
s
a
.
closeSync
();
let
fp
a
=
await
fileIO
.
fdopenStream
(
file
.
fd
,
'
a+
'
);
expect
(
fp
a
!==
null
).
assertTrue
();
expect
(
fp
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
fp
a
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
fp
a
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
...
...
@@ -920,15 +920,15 @@ describe('fileIO_fs_FdOpenStream', async function () {
try
{
expect
(
isIntNum
(
file
.
fd
)).
assertTrue
();
fileIO
.
fdopenStream
(
file
.
fd
,
'
a+
'
,
(
err
,
s
a
)
=>
{
fileIO
.
fdopenStream
(
file
.
fd
,
'
a+
'
,
(
err
,
fp
a
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_fdopenstream_async_017 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
s
a
!==
null
).
assertTrue
();
expect
(
s
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
s
a
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
s
a
.
closeSync
();
expect
(
fp
a
!==
null
).
assertTrue
();
expect
(
fp
a
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
fp
a
.
readSync
(
new
ArrayBuffer
(
4096
))
==
FILE_CONTENT
.
length
*
2
).
assertTrue
();
fp
a
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
});
...
...
storage/storagefileiov9jstest/src/main/js/test/members/fileLock.test.js
浏览文件 @
66bce73b
此差异已折叠。
点击以展开。
storage/storagefileiov9jstest/src/main/js/test/members/fsync.test.js
浏览文件 @
66bce73b
...
...
@@ -14,8 +14,7 @@
*/
import
{
fileio
,
fileIO
,
FILE_CONTENT
,
prepareFile
,
nextFileName
,
describe
,
it
,
expect
,
fileIO
,
FILE_CONTENT
,
prepareFile
,
nextFileName
,
describe
,
it
,
expect
,
}
from
'
../Common
'
;
export
default
function
fileIOFsync
()
{
...
...
@@ -38,8 +37,8 @@ describe('fileIO_fs_fsync', function () {
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
fileIO
.
fsyncSync
(
file
.
fd
);
file
io
.
closeSync
(
file
.
fd
);
file
io
.
unlinkSync
(
fpath
);
file
IO
.
closeSync
(
file
);
file
IO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_fsync_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
...
...
@@ -47,12 +46,12 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0
01
0
* @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0
10
0
* @tc.name fileIO_test_fsync_sync_001
* @tc.desc Test fsyncSync() interface. Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fsync_sync_001
'
,
0
,
function
()
{
...
...
@@ -67,12 +66,12 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0
02
0
* @tc.number SUB_DF_FILEIO_FSYNC_SYNC_0
20
0
* @tc.name fileIO_test_fsync_sync_002
* @tc.desc Test fsyncSync() interface. Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fsync_sync_002
'
,
0
,
function
()
{
...
...
@@ -103,8 +102,8 @@ describe('fileIO_fs_fsync', function () {
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
await
fileIO
.
fsync
(
file
.
fd
);
file
io
.
closeSync
(
file
.
fd
);
file
io
.
unlinkSync
(
fpath
);
file
IO
.
closeSync
(
file
);
file
IO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_fsync_async_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -113,13 +112,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
01
0
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
10
0
* @tc.name fileIO_test_fsync_async_001
* @tc.desc Test fsync() interface. Promise.then().catch()
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fsync_async_001
'
,
0
,
async
function
(
done
)
{
...
...
@@ -129,8 +128,8 @@ describe('fileIO_fs_fsync', function () {
try
{
let
file
=
fileIO
.
openSync
(
fpath
,
fileIO
.
OpenMode
.
READ_WRITE
);
fileIO
.
fsync
(
file
.
fd
).
then
(()
=>
{
file
io
.
closeSync
(
file
.
fd
);
file
io
.
unlinkSync
(
fpath
);
file
IO
.
closeSync
(
file
);
file
IO
.
unlinkSync
(
fpath
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
fileIO_test_fsync_async_001 error package:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -143,13 +142,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
02
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
200
* @tc.name fileIO_test_fsync_async_002
* @tc.desc Test fsync() interface. Callback.
* Open the file in read-write mode, and synchronize the file content data.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fsync_async_002
'
,
0
,
async
function
(
done
)
{
...
...
@@ -163,8 +162,8 @@ describe('fileIO_fs_fsync', function () {
console
.
log
(
'
fileIO_test_fsync_async_002 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
file
io
.
closeSync
(
file
.
fd
);
file
io
.
unlinkSync
(
fpath
);
file
IO
.
closeSync
(
file
);
file
IO
.
unlinkSync
(
fpath
);
});
done
();
}
catch
(
e
)
{
...
...
@@ -174,13 +173,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
03
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
300
* @tc.name fileIO_test_fsync_async_003
* @tc.desc Test fsync() interface. await Promise.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fsync_async_003
'
,
0
,
async
function
(
done
)
{
...
...
@@ -196,13 +195,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
04
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
400
* @tc.name fileIO_test_fsync_async_004
* @tc.desc Test fsync() interface. Callback.
* Invalid fd parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fsync_async_004
'
,
0
,
async
function
(
done
)
{
...
...
@@ -210,7 +209,7 @@ describe('fileIO_fs_fsync', function () {
try
{
fileIO
.
fsync
(
-
1
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_fsync_async_004 error
package: {
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
console
.
log
(
'
fileIO_test_fsync_async_004 error
: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
expect
(
err
.
code
==
13900008
&&
err
.
message
==
'
Bad file descriptor
'
).
assertTrue
();
done
();
}
...
...
@@ -222,13 +221,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
05
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
500
* @tc.name fileIO_test_fsync_async_005
* @tc.desc Test fsync() interface. Promise.then().catch()
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fsync_async_005
'
,
0
,
async
function
(
done
)
{
...
...
@@ -237,7 +236,7 @@ describe('fileIO_fs_fsync', function () {
fileIO
.
fsync
(
-
1
).
then
(()
=>
{
expect
(
false
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
fileIO_test_fsync_async_005 error
package: {
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
console
.
log
(
'
fileIO_test_fsync_async_005 error
: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
expect
(
err
.
code
==
13900008
&&
err
.
message
==
'
Bad file descriptor
'
).
assertTrue
();
done
();
});
...
...
@@ -248,13 +247,13 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
06
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
600
* @tc.name fileIO_test_fsync_async_006
* @tc.desc Test fsync() interface. await Promise.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fsync_async_006
'
,
0
,
async
function
(
done
)
{
...
...
@@ -270,19 +269,19 @@ describe('fileIO_fs_fsync', function () {
});
/**
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
06
* @tc.name fileIO_test_fsync_async_00
6
* @tc.number SUB_DF_FILEIO_FSYNC_ASYNC_0
700
* @tc.name fileIO_test_fsync_async_00
7
* @tc.desc Test fsync() interface. Callback.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_fsync_async_007
'
,
0
,
async
function
(
done
)
{
try
{
fileIO
.
fsync
(()
=>
{
fileIO
.
fsync
((
err
)
=>
{
expect
(
false
).
assertTrue
();
});
}
catch
(
e
)
{
...
...
storage/storagefileiov9jstest/src/main/js/test/members/listFile.test.js
浏览文件 @
66bce73b
...
...
@@ -57,7 +57,7 @@ export default function fileIOListfile() {
* Do not have prop filter.Filter files by quantity only.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_sync_001
'
,
0
,
async
function
()
{
...
...
@@ -90,7 +90,7 @@ export default function fileIOListfile() {
* Do not have prop listNum.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_sync_002
'
,
0
,
async
function
()
{
...
...
@@ -129,7 +129,7 @@ export default function fileIOListfile() {
* Do not have prop suffix. Not filter files by suffix.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_sync_003
'
,
0
,
async
function
()
{
...
...
@@ -168,7 +168,7 @@ export default function fileIOListfile() {
* Scanfile.Retain six files in the three-level directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_sync_004
'
,
0
,
async
function
()
{
...
...
@@ -226,7 +226,7 @@ export default function fileIOListfile() {
* Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_sync_005
'
,
0
,
async
function
()
{
...
...
@@ -268,7 +268,7 @@ export default function fileIOListfile() {
* Invalid file suffix name format.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_sync_006
'
,
0
,
async
function
()
{
...
...
@@ -308,7 +308,7 @@ export default function fileIOListfile() {
* Filter out all files because the size of all files less than 12.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_sync_007
'
,
0
,
async
function
()
{
...
...
@@ -348,7 +348,7 @@ export default function fileIOListfile() {
* listNum is 0.Traverse all files.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_sync_008
'
,
0
,
async
function
()
{
...
...
@@ -390,7 +390,7 @@ export default function fileIOListfile() {
* Missing all arguments.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_sync_009
'
,
0
,
async
function
()
{
...
...
@@ -411,7 +411,7 @@ export default function fileIOListfile() {
* Invalid option args.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_sync_010
'
,
0
,
async
function
()
{
...
...
@@ -463,7 +463,7 @@ export default function fileIOListfile() {
fileIO
.
rmdirSync
(
dpath
);
});
}
catch
(
e
)
{
console
.
info
(
'
fileIO_test_listfile_async_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
console
.
log
(
'
fileIO_test_listfile_async_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
...
...
@@ -475,7 +475,7 @@ export default function fileIOListfile() {
* Only path, do not filter file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_001
'
,
0
,
async
function
(
done
)
{
...
...
@@ -494,7 +494,7 @@ export default function fileIOListfile() {
fileIO
.
rmdirSync
(
dpath
);
done
();
}
catch
(
err
)
{
console
.
info
(
'
fileIO_test_listfile_async_001 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
console
.
log
(
'
fileIO_test_listfile_async_001 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
false
).
assertTrue
();
}
});
...
...
@@ -506,7 +506,7 @@ export default function fileIOListfile() {
* Do not have prop filter.Filter files by quantity only.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_002
'
,
0
,
async
function
()
{
...
...
@@ -544,7 +544,7 @@ export default function fileIOListfile() {
* Do not have prop filter.Filter files by quantity only.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_003
'
,
0
,
async
function
(
done
)
{
...
...
@@ -578,7 +578,7 @@ export default function fileIOListfile() {
* Do not have prop listNum.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_004
'
,
0
,
async
function
()
{
...
...
@@ -610,7 +610,7 @@ export default function fileIOListfile() {
fileIO
.
rmdirSync
(
dpath
);
});
}
catch
(
e
)
{
console
.
info
(
'
fileIO_test_listfile_async_004 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
console
.
log
(
'
fileIO_test_listfile_async_004 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
...
...
@@ -622,7 +622,7 @@ export default function fileIOListfile() {
* Do not have prop listNum.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_005
'
,
0
,
async
function
(
done
)
{
...
...
@@ -650,7 +650,7 @@ export default function fileIOListfile() {
fileIO
.
rmdirSync
(
dpath
);
done
();
}
catch
(
err
)
{
console
.
info
(
'
fileIO_test_listfile_async_005 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
console
.
log
(
'
fileIO_test_listfile_async_005 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
false
).
assertTrue
();
}
});
...
...
@@ -662,7 +662,7 @@ export default function fileIOListfile() {
* Do not have prop suffix. Not filter files by suffix.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_006
'
,
0
,
async
function
()
{
...
...
@@ -706,7 +706,7 @@ export default function fileIOListfile() {
* Do not have prop suffix. Not filter files by suffix.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_007
'
,
0
,
async
function
(
done
)
{
...
...
@@ -746,7 +746,7 @@ export default function fileIOListfile() {
* Scanfile.Retain six files in the three-level directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_008
'
,
0
,
async
function
()
{
...
...
@@ -809,7 +809,7 @@ export default function fileIOListfile() {
* Scanfile.Retain six files in the three-level directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_009
'
,
0
,
async
function
(
done
)
{
...
...
@@ -868,7 +868,7 @@ export default function fileIOListfile() {
* Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_010
'
,
0
,
async
function
()
{
...
...
@@ -915,7 +915,7 @@ export default function fileIOListfile() {
* Filter out files whose suffix is not '. txt' and does not meet other conditions.Two files are retained.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_011
'
,
0
,
async
function
(
done
)
{
...
...
@@ -958,7 +958,7 @@ export default function fileIOListfile() {
* Invalid file suffix name format.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_012
'
,
0
,
async
function
()
{
...
...
@@ -1001,7 +1001,7 @@ export default function fileIOListfile() {
* Invalid file suffix name format.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_013
'
,
0
,
async
function
(
done
)
{
...
...
@@ -1044,7 +1044,7 @@ export default function fileIOListfile() {
* Filter out all files because the size of all files less than 12.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_014
'
,
0
,
async
function
()
{
...
...
@@ -1089,7 +1089,7 @@ export default function fileIOListfile() {
* Filter out all files because the size of all files less than 12.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_015
'
,
0
,
async
function
(
done
)
{
...
...
@@ -1130,7 +1130,7 @@ export default function fileIOListfile() {
* listNum is 0.Traverse all files.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_016
'
,
0
,
async
function
()
{
...
...
@@ -1177,7 +1177,7 @@ export default function fileIOListfile() {
* listNum is 0.Traverse all files.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_017
'
,
0
,
async
function
(
done
)
{
...
...
@@ -1220,7 +1220,7 @@ export default function fileIOListfile() {
* Missing all arguments.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_018
'
,
0
,
async
function
(
done
)
{
...
...
@@ -1242,7 +1242,7 @@ export default function fileIOListfile() {
* Invalid option args.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_listfile_async_019
'
,
0
,
async
function
(
done
)
{
...
...
storage/storagefileiov9jstest/src/main/js/test/members/lstat.test.js
浏览文件 @
66bce73b
此差异已折叠。
点击以展开。
storage/storagefileiov9jstest/src/main/js/test/members/mkdir.test.js
浏览文件 @
66bce73b
...
...
@@ -96,7 +96,7 @@ describe('fileIO_fs_mkdir', function () {
* @tc.require
*/
it
(
'
fileIO_test_mkdir_sync_003
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_
open_sync_000
'
);
let
fpath
=
await
nextFileName
(
'
fileIO_test_
mkdir_sync_003
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
...
...
@@ -198,7 +198,7 @@ describe('fileIO_fs_mkdir', function () {
try
{
fileIO
.
mkdir
(
'
/
'
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_mkdir_async_003 error
package: {
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
console
.
log
(
'
fileIO_test_mkdir_async_003 error
: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
expect
(
err
.
code
==
13900015
&&
err
.
message
==
'
File exists
'
).
assertTrue
();
done
();
}
...
...
storage/storagefileiov9jstest/src/main/js/test/members/moveFile.test.js
浏览文件 @
66bce73b
...
...
@@ -21,7 +21,7 @@ export default function fileIOMoveFile() {
describe
(
'
fileIO_fs_moveFile
'
,
function
()
{
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0000
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
SYNC_0000
* @tc.name fileIO_test_moveFile_sync_000
* @tc.desc Test moveFileSync() interface.
* Move a single file, shall work properly in normal case.
...
...
@@ -51,13 +51,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0100
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
SYNC_0100
* @tc.name fileIO_test_moveFile_sync_001
* @tc.desc Test moveFileSync() interface.
* A file with the same name already exists under the destination path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_sync_001
'
,
0
,
async
function
()
{
...
...
@@ -81,13 +81,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0200
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
SYNC_0200
* @tc.name fileIO_test_moveFile_sync_002
* @tc.desc Test moveFileSync() interface.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_sync_002
'
,
0
,
async
function
()
{
...
...
@@ -109,13 +109,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0400
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
SYNC_0400
* @tc.name fileIO_test_moveFile_sync_004
* @tc.desc Test moveFileSync() interface.
* The path point to a directory, not a file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_sync_004
'
,
0
,
async
function
()
{
...
...
@@ -134,13 +134,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0500
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
SYNC_0500
* @tc.name fileIO_test_moveFile_sync_005
* @tc.desc Test moveFileSync() interface.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_sync_005
'
,
0
,
async
function
()
{
...
...
@@ -158,13 +158,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILESYNC_0600
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
SYNC_0600
* @tc.name fileIO_test_moveFile_sync_006
* @tc.desc Test moveFileSync() interface.
* Entry parameters increase forced movement when mode = 0.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_sync_006
'
,
0
,
async
function
()
{
...
...
@@ -189,7 +189,7 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0000
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
ASYNC_0000
* @tc.name fileIO_test_moveFile_async_000
* @tc.desc Test moveFile() interface. Promise.
* Move a single file, shall work properly in normal case.
...
...
@@ -220,13 +220,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0100
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
ASYNC_0100
* @tc.name fileIO_test_moveFile_async_001
* @tc.desc Test moveFile() interface. Callback.
* Move a single file, shall work properly in normal case.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_async_001
'
,
0
,
async
function
(
done
)
{
...
...
@@ -256,13 +256,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0200
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
ASYNC_0200
* @tc.name fileIO_test_moveFile_async_002
* @tc.desc Test moveFile() interface. Promise.
* A file with the same name already exists under the destination path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_async_002
'
,
0
,
async
function
(
done
)
{
...
...
@@ -287,13 +287,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0300
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
ASYNC_0300
* @tc.name fileIO_test_moveFile_async_003
* @tc.desc Test moveFile() interface. Callback.
* A file with the same name already exists under the destination path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_async_003
'
,
0
,
async
function
(
done
)
{
...
...
@@ -310,7 +310,7 @@ export default function fileIOMoveFile() {
fileIO
.
moveFile
(
fpath
,
ffpath
,
1
,
(
err
)
=>
{
if
(
err
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_moveFile_async_003 error
package: {
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
console
.
log
(
'
fileIO_test_moveFile_async_003 error
: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
expect
(
err
.
code
==
13900015
&&
err
.
message
==
'
File exists
'
).
assertTrue
();
done
();
}
...
...
@@ -322,13 +322,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0400
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
ASYNC_0400
* @tc.name fileIO_test_moveFile_async_004
* @tc.desc Test moveFile() interface. Promise.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_async_004
'
,
0
,
async
function
(
done
)
{
...
...
@@ -351,13 +351,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0500
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
ASYNC_0500
* @tc.name fileIO_test_moveFile_async_005
* @tc.desc Test moveFile() interface. Callback.
* The path point to nothing, no such file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_async_005
'
,
0
,
async
function
(
done
)
{
...
...
@@ -372,7 +372,7 @@ export default function fileIOMoveFile() {
fileIO
.
moveFile
(
fpath
,
ffpath
,
(
err
)
=>
{
if
(
err
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_moveFile_async_005 error
package: {
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
console
.
log
(
'
fileIO_test_moveFile_async_005 error
: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
expect
(
err
.
code
==
13900002
&&
err
.
message
==
'
No such file or directory
'
).
assertTrue
();
done
();
}
...
...
@@ -384,13 +384,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0600
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
ASYNC_0600
* @tc.name fileIO_test_moveFile_async_006
* @tc.desc Test moveFile() interface. Promise.
* The path point to a directory, not a file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_async_006
'
,
0
,
async
function
(
done
)
{
...
...
@@ -410,13 +410,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0700
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
ASYNC_0700
* @tc.name fileIO_test_moveFile_async_007
* @tc.desc Test moveFile() interface. Callback.
* The path point to a directory, not a file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_async_007
'
,
0
,
async
function
(
done
)
{
...
...
@@ -440,13 +440,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0800
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
ASYNC_0800
* @tc.name fileIO_test_moveFile_async_008
* @tc.desc Test moveFile() interface. Promise.
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_async_008
'
,
0
,
async
function
(
done
)
{
...
...
@@ -465,13 +465,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_0900
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
ASYNC_0900
* @tc.name fileIO_test_moveFile_async_009
* @tc.desc Test moveFile() interface. Promise.
* Entry parameters increase forced movement when mode = 0.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_async_009
'
,
0
,
async
function
(
done
)
{
...
...
@@ -497,13 +497,13 @@ export default function fileIOMoveFile() {
});
/**
* @tc.number SUB_DF_FILEIO_MOVEFILEASYNC_1000
* @tc.number SUB_DF_FILEIO_MOVEFILE
_
ASYNC_1000
* @tc.name fileIO_test_moveFile_async_010
* @tc.desc Test moveFile() interface. Callback.
* Entry parameters increase forced movement when mode = 0.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_moveFile_async_010
'
,
0
,
async
function
(
done
)
{
...
...
storage/storagefileiov9jstest/src/main/js/test/members/open.test.js
浏览文件 @
66bce73b
此差异已折叠。
点击以展开。
storage/storagefileiov9jstest/src/main/js/test/members/read.test.js
浏览文件 @
66bce73b
此差异已折叠。
点击以展开。
storage/storagefileiov9jstest/src/main/js/test/members/rmdir.test.js
浏览文件 @
66bce73b
此差异已折叠。
点击以展开。
storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js
浏览文件 @
66bce73b
此差异已折叠。
点击以展开。
storage/storagefileiov9jstest/src/main/js/test/members/symlink.test.js
浏览文件 @
66bce73b
...
...
@@ -52,7 +52,7 @@ describe('fileIO_fs_symlink', function () {
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_symlink_sync_001
'
,
0
,
async
function
()
{
...
...
@@ -84,10 +84,10 @@ describe('fileIO_fs_symlink', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
symlink
(
fpath
,
fpath
+
'
link
3
'
).
then
(()
=>
{
expect
(
fileIO
.
accessSync
(
fpath
+
'
link
3
'
)).
assertTrue
();
fileIO
.
symlink
(
fpath
,
fpath
+
'
link
1
'
).
then
(()
=>
{
expect
(
fileIO
.
accessSync
(
fpath
+
'
link
1
'
)).
assertTrue
();
fileIO
.
unlinkSync
(
fpath
);
fileIO
.
unlinkSync
(
fpath
+
'
link
3
'
);
fileIO
.
unlinkSync
(
fpath
+
'
link
1
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
fileIO_test_symlink_async_000 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
...
...
@@ -106,7 +106,7 @@ describe('fileIO_fs_symlink', function () {
* Create a symbolic link to verify normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_symlink_async_001
'
,
0
,
async
function
(
done
)
{
...
...
@@ -114,10 +114,10 @@ describe('fileIO_fs_symlink', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
await
fileIO
.
symlink
(
fpath
,
fpath
+
'
link
4
'
);
expect
(
fileIO
.
accessSync
(
fpath
+
'
link
4
'
)).
assertTrue
();
await
fileIO
.
symlink
(
fpath
,
fpath
+
'
link
2
'
);
expect
(
fileIO
.
accessSync
(
fpath
+
'
link
2
'
)).
assertTrue
();
fileIO
.
unlinkSync
(
fpath
);
fileIO
.
unlinkSync
(
fpath
+
'
link
4
'
);
fileIO
.
unlinkSync
(
fpath
+
'
link
2
'
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_symlink_async_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
...
...
@@ -132,7 +132,7 @@ describe('fileIO_fs_symlink', function () {
* Create a symbolic link to verify normal function.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_symlink_async_002
'
,
0
,
async
function
(
done
)
{
...
...
@@ -140,14 +140,14 @@ describe('fileIO_fs_symlink', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
symlink
(
fpath
,
fpath
+
'
link
5
'
,
(
err
)
=>
{
fileIO
.
symlink
(
fpath
,
fpath
+
'
link
3
'
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_symlink_async_002 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
fileIO
.
accessSync
(
fpath
+
'
link
5
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
fpath
+
'
link
3
'
)).
assertTrue
();
fileIO
.
unlinkSync
(
fpath
);
fileIO
.
unlinkSync
(
fpath
+
'
link
5
'
);
fileIO
.
unlinkSync
(
fpath
+
'
link
3
'
);
done
();
});
}
catch
(
e
)
{
...
...
@@ -163,7 +163,7 @@ describe('fileIO_fs_symlink', function () {
* Missing parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level
0
* @tc.level Level
3
* @tc.require
*/
it
(
'
fileIO_test_symlink_async_003
'
,
0
,
async
function
(
done
)
{
...
...
storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js
浏览文件 @
66bce73b
此差异已折叠。
点击以展开。
storage/storagefileiov9jstest/src/main/js/test/members/unlink.test.js
浏览文件 @
66bce73b
此差异已折叠。
点击以展开。
storage/storagefileiov9jstest/src/main/js/test/members/write.test.js
浏览文件 @
66bce73b
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录