Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
38f1a5d9
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,发现更多精彩内容 >>
提交
38f1a5d9
编写于
5月 17, 2022
作者:
R
raoxian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update storagefileioerrorjstest
Signed-off-by:
N
raoxian
<
raoxian@huawei.com
>
上级
32f56178
变更
6
展开全部
显示空白变更内容
内联
并排
Showing
6 changed file
with
84 addition
and
1492 deletion
+84
-1492
storage/storagefileioerrorjstest/Test.json
storage/storagefileioerrorjstest/Test.json
+2
-2
storage/storagefileioerrorjstest/src/main/config.json
storage/storagefileioerrorjstest/src/main/config.json
+3
-3
storage/storagefileioerrorjstest/src/main/js/default/test/Common.js
...oragefileioerrorjstest/src/main/js/default/test/Common.js
+12
-121
storage/storagefileioerrorjstest/src/main/js/default/test/FileError.test.js
...eioerrorjstest/src/main/js/default/test/FileError.test.js
+0
-407
storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js
...oerrorjstest/src/main/js/default/test/FileIOError.test.js
+67
-296
storage/storagefileioerrorjstest/src/main/js/default/test/FileVirtualPath.test.js
...orjstest/src/main/js/default/test/FileVirtualPath.test.js
+0
-663
未找到文件。
storage/storagefileioerrorjstest/Test.json
浏览文件 @
38f1a5d9
{
"description"
:
"Configuration for storage file
and file
io Tests"
,
"description"
:
"Configuration for storage fileio Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"60000"
,
"package"
:
"ohos.acts.st
roage.fileio
"
,
"package"
:
"ohos.acts.st
orage.fileioerror
"
,
"shell-timeout"
:
"60000"
},
"kits"
:
[
...
...
storage/storagefileioerrorjstest/src/main/config.json
浏览文件 @
38f1a5d9
{
"app"
:
{
"bundleName"
:
"ohos.acts.st
roage.fileio
"
,
"bundleName"
:
"ohos.acts.st
orage.fileioerror
"
,
"vendor"
:
"example"
,
"version"
:
{
"code"
:
1000000
,
...
...
@@ -13,7 +13,7 @@
},
"deviceConfig"
:
{},
"module"
:
{
"package"
:
"ohos.acts.st
roage.fileio
"
,
"package"
:
"ohos.acts.st
orage.fileioerror
"
,
"name"
:
".MyApplication"
,
"deviceType"
:
[
"phone"
...
...
@@ -36,7 +36,7 @@
]
}
],
"name"
:
"ohos.acts.st
roage.fileio
.MainAbility"
,
"name"
:
"ohos.acts.st
orage.fileioerror
.MainAbility"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"$string:app_name"
,
...
...
storage/storagefileioerrorjstest/src/main/js/default/test/Common.js
浏览文件 @
38f1a5d9
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import
fileio
from
'
@
system
.fileio
'
import
fileio
from
'
@
ohos
.fileio
'
export
const
FILE_CONTENT
=
'
hello world
'
...
...
@@ -31,133 +31,16 @@ export function prepareFile(fpath, content) {
return
false
}
}
export
function
prepareFile1
(
fpath
,
content
)
{
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o777
)
fileio
.
ftruncateSync
(
fd
)
fileio
.
writeSync
(
fd
,
content
)
fileio
.
fsyncSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
Failed to prepareFile for
'
+
e
)
return
false
}
}
export
function
prepareEmptyFile
(
fpath
)
{
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o777
)
fileio
.
closeSync
(
fd
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
Failed to prepareFile for
'
+
e
)
return
false
}
}
export
function
fileToReadOnly
(
fpath
)
{
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o1
)
fileio
.
fchmodSync
(
fd
,
0o444
)
fileio
.
fsyncSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
Failed to fileToReadOnly for
'
+
e
);
return
false
}
}
export
function
fileToWriteOnly
(
fpath
)
{
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o2
)
fileio
.
fchmodSync
(
fd
,
0o222
)
fileio
.
fsyncSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
Failed to fileToWriteOnly
'
+
e
)
return
false
}
}
export
function
fileToReadAndWrite
(
fpath
)
{
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o1
)
fileio
.
fchmodSync
(
fd
,
0o777
)
fileio
.
fsyncSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
Failed to fileToReadAndWrite
'
+
e
);
return
false
}
}
export
function
appName
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/
'
return
BASE_PATH
+
testName
}
export
function
nextFileName
(
testName
)
{
const
BASE_PATH
=
'
/data/
accounts/account_0/appdata/ohos.acts.stroage.fileio
/cache/
'
const
BASE_PATH
=
'
/data/
storage/el2/base/haps/entry
/cache/
'
return
BASE_PATH
+
testName
}
export
function
fileName
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/
'
return
BASE_PATH
+
testName
}
export
function
cacheFileName
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/cache/
'
return
BASE_PATH
+
testName
}
export
function
differentFileName
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/
'
return
BASE_PATH
+
testName
}
export
function
differentCacheName
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/cache/
'
const
BASE_PATH
=
'
/data/storage/el2/base/haps/entry/files/
'
return
BASE_PATH
+
testName
}
export
function
getFileTextLen
(
fpath
)
{
let
ss
try
{
ss
=
fileio
.
Stream
.
createStreamSync
(
fpath
,
'
r+
'
)
expect
(
ss
!==
null
).
assertTrue
()
let
len
=
ss
.
readSync
(
new
ArrayBuffer
(
4096
))
console
.
log
(
'
file:
'
+
fpath
)
console
.
log
(
'
file length:
'
+
len
)
expect
(
ss
.
closeSync
()
!==
null
).
assertTrue
()
return
len
}
catch
(
e
)
{
console
.
log
(
'
Failed to getFileTextLen
'
+
e
)
expect
(
ss
.
closeSync
()
!==
null
).
assertTrue
()
return
null
}
}
export
function
isFileExist
(
fpath
)
{
try
{
expect
(
fileio
.
accessSync
(
fpath
)
!==
null
).
assertTrue
()
console
.
log
(
'
file:
'
+
fpath
)
console
.
log
(
'
status:exist
'
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
file:
'
+
fpath
)
console
.
log
(
'
status:non-existen
'
)
return
false
}
}
export
function
sleep
(
n
)
{
var
start
=
new
Date
().
getTime
();
while
(
true
)
{
if
(
new
Date
().
getTime
()
-
start
>
n
)
{
break
;
}
}
}
export
function
randomString
(
num
)
{
let
len
=
num
;
var
$chars
=
'
aaaabbbbcccc
'
;
...
...
@@ -168,3 +51,11 @@ export function randomString(num) {
}
return
pwd
;
}
export
function
isIntNum
(
val
)
{
return
typeof
val
===
'
number
'
&&
val
%
1
===
0
;
}
export
function
isInclude
(
error
,
message
)
{
return
error
.
toString
().
indexOf
(
message
)
!=
-
1
;
}
\ No newline at end of file
storage/storagefileioerrorjstest/src/main/js/default/test/FileError.test.js
已删除
100644 → 0
浏览文件 @
32f56178
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
fileio
from
'
@system.fileio
'
import
file
from
'
@system.file
'
;
import
{
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
import
{
FILE_CONTENT
,
prepareFile
,
fileName
,
randomString
,
}
from
'
./Common
'
describe
(
'
FileError
'
,
function
()
{
/**
* @tc.number SUB_STORAGE_File_test_error_0000
* @tc.name File_test_error_000
* @tc.desc Function of API, Move files when disk space is full.
* Create the file (file_test_error) in advance and give 777 permission,
* path:/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/file_test_error
*/
it
(
'
File_test_error_000
'
,
0
,
async
function
(
done
)
{
file
.
move
({
srcUri
:
'
internal://app/file_test_error
'
,
dstUri
:
'
internal://cache/file_test_error
'
,
success
:
function
(
uri
)
{
console
.
log
(
'
file_test_error_000 pass, uri:
'
+
uri
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_000 call move fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_0100
* @tc.name File_test_error_001
* @tc.desc Function of API, Copy files when disk space is full.
* Create the file (file_test_error) in advance and give 777 permission,
* path:/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/file_test_error
*/
it
(
'
File_test_error_001
'
,
0
,
async
function
(
done
)
{
file
.
copy
({
srcUri
:
'
internal://app/file_test_error
'
,
dstUri
:
'
internal://cache/file_test_error
'
,
success
:
function
(
uri
)
{
console
.
log
(
'
file_test_error_001 pass, uri:
'
+
uri
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_001 call copy fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_0200
* @tc.name File_test_error_002
* @tc.desc Function of API, Write files when disk space is full.
*/
it
(
'
File_test_error_002
'
,
0
,
async
function
(
done
)
{
file
.
writeText
({
uri
:
'
internal://app../file_test_error
'
,
text
:
FILE_CONTENT
,
success
:
function
()
{
console
.
log
(
'
file_test_error_002 call writeText success.
'
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_002 call writeText fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_0300
* @tc.name File_test_error_003
* @tc.desc Function of API, Write files when disk space is full.
*/
it
(
'
File_test_error_003
'
,
0
,
async
function
(
done
)
{
let
buf
=
new
Uint8Array
([
48
,
49
,
50
,
51
,
65
,
66
,
67
,
68
,
32
,
33
]);
file
.
writeArrayBuffer
({
uri
:
'
internal://app/file_test_error
'
,
buffer
:
buf
,
success
:
function
()
{
console
.
log
(
'
file_test_error_003 call writeArrayBuffer success.
'
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_003 call writeArrayBuffer fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_0400
* @tc.name File_test_error_004
* @tc.desc Function of API, When inode is full, verify the folder creation function
*/
it
(
'
File_test_error_004
'
,
0
,
async
function
(
done
)
{
file
.
mkdir
({
uri
:
'
internal://app/file_test_error004d
'
,
success
:
function
()
{
console
.
log
(
'
file_test_error_004 call mkdir success.
'
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_004 call mkdir fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_0500
* @tc.name File_test_error_005
* @tc.desc Function of API, Prerequisites create file 200M,When ram is filled to
* the remaining 100m, verify the function of reading 200m files
*/
it
(
'
File_test_error_005
'
,
0
,
async
function
(
done
)
{
file
.
readText
({
uri
:
'
internal://app/file_test_error_005
'
,
success
:
function
(
data
)
{
console
.
log
(
'
file_test_error_005 pass, Content:
'
+
data
.
text
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_005 call readText fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_0600
* @tc.name File_test_error_006
* @tc.desc Function of API, Prerequisites create file 200M,When ram is filled to
* the remaining 100m, verify the function of reading 200m files
*/
it
(
'
File_test_error_006
'
,
0
,
async
function
(
done
)
{
file
.
readArrayBuffer
({
uri
:
'
internal://app/file_test_error_006
'
,
success
:
function
(
data
)
{
console
.
log
(
'
file_test_error_006 pass, Content:
'
+
data
.
buffer
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_006 call readArrayBuffer fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_0700
* @tc.name File_test_error_007
* @tc.desc Function of API, delete file
*/
it
(
'
File_test_error_007
'
,
0
,
async
function
(
done
)
{
let
fpath
=
fileName
(
'
file_test_error_007
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
file
.
rmdir
({
uri
:
'
internal://app/file_test_error_007
'
,
recursive
:
true
,
success
:
function
()
{
console
.
log
(
'
file_test_error_007 call rmdir success.
'
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_007 call rmdir fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_0800
* @tc.name File_test_error_008
* @tc.desc Function of API, Try to delete the folder while the file in the folder is reading and writing
*/
it
(
'
File_test_error_008
'
,
0
,
async
function
(
done
)
{
file
.
writeText
({
uri
:
'
internal://app/file_test_error_008
'
,
text
:
randomString
(
4096
),
success
:
function
()
{
console
.
log
(
'
file_test_error_008 call mkdir success.
'
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_008 call mkdir fail, code:
'
+
code
+
'
, data:
'
+
data
);
expect
(
null
).
assertFail
();
},
});
file
.
rmdir
({
uri
:
'
internal://app/file_test_error_008
'
,
success
:
function
()
{
console
.
log
(
'
file_test_error_008 call rmdir success.
'
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_008 call rmdir fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_0900
* @tc.name File_test_error_009
* @tc.desc Function of API, Delete non empty folder
*/
it
(
'
File_test_error_009
'
,
0
,
async
function
(
done
)
{
let
dpath
=
fileName
(
'
file_test_error_009
'
)
+
'
d
'
;
let
fpath
=
dpath
+
'
/file_test_error_009
'
;
expect
(
fileio
.
mkdirSync
(
dpath
)
!==
null
).
assertTrue
();
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
file
.
rmdir
({
uri
:
'
internal://app/file_test_error_009d
'
,
recursive
:
true
,
success
:
function
()
{
console
.
log
(
'
file_test_error_009 call rmdir success.
'
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_009 call rmdir fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_1000
* @tc.name File_test_error_010
* @tc.desc Function of API, Delete non empty folder
*/
it
(
'
File_test_error_010
'
,
0
,
async
function
(
done
)
{
let
dpath
=
fileName
(
'
file_test_error_010
'
)
+
'
d
'
;
let
fpath
=
dpath
+
'
/file_test_error_010
'
;
expect
(
fileio
.
mkdirSync
(
dpath
)
!==
null
).
assertTrue
();
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
file
.
rmdir
({
uri
:
'
internal://app/file_test_error_010d
'
,
recursive
:
false
,
success
:
function
()
{
console
.
log
(
'
file_test_error_010 call rmdir success.
'
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_010 call rmdir fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_1100
* @tc.name File_test_error_011
* @tc.desc Function of API, Unsupported same encoding format
*/
it
(
'
File_test_error_011
'
,
0
,
async
function
(
done
)
{
file
.
writeText
({
uri
:
'
internal://app/file_test_error_011
'
,
text
:
'
hello
'
,
encoding
:
'
gbk
'
,
success
:
function
()
{
console
.
log
(
'
file_test_error_011 call writeText success.
'
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_011 call writeText fail, code:
'
+
code
+
'
, data:
'
+
data
);
done
();
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
/**
* @tc.number SUB_STORAGE_File_test_error_1200
* @tc.name File_test_error_012
* @tc.desc Function of API, Unsupported same encoding format
*/
it
(
'
File_test_error_012
'
,
0
,
async
function
(
done
)
{
file
.
writeText
({
uri
:
'
internal://app/file_test_error_012
'
,
text
:
'
Text that just for test.
'
,
encoding
:
'
Utf-8
'
,
success
:
function
()
{
console
.
log
(
'
file_test_error_012 call writeText success.
'
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_012 call writeText fail, code:
'
+
code
+
'
, data:
'
+
data
);
expect
(
null
).
assertFail
();
},
});
file
.
readText
({
uri
:
'
internal://app/file_test_error_012
'
,
encoding
:
'
GBK
'
,
success
:
function
(
data
)
{
console
.
log
(
'
file_test_error_012 call readText success.
'
+
data
.
text
);
expect
(
null
).
assertFail
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_012 call readText fail, code:
'
+
code
+
'
, data:
'
+
data
);
file
.
delete
({
uri
:
'
internal://app/file_test_error_012
'
,
success
:
function
()
{
console
.
log
(
'
file_test_error_012 call delete success
'
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
file_test_error_012 call delete fail, code:
'
+
code
+
'
, data:
'
+
data
);
expect
(
null
).
assertFail
();
},
});
},
});
setTimeout
(
function
(){
expect
(
null
).
assertFail
();
done
();
},
30
)
});
});
storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js
浏览文件 @
38f1a5d9
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import
fileio
from
'
@
system
.fileio
'
import
fileio
from
'
@
ohos
.fileio
'
import
{
describe
,
it
,
...
...
@@ -25,188 +25,14 @@ import {
prepareFile
,
fileName
,
nextFileName
,
appName
,
randomString
,
isIntNum
,
isInclude
}
from
'
./Common
'
from
'
./Common
'
describe
(
'
FileIOError
'
,
function
()
{
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0000
* @tc.name FileIo_test_error_000
* @tc.desc Function of API, Copy files when disk space is full
* Create the file (fileio_test_error) in advance and give 777 permission,
* path:/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/fileio_test_error
*/
it
(
'
FileIo_test_error_000
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
fileio_test_error
'
);
let
fpathTarget
=
appName
(
'
fileio_test_error
'
);
try
{
expect
(
fileio
.
copyFileSync
(
fpath
,
fpathTarget
)
!==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_000 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0100
* @tc.name FileIo_test_error_001
* @tc.desc Function of API, mkdir files when disk space is full
*/
it
(
'
FileIo_test_error_001
'
,
0
,
function
()
{
let
dpath
=
nextFileName
(
'
fileio_test_error_001d
'
);
try
{
expect
(
fileio
.
mkdirSync
(
dpath
)
!==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_001 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0200
* @tc.name FileIo_test_error_002
* @tc.desc Function of API, When inode is full, verify the folder creation function
*/
it
(
'
FileIo_test_error_002
'
,
0
,
function
()
{
let
dpath
=
fileName
(
'
fileio_test_error_002d
'
);
try
{
expect
(
fileio
.
mkdirSync
(
dpath
)
!==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_002 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0300
* @tc.name FileIo_test_error_003
* @tc.desc Function of API, When the disk space is full, verify the synchronous write file data function
*/
it
(
'
FileIo_test_error_003
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
fileio_test_error_003
'
);
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
expect
(
fd
!==
null
).
assertTrue
();
expect
(
fileio
.
writeSync
(
fd
,
FILE_CONTENT
)
!==
null
).
assertTrue
();
expect
(
fileio
.
closeSync
(
fd
)
!==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_003 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0400
* @tc.name FileIo_test_error_004
* @tc.desc Function of API, When the disk space is full,
* verify synchronization and write the buffer data back to the disk for data synchronization
*/
it
(
'
FileIo_test_error_004
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
fileio_test_error_004
'
);
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
expect
(
fd
!==
null
).
assertTrue
();
expect
(
fileio
.
fsyncSync
(
fd
)
!==
null
).
assertTrue
();
expect
(
fileio
.
closeSync
(
fd
)
!==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_004 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0500
* @tc.name FileIo_test_error_005
* @tc.desc Function of API, Open 200m file function when there is 100m left in RAM
* Create a 200m file (fileio_test_error_005) and grant 777 permissions,
* path:/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/fileio_test_error_005
*/
it
(
'
FileIo_test_error_005
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
fileio_test_error_005
'
);
try
{
let
fd
=
fileio
.
openSync
(
fpath
);
expect
(
fd
!==
null
).
assertTrue
();
expect
(
fileio
.
closeSync
(
fd
)
!==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_005 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0600
* @tc.name FileIo_test_error_006
* @tc.desc Function of API, Read 200m file function when there is 100m left in RAM
* Create a 200m file (fileio_test_error_005) and grant 777 permissions,
* path:/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/fileio_test_error_005
*/
it
(
'
FileIo_test_error_006
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
fileio_test_error_005
'
);
try
{
let
fd
=
fileio
.
openSync
(
fpath
);
expect
(
fd
!==
null
).
assertTrue
();
let
rlen
=
fileio
.
readSync
(
fd
,
new
ArrayBuffer
(
209715200
));
expect
(
rlen
==
209715200
).
assertTrue
();
expect
(
fileio
.
closeSync
(
fd
)
!==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_006 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0700
* @tc.name FileIo_test_error_007
* @tc.desc Function of API, Verify the function of obtaining
* 200m file stream synchronously when 100m ram is left
* Create a 200m file (fileio_test_error_005) and grant 777 permissions,
* path:/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/fileio_test_error_005
*/
it
(
'
FileIo_test_error_007
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
fileio_test_error_005
'
);
try
{
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
expect
(
ss
.
closeSync
()
!==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_007 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0800
* @tc.name FileIo_test_error_008
* @tc.desc Function of API, Read 200m file function when there is 100m left in RAM
* Create a 200m file (fileio_test_error_005) and grant 777 permissions,
* path:/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/fileio_test_error_005
*/
it
(
'
FileIo_test_error_008
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
fileio_test_error_005
'
);
try
{
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
let
rlen
=
ss
.
readSync
(
new
ArrayBuffer
(
209715200
));
expect
(
rlen
==
209715200
).
assertTrue
();
expect
(
ss
.
closeSync
()
!==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_008 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0900
* @tc.name FileIo_test_error_009
...
...
@@ -218,18 +44,20 @@ describe('FileIOError', function () {
fileio
.
mkdirSync
(
dpath
);
expect
(
prepareFile
(
fpath
,
'
hello
'
)).
assertTrue
();
try
{
expect
(
fileio
.
rmdirSync
(
dpath
)
!==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
let
fd
=
fileio
.
openSync
(
dpath
);
expect
(
isIntNum
(
fd
)).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_009 has failed for
'
+
e
);
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_009 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
Directory not empty
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
rmdirSync
(
dpath
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error1000
* @tc.number SUB_STORAGE_FileIo_test_error
_
1000
* @tc.name FileIo_test_error_010
* @tc.desc Function of API, delete file
*/
...
...
@@ -237,49 +65,22 @@ describe('FileIOError', function () {
let
fpath
=
fileName
(
'
fileio_test_error_010f
'
);
expect
(
prepareFile
(
fpath
,
'
hello
'
)).
assertTrue
();
try
{
expect
(
fileio
.
rmdirSync
(
fpath
)
!==
null
).
assertTrue
();
let
fd
=
fileio
.
openSync
(
fpath
);
expect
(
isIntNum
(
fd
)).
assertTrue
();
fileio
.
rmdirSync
(
fpath
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_010 has failed for
'
+
e
);
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_010 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
Not a directory
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_1100
* @tc.name FileIo_test_error_011
* @tc.desc Function of API, Pass in a
* path that exceeds 4096 bytes to copy the file
*/
it
(
'
FileIo_test_error_011
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
fileio_test_error_011
'
);
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
let
dpath
=
nextFileName
(
'
fileio_error_011d
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
for
(
let
i
=
0
;
i
<
16
;
i
++
)
{
if
(
i
==
15
)
{
let
fpathTarget
=
dpath
+
'
/f
'
+
randomString
(
248
);
expect
(
fileio
.
copyFileSync
(
fpath
,
fpathTarget
)
!==
null
).
assertTrue
();
console
.
log
((
i
+
1
)
+
'
copy success
'
);
expect
(
null
).
assertFail
();
}
else
{
dpath
=
dpath
+
'
/d
'
+
randomString
(
248
);
fileio
.
mkdirSync
(
dpath
);
console
.
log
((
i
+
1
)
+
'
mkdir success
'
);
}
}
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_error_011 has failed for
'
+
e
);
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0120
* @tc.number SUB_STORAGE_FileIo_test_error_1200
* @tc.name FileIo_test_error_012
* @tc.desc Function of API, flags=0o102.
The test file is exist
.
* @tc.desc Function of API, flags=0o102.
missing mode parameter
.
*/
it
(
'
FileIo_test_error_012
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
FileIo_test_error_012
'
);
...
...
@@ -288,16 +89,17 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o102
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_012 has failed for
'
+
e
);
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
();
catch
(
err
)
{
console
.
log
(
'
FileIo_test_error_012 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_
013
0
* @tc.number SUB_STORAGE_FileIO_OpenSync_
130
0
* @tc.name FileIo_test_error_013
* @tc.desc Function of API, flags=0o102
* @tc.desc Function of API, flags=0o102
, missing mode parameter.
*/
it
(
'
FileIo_test_error_013
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
FileIo_test_error_013
'
);
...
...
@@ -305,31 +107,14 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o102
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_013 has failed for
'
+
e
);
catch
(
err
)
{
console
.
log
(
'
FileIo_test_error_013 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_0140
* @tc.name FileIo_test_error_014
* @tc.desc Function of API, flags=0o202. The test file is exist.
*/
it
(
'
FileIo_test_error_014
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
FileIo_test_error_014
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o202
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_014 has failed for
'
+
e
);
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_0150
* @tc.number SUB_STORAGE_FileIO_OpenSync_1500
* @tc.name FileIo_test_error_015
* @tc.desc Function of API, flags=0o302. The test file is exist.
*/
...
...
@@ -337,17 +122,17 @@ describe('FileIOError', function () {
let
fpath
=
nextFileName
(
'
FileIo_test_error_015
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o302
);
expect
(
null
).
assertFail
();
fileio
.
openSync
(
fpath
,
0o302
,
0o666
);
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_015 has failed for
'
+
e
);
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
();
catch
(
err
)
{
console
.
log
(
'
FileIo_test_error_015 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
File exists
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_
016
0
* @tc.number SUB_STORAGE_FileIO_OpenSync_
160
0
* @tc.name FileIo_test_error_016
* @tc.desc Function of API, flags=0o100002. The test file is exist.
*/
...
...
@@ -358,48 +143,33 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o100002
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_016 has failed for
'
+
e
);
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
catch
(
e
rr
)
{
console
.
log
(
'
FileIo_test_error_016 has failed for
'
+
e
rr
);
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_
017
0
* @tc.number SUB_STORAGE_FileIO_OpenSync_
170
0
* @tc.name FileIo_test_error_017
* @tc.desc Function of API, flags=0o40002 The test file is exist.
*/
it
(
'
FileIo_test_error_017
'
,
0
,
function
()
{
let
dpath
=
nextFileName
(
'
FileIo_test_error_017
'
);
expect
(
fileio
.
mkdirSync
(
dpath
)
!==
null
).
assertTrue
(
);
fileio
.
mkdirSync
(
dpath
);
try
{
fileio
.
openSync
(
dpath
,
0o40002
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_017 has failed for
'
+
e
);
expect
(
fileio
.
rmdirSync
(
dpath
)
!==
null
).
assertTrue
();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_0180
* @tc.name FileIo_test_error_018
* @tc.desc Function of API, flags=0o20040002. The test file is exist.
*/
it
(
'
FileIo_test_error_018
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
FileIo_test_error_018
'
);
try
{
fileio
.
openSync
(
fpath
,
0o20040002
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_018 has failed for
'
+
e
);
catch
(
err
)
{
console
.
log
(
'
FileIo_test_error_017 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_
019
0
* @tc.number SUB_STORAGE_FileIO_OpenSync_
190
0
* @tc.name FileIo_test_error_019
* @tc.desc Function of API, flags=0o400002. The test file is exist.
*/
...
...
@@ -411,14 +181,14 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o400002
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_019 has failed for
'
+
e
);
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
catch
(
e
rr
)
{
console
.
log
(
'
FileIo_test_error_019 has failed for
'
+
e
rr
);
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_
02
00
* @tc.number SUB_STORAGE_FileIO_OpenSync_
20
00
* @tc.name FileIo_test_error_020
* @tc.desc Function of API, flags=0o400002. The test file is exist.
*/
...
...
@@ -430,14 +200,14 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o400002
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_020 has failed for
'
+
e
);
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
(
);
catch
(
e
rr
)
{
console
.
log
(
'
FileIo_test_error_020 has failed for
'
+
e
rr
);
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_
021
0
* @tc.number SUB_STORAGE_FileIO_OpenSync_
210
0
* @tc.name FileIo_test_error_021
* @tc.desc Function of API, flags=0o10000102. The test file is exist.
*/
...
...
@@ -447,27 +217,28 @@ describe('FileIOError', function () {
fileio
.
openSync
(
fpath
,
0o10000102
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_021 has failed for
'
+
e
);
catch
(
err
)
{
console
.
log
(
'
FileIo_test_error_021 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_OpenSync_
022
0
* @tc.name FileIo_test_error_02
2
* @tc.desc Function of API,
mode=1 The test file is exis
t.
* @tc.number SUB_STORAGE_FileIO_OpenSync_
230
0
* @tc.name FileIo_test_error_02
3
* @tc.desc Function of API,
flags=0o200000. Invalid argumen
t.
*/
it
(
'
FileIo_test_error_022
'
,
0
,
function
()
{
let
fpath
=
nextFileName
(
'
FileIo_test_error_022
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
fpathTarget
=
fpath
+
'
f1
'
;
it
(
'
FileIo_test_error_023
'
,
0
,
function
()
{
let
dpath
=
fileName
(
'
FileIo_test_error_023d
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
fileio
.
copyFileSync
(
fpath
,
fpathTarget
,
1
);
fileio
.
openSync
(
dpath
,
0o200000
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
FileIo_test_error_021 has failed for
'
+
e
);
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
();
catch
(
err
)
{
console
.
log
(
'
FileIo_test_error_023 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
Invalid argument
'
)).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
}
});
...
...
storage/storagefileioerrorjstest/src/main/js/default/test/FileVirtualPath.test.js
已删除
100644 → 0
浏览文件 @
32f56178
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录