Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7a9a4156
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,发现更多精彩内容 >>
提交
7a9a4156
编写于
6月 17, 2022
作者:
R
raoxian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update fileio testcase
Signed-off-by:
N
raoxian
<
raoxian@huawei.com
>
上级
30547c2b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
755 addition
and
181 deletion
+755
-181
storage/storagefileiojstest/src/main/js/default/test/List.test.js
...storagefileiojstest/src/main/js/default/test/List.test.js
+1
-0
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/chmod.test.js
.../main/js/default/test/module_fileio/members/chmod.test.js
+76
-37
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/chown.test.js
.../main/js/default/test/module_fileio/members/chown.test.js
+206
-21
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/fchmod.test.js
...main/js/default/test/module_fileio/members/fchmod.test.js
+81
-78
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/fchown.test.js
...main/js/default/test/module_fileio/members/fchown.test.js
+179
-15
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/lchown.test.js
...main/js/default/test/module_fileio/members/lchown.test.js
+212
-30
未找到文件。
storage/storagefileiojstest/src/main/js/default/test/List.test.js
浏览文件 @
7a9a4156
...
...
@@ -29,6 +29,7 @@ require('./module_fileio/members/chown.test.js');
require
(
'
./module_fileio/members/close.test.js
'
);
require
(
'
./module_fileio/members/copyFile.test.js
'
);
require
(
'
./module_fileio/members/createStream.test.js
'
);
require
(
'
./module_fileio/members/fchmod.test.js
'
);
require
(
'
./module_fileio/members/fchown.test.js
'
);
require
(
'
./module_fileio/members/fdatasync.test.js
'
);
require
(
'
./module_fileio/members/fdopenStream.test.js
'
);
...
...
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/chmod.test.js
浏览文件 @
7a9a4156
...
...
@@ -23,8 +23,8 @@ describe('fileio_chmod', function () {
/**
* @tc.number SUB_DF_FILEIO_CHMODSYNC_0000
* @tc.name fileio_test_chmod_sync_000
* @tc.desc Test chmodSync() interfaces
* @tc.size MEDIUM
(中型)
* @tc.desc Test chmodSync() interfaces
, mode = 0o660. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -34,20 +34,20 @@ describe('fileio_chmod', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
expect
(
fileio
.
chmodSync
(
fpath
,
0o660
)
==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o660
);
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o660
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_chmod_sync_000 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_chmod_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODSYNC_0
01
0
* @tc.number SUB_DF_FILEIO_CHMODSYNC_0
10
0
* @tc.name fileio_test_chmod_sync_001
* @tc.desc Test chmodSync() interfaces
* @tc.size MEDIUM
(中型)
* @tc.desc Test chmodSync() interfaces
, mode = 0o0700. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -57,52 +57,71 @@ describe('fileio_chmod', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
expect
(
fileio
.
chmodSync
(
fpath
,
0o0700
)
==
null
).
assertTrue
(
);
fileio
.
chmodSync
(
fpath
,
0o0700
);
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o0700
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_chmod_sync_001 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_chmod_sync_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODSYNC_0200
* @tc.name fileio_test_chmod_sync_002
* @tc.desc Test chmodSync() interfaces, invalid path. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chmod_sync_002
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chmod_sync_002
'
);
try
{
fileio
.
chmodSync
(
fpath
,
0o0700
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_chmod_sync_002 has failed for
'
+
e
);
expect
(
e
.
message
==
"
No such file or directory
"
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0000
* @tc.name fileio_test_chmod_async_000
* @tc.desc Test
chmodAsync() interfaces
* @tc.size MEDIUM
(中型)
* @tc.desc Test
the chmodAsync() interface with promise, mode = 0o660. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chmod_async_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chmod_async_00
1
'
);
let
fpath
=
await
nextFileName
(
'
fileio_test_chmod_async_00
0
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
chmod
(
fpath
,
0o660
)
.
then
(
function
(
err
)
{
expect
(
!
err
).
assertTrue
();
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o660
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
done
();
})
.
catch
(
function
(
e
)
{
console
.
log
(
e
);
console
.
info
(
e
);
});
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_chmod_async_000 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_chmod_async_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0
01
0
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0
10
0
* @tc.name fileio_test_chmod_async_001
* @tc.desc Test
chmodAsync() interfaces
* @tc.size MEDIUM
(中型)
* @tc.desc Test
the chmodAsync() interface with promise, mode = 0o0700. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -115,68 +134,88 @@ describe('fileio_chmod', function () {
fileio
.
chmod
(
fpath
,
0o0700
)
.
then
(
function
(
err
)
{
expect
(
!
err
).
assertTrue
();
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o0700
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
done
();
})
.
catch
(
function
(
e
)
{
console
.
log
(
e
);
console
.
info
(
e
);
});
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_chmod_async_001 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_chmod_async_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0
02
0
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0
20
0
* @tc.name fileio_test_chmod_async_002
* @tc.desc Test
chmodAsync() interfaces
* @tc.size MEDIUM
(中型)
* @tc.desc Test
the chmodAsync() interface with callback, mode = 0o660. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chmod_async_002
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chmod_async_00
0
'
);
let
fpath
=
await
nextFileName
(
'
fileio_test_chmod_async_00
2
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
await
fileio
.
chmod
(
fpath
,
0o660
,
function
()
{
fileio
.
chmod
(
fpath
,
0o660
,
function
()
{
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o660
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_chmod_async_002 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_chmod_async_002 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0
03
0
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0
30
0
* @tc.name fileio_test_chmod_async_003
* @tc.desc Test
chmodAsync() interfaces
* @tc.size MEDIUM
(中型)
* @tc.desc Test
the chmodAsync() interface with callback, mode = 0o0700. Test file permissions modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chmod_async_003
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chmod_async_00
0
'
);
let
fpath
=
await
nextFileName
(
'
fileio_test_chmod_async_00
3
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
await
fileio
.
chmod
(
fpath
,
0o0700
,
function
()
{
fileio
.
chmod
(
fpath
,
0o0700
,
function
()
{
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o0700
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_chmod_async_003 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_chmod_async_003 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHMODASYNC_0400
* @tc.name fileio_test_chmod_async_004
* @tc.desc Test the chmodAsync() interface with promise, invalid path. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chmod_async_004
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chmod_async_004
'
);
try
{
await
fileio
.
chmod
(
fpath
,
0o660
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_chmod_async_004 has failed for
'
+
e
);
expect
(
e
.
message
==
"
No such file or directory
"
).
assertTrue
();
done
();
}
});
});
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/chown.test.js
浏览文件 @
7a9a4156
...
...
@@ -21,10 +21,10 @@ import {
describe
(
'
fileio_chown
'
,
function
()
{
/**
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_000
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_000
0
* @tc.name fileio_test_chown_sync_000
* @tc.desc Test chownSync() interface
* @tc.size MEDIUM
(中型)
* @tc.desc Test chownSync() interface
. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -33,58 +33,243 @@ describe('fileio_chown', function () {
let
fpath
=
await
nextFileName
(
'
fileio_test_chown_sync_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
chmodSync
(
fpath
,
0o777
);
let
stat
=
fileio
.
statSync
(
fpath
);
expect
(
fileio
.
chownSync
(
fpath
,
stat
.
uid
,
stat
.
gid
)
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
chownSync
(
fpath
,
stat
.
uid
,
stat
.
gid
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_chown_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_000
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_0100
* @tc.name fileio_test_chown_sync_001
* @tc.desc Test chownSync() interface, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chown_sync_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chown_sync_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
chownSync
(
fpath
,
0
,
0
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_chown_sync_001 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Operation not permitted
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_0200
* @tc.name fileio_test_chown_sync_002
* @tc.desc Test chownSync() interface, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chown_sync_002
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chown_sync_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
stat
=
fileio
.
statSync
(
fpath
);
fileio
.
chownSync
(
fpath
,
null
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_chown_sync_002 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Invalid owner
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_0300
* @tc.name fileio_test_chown_sync_003
* @tc.desc Test chownSync() interface, wrong group. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chown_sync_003
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chown_sync_003
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
stat
=
fileio
.
statSync
(
fpath
);
fileio
.
chownSync
(
fpath
,
stat
.
uid
,
null
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_chown_sync_003 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Invalid group
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNSYNC_0400
* @tc.name fileio_test_chown_sync_004
* @tc.desc Test chownSync() interface, file does not exist. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chown_sync_004
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chown_sync_004
'
);
let
ffpath
=
await
nextFileName
(
'
fileio_test_chown_sync_004_1
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
stat
=
fileio
.
statSync
(
fpath
);
fileio
.
chownSync
(
ffpath
,
stat
.
uid
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_chown_sync_004 has failed for
'
+
e
);
expect
(
e
.
message
==
"
No such file or directory
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0000
* @tc.name fileio_test_chown_async_00
* @tc.desc Test
chownASync() interface
* @tc.size MEDIUM
(中型)
* @tc.desc Test
the chownAsync() interface with promise. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_chown_async_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_
chown_A
sync_000
'
);
it
(
'
fileio_
test_
chown_async_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_
test_chown_a
sync_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
chmodSync
(
fpath
,
0o777
);
let
stat
=
fileio
.
statSync
(
fpath
);
expect
(
await
fileio
.
chown
(
fpath
,
stat
.
uid
,
stat
.
gid
)
==
null
).
assertTrue
(
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
await
fileio
.
chown
(
fpath
,
stat
.
uid
,
stat
.
gid
);
fileio
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_chown_async_000 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_chown_async_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0
01
* @tc.name fileio_test_chown_async_00
* @tc.desc Test
chownASync() interface
* @tc.size MEDIUM
(中型)
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0
100
* @tc.name fileio_test_chown_async_00
1
* @tc.desc Test
the chownAsync() interface with callback. The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_chown_async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_
chown_A
sync_001
'
);
it
(
'
fileio_
test_
chown_async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_
test_chown_a
sync_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
chmodSync
(
fpath
,
0o777
);
let
stat
=
fileio
.
statSync
(
fpath
);
fileio
.
chown
(
fpath
,
stat
.
uid
,
stat
.
gid
,
function
(
error
)
{
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileio_chown_A
sync_001 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_chown_a
sync_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0200
* @tc.name fileio_test_chown_async_002
* @tc.desc Test the chownAsync() interface with promise, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chown_async_002
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chown_async_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
await
fileio
.
chown
(
fpath
,
0
,
0
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_chown_async_002 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Operation not permitted
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0300
* @tc.name fileio_test_chown_async_003
* @tc.desc Test the chownAsync() interface with promise, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chown_async_003
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chown_async_003
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
stat
=
fileio
.
statSync
(
fpath
);
await
fileio
.
chown
(
fpath
,
null
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_chown_async_003 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Invalid owner
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0400
* @tc.name fileio_test_chown_async_004
* @tc.desc Test the chownAsync() interface with callback, wrong group. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chown_async_004
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chown_async_004
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
stat
=
fileio
.
statSync
(
fpath
);
fileio
.
chown
(
fpath
,
stat
.
uid
,
null
,
function
(
error
)
{
});
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_chown_async_004 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Invalid group
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_CHOWNASYNC_0500
* @tc.name fileio_test_chown_async_005
* @tc.desc Test the chownAsync() interface with promise, file does not exist. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_chown_async_005
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_chown_async_005
'
);
let
ffpath
=
await
nextFileName
(
'
fileio_test_chown_async_005_1
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
stat
=
fileio
.
statSync
(
fpath
);
await
fileio
.
chown
(
ffpath
,
stat
.
uid
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_chown_async_005 has failed for
'
+
e
);
expect
(
e
.
message
==
"
No such file or directory
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
});
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/fchmod.test.js
浏览文件 @
7a9a4156
...
...
@@ -21,120 +21,105 @@ import {
describe
(
'
fileio_fchmod
'
,
function
()
{
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_
A
SYNC_0000
* @tc.name fileio_test_fchmod_
a
sync_000
* @tc.desc Test fchmod
Async()interfaces
.
* @tc.number SUB_DF_FILEIO_FCHMOD_SYNC_0000
* @tc.name fileio_test_fchmod_sync_000
* @tc.desc Test fchmod
Sync() interfaces, mode = 0o660. Test file permissions modified successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchmod_
async_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchmod_
a
sync_000
'
);
it
(
'
fileio_test_fchmod_
sync_000
'
,
0
,
async
function
(
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchmod_sync_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
await
fileio
.
open
(
fpath
,
0o1
,
0o0200
)
.
then
(
function
(
fd
)
{
fileio
.
fchmod
(
fd
,
1002
,
function
(
err
)
{
fileio
.
statSync
(
fpath
);
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
});
})
.
catch
(
function
(
err
)
{
expect
(
err
==
null
).
assertTrue
();
});
let
fd
=
fileio
.
openSync
(
fpath
,
0o2
);
fileio
.
fchmodSync
(
fd
,
0o660
);
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o660
).
assertTrue
();
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchmod_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_
ASYNC_001
0
* @tc.name fileio_test_fchmod_
a
sync_001
* @tc.desc Test fchmod
Async()interfaces
.
* @tc.number SUB_DF_FILEIO_FCHMOD_
SYNC_010
0
* @tc.name fileio_test_fchmod_sync_001
* @tc.desc Test fchmod
Sync() interfaces, invalid fd. Test file modification failed
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchmod_async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchmod_async_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
it
(
'
fileio_test_fchmod_sync_001
'
,
0
,
function
()
{
try
{
await
fileio
.
open
(
fpath
,
0o0
,
0o0200
)
.
then
(
function
(
fd
)
{
fileio
.
fchmod
(
fd
,
1003
)
.
then
(
function
(
err
)
{
fileio
.
statSync
(
fpath
);
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
})
.
catch
(
function
(
err
)
{
expect
(
err
==
null
).
assertTrue
();
});
})
.
catch
(
function
(
err
)
{
expect
(
err
==
null
).
assertTrue
();
});
done
();
fileio
.
fchmodSync
(
-
1
,
0o660
);
}
catch
(
e
)
{
expect
(
null
).
assertFail
();
console
.
info
(
'
fileio_test_fchmod_sync_001 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Bad file descriptor
"
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_SYNC_0000
* @tc.name fileio_test_fchmod_sync_000
* @tc.desc Test
fchmodSync()interfaces
.
* @tc.number SUB_DF_FILEIO_FCHMOD_
A
SYNC_0000
* @tc.name fileio_test_fchmod_
a
sync_000
* @tc.desc Test
the fchmodAsync() interface with callback, mode = 1002. Test file permissions modified successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchmod_
sync_000
'
,
0
,
async
function
(
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchmod_sync_000
'
);
it
(
'
fileio_test_fchmod_
async_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchmod_
a
sync_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o2
);
expect
(
fileio
.
fchmodSync
(
fd
,
0o660
)
==
null
).
assertTrue
();
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o660
).
assertTrue
();
expect
(
fileio
.
closeSync
(
fd
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
let
fd
=
fileio
.
openSync
(
fpath
,
0o1
,
0o0200
);
fileio
.
fchmod
(
fd
,
1002
,
function
(
err
)
{
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o752
).
assertTrue
();
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_fchmod_
sync_000 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_fchmod_a
sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_
SYNC_001
0
* @tc.name fileio_test_fchmod_sync_001
* @tc.desc Test
fchmodSync() interfaces
.
* @tc.number SUB_DF_FILEIO_FCHMOD_
ASYNC_010
0
* @tc.name fileio_test_fchmod_
a
sync_001
* @tc.desc Test
the fchmodAsync() interface with callback, mode = 1003. Test file permissions modified successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchmod_sync_001
'
,
0
,
function
()
{
it
(
'
fileio_test_fchmod_async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchmod_async_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
expect
(
fileio
.
fchmodSync
(
-
1
,
0o660
)
==
null
).
assertTrue
();
expect
(
null
).
assertFail
();
let
fd
=
fileio
.
openSync
(
fpath
,
0o0
,
0o0200
);
fileio
.
fchmod
(
fd
,
1003
).
then
(
function
(
err
)
{
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o753
).
assertTrue
();
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
})
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_fchmod_sync_001 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_fchmod_async_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0
02
0
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0
20
0
* @tc.name fileio_test_fchmod_async_002
* @tc.desc Test
fchmod() interfaces
.
* @tc.desc Test
the fchmodAsync() interface with callback, mode = 0o100. Test file permissions modified successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -144,23 +129,23 @@ describe('fileio_fchmod', function () {
let
fpath
=
await
nextFileName
(
'
fileio_test_fchmod_async_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
await
fileio
.
open
(
fpath
,
0o1
,
0o020
).
then
(
function
(
fd
)
{
fileio
.
fchmod
(
fd
,
0o100
,
function
(
err
)
{
expect
(
fileio
.
closeSync
(
fd
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
done
(
);
}
);
let
fd
=
fileio
.
openSync
(
fpath
,
0o1
,
0o020
);
fileio
.
fchmod
(
fd
,
0o100
,
function
(
err
)
{
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o100
).
assertTrue
();
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
done
(
);
});
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_fchmod_async_002 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_fchmod_async_002 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0
03
0
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0
30
0
* @tc.name fileio_test_fchmod_async_003
* @tc.desc Test
fchmod() interfaces
.
* @tc.desc Test
the fchmodAsync() interface with promise, mode = 0o400. Test file permissions modified successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -170,16 +155,34 @@ describe('fileio_fchmod', function () {
let
fpath
=
await
nextFileName
(
'
fileio_test_fchmod_async_003
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
await
fileio
.
open
(
fpath
,
0o1
,
0o020
);
expect
((
await
fileio
.
fchmod
(
fd
,
0o400
))
==
null
).
assertTrue
();
expect
(
fileio
.
closeSync
(
fd
)
==
null
).
assertTrue
(
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
let
fd
=
fileio
.
openSync
(
fpath
,
0o1
,
0o020
);
await
fileio
.
fchmod
(
fd
,
0o400
);
expect
((
fileio
.
statSync
(
fpath
).
mode
&
0o777
)
==
0o400
).
assertTrue
();
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_fchmod_async_003 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_fchmod_async_003 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHMOD_ASYNC_0400
* @tc.name fileio_test_fchmod_async_004
* @tc.desc Test the fchmodAsync() interface with promise, invalid fd. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchmod_async_004
'
,
0
,
async
function
(
done
)
{
try
{
await
fileio
.
fchmod
(
-
1
,
0o666
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchmod_async_004 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Bad file descriptor
"
).
assertTrue
();
done
();
}
});
});
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/fchown.test.js
浏览文件 @
7a9a4156
...
...
@@ -23,7 +23,7 @@ describe('fileio_fchown', async function () {
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0000
* @tc.name fileio_test_fchown_async_000
* @tc.desc Test
fchown() and open() and statSync() interfaces
.
* @tc.desc Test
the fchownAsync() interface with callback. The test file was modified successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -36,20 +36,22 @@ describe('fileio_fchown', async function () {
let
stat
=
fileio
.
statSync
(
fpath
);
expect
(
isIntNum
(
stat
.
uid
)).
assertTrue
();
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
fileio
.
fchmodSync
(
fd
,
0o777
);
fileio
.
fchown
(
fd
,
stat
.
uid
,
stat
.
gid
,
function
(
err
)
{
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
});
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchown_async_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0
01
0
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0
10
0
* @tc.name fileio_test_fchown_async_001
* @tc.desc Test
fchown() and open() and statSync() interfaces
.
* @tc.desc Test
the fchownAsync() interface with promise. The test file was modified successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -62,19 +64,21 @@ describe('fileio_fchown', async function () {
let
stat
=
fileio
.
statSync
(
fpath
);
expect
(
isIntNum
(
stat
.
uid
)).
assertTrue
();
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
fileio
.
fchown
(
fd
,
stat
.
uid
,
stat
.
gid
);
expect
(
fileio
.
closeSync
(
fd
)
==
null
).
assertTrue
();
fileio
.
fchmodSync
(
fd
,
0o777
);
await
fileio
.
fchown
(
fd
,
stat
.
uid
,
stat
.
gid
);
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchown_async_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0
02
0
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0
20
0
* @tc.name fileio_test_fchown_async_002
* @tc.desc Test
fchown() and open() and statSync() interfaces
.
* @tc.desc Test
the fchownAsync() interface with promise, invalid fd. Test file modification failed
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -85,14 +89,82 @@ describe('fileio_fchown', async function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
stat
=
fileio
.
statSync
(
fpath
);
expect
(
isIntNum
(
stat
.
uid
)).
assertTrue
();
fileio
.
fchown
(
-
1
,
stat
.
uid
,
stat
.
gid
);
expect
(
null
).
assertFail
();
await
fileio
.
fchown
(
-
1
,
stat
.
uid
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchown_async_002 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Bad file descriptor
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0300
* @tc.name fileio_test_fchown_async_003
* @tc.desc Test the fchownAsync() interface with promise, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchown_async_003
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchown_async_003
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
fileio
.
openSync
(
fpath
);
await
fileio
.
fchown
(
fd
,
0
,
0
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_fchown_003 has failed for
'
+
e
);
expect
(
!!
e
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
console
.
info
(
'
fileio_test_fchown_async_003 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Operation not permitted
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0400
* @tc.name fileio_test_fchown_async_004
* @tc.desc Test the fchownAsync() interface with promise, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchown_async_004
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchown_async_004
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
fileio
.
openSync
(
fpath
);
let
stat
=
fileio
.
statSync
(
fpath
);
await
fileio
.
fchown
(
fd
,
null
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchown_async_004 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Operation not permitted
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_ASYNC_0500
* @tc.name fileio_test_fchown_async_005
* @tc.desc Test the fchownAsync() interface with promise, wrong group. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchown_async_005
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchown_async_005
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
fileio
.
openSync
(
fpath
);
let
stat
=
fileio
.
statSync
(
fpath
);
await
fileio
.
fchown
(
fd
,
stat
.
uid
,
null
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchown_async_005 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Invalid group
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
...
...
@@ -100,7 +172,7 @@ describe('fileio_fchown', async function () {
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_SYNC_0000
* @tc.name fileio_test_fchown_sync_000
* @tc.desc Test fchownSync() interface.
* @tc.desc Test fchownSync() interface.
The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -113,11 +185,103 @@ describe('fileio_fchown', async function () {
let
stat
=
fileio
.
statSync
(
fpath
);
expect
(
isIntNum
(
stat
.
uid
)).
assertTrue
();
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
fileio
.
fchmodSync
(
fd
,
0o777
);
fileio
.
fchownSync
(
fd
,
stat
.
uid
,
stat
.
gid
);
expect
(
fileio
.
closeSync
(
fd
)
==
null
).
assertTrue
(
);
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchown_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_SYNC_0100
* @tc.name fileio_test_fchown_sync_001
* @tc.desc Test fchownSync() interface, invalid fd. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchown_sync_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchown_sync_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
stat
=
fileio
.
statSync
(
fpath
);
fileio
.
fchownSync
(
-
1
,
stat
.
uid
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchown_sync_001 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Bad file descriptor
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_SYNC_0200
* @tc.name fileio_test_fchown_sync_002
* @tc.desc Test fchownSync() interface, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchown_sync_002
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchown_sync_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
fileio
.
openSync
(
fpath
);
fileio
.
fchownSync
(
fd
,
0
,
0
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchown_sync_002 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Operation not permitted
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_SYNC_0300
* @tc.name fileio_test_fchown_sync_003
* @tc.desc Test fchownSync() interface, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchown_sync_003
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchown_sync_003
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
fileio
.
openSync
(
fpath
);
let
stat
=
fileio
.
statSync
(
fpath
);
fileio
.
fchownSync
(
fd
,
null
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchown_sync_003 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Operation not permitted
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_DF_FILEIO_FCHOWN_SYNC_0400
* @tc.name fileio_test_fchown_sync_004
* @tc.desc Test fchownSync() interface, wrong group. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_fchown_sync_004
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_fchown_sync_004
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
fd
=
fileio
.
openSync
(
fpath
);
let
stat
=
fileio
.
statSync
(
fpath
);
fileio
.
fchownSync
(
fd
,
stat
.
uid
,
null
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_fchown_sync_004 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Operation not permitted
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
});
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/lchown.test.js
浏览文件 @
7a9a4156
...
...
@@ -21,9 +21,9 @@ import {
describe
(
'
fileio_lchown
'
,
function
()
{
/**
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_000
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_000
0
* @tc.name fileio_test_lchown_sync_000
* @tc.desc Test lchownSync() interface.
* @tc.desc Test lchownSync() interface.
The test file was modified successfully.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -31,86 +31,268 @@ describe('fileio_lchown', function () {
*/
it
(
'
fileio_test_lchown_sync_000
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_lchown_sync_000
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlinkSync
(
fpath
,
ffpath
);
let
stat
=
fileio
.
statSync
(
fpath
);
expect
(
fileio
.
lchownSync
(
fpath
,
stat
.
uid
,
stat
.
gid
)
==
null
).
assertTrue
(
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
lchownSync
(
ffpath
,
stat
.
uid
,
stat
.
gid
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_lchown_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_0
01
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_0
100
* @tc.name fileio_test_lchown_sync_001
* @tc.desc Test lchownSync() interface.
* @tc.desc Test lchownSync() interface
, invalid path. Test file modification failed
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_lchown_sync_001
'
,
0
,
async
function
()
{
it
(
'
fileio_test_lchown_sync_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_lchown_sync_001
'
);
let
ffpath
=
await
nextFileName
(
'
fileio_test_lchown_sync_001_1
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
stat
=
fileio
.
statSync
(
fpath
);
expect
(
isIntNum
(
stat
.
uid
)).
assertTrue
();
expect
(
fileio
.
lchownSync
(
'
/
'
,
stat
.
uid
,
stat
.
gid
));
expect
(
null
).
assertFail
();
fileio
.
lchownSync
(
ffpath
,
stat
.
uid
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_lchown_sync_001 has failed for
'
+
e
);
expect
(
e
.
message
==
"
No such file or directory
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_0200
* @tc.name fileio_test_lchown_sync_002
* @tc.desc Test lchownSync() interface, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_lchown_sync_002
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_lchown_sync_002
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlinkSync
(
fpath
,
ffpath
);
fileio
.
lchownSync
(
ffpath
,
0
,
0
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_lchown_sync_002 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Operation not permitted
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
}
});
/**
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_0300
* @tc.name fileio_test_lchown_sync_003
* @tc.desc Test lchownSync() interface, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_lchown_sync_003
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_lchown_sync_003
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlinkSync
(
fpath
,
ffpath
);
let
stat
=
fileio
.
statSync
(
fpath
);
fileio
.
lchownSync
(
ffpath
,
null
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_lchown_sync_003 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Invalid owner
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
}
});
/**
* @tc.number SUB_DF_FILEIO_LSEEK_SYNC_0400
* @tc.name fileio_test_lchown_sync_004
* @tc.desc Test lchownSync() interface, wrong group. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_lchown_sync_004
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_lchown_sync_004
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlinkSync
(
fpath
,
ffpath
);
let
stat
=
fileio
.
statSync
(
fpath
);
fileio
.
lchownSync
(
ffpath
,
stat
.
uid
,
null
);
}
catch
(
e
)
{
expect
(
!!
e
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
console
.
info
(
'
fileio_test_lchown_sync_004 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Invalid group
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_000
* @tc.name fileio_test_lchown_async_00
* @tc.desc Test
lchownASync() interface
.
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_000
0
* @tc.name fileio_test_lchown_async_00
0
* @tc.desc Test
the lchownASync() interface with promise. The test file was modified successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_lchown_Async_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_lchown_Async_000
'
);
it
(
'
fileio_test_lchown_async_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_lchown_async_000
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlinkSync
(
fpath
,
ffpath
);
let
stat
=
fileio
.
statSync
(
fpath
);
expect
(
await
fileio
.
lchown
(
fpath
,
stat
.
uid
,
stat
.
gid
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
await
fileio
.
lchown
(
ffpath
,
stat
.
uid
,
stat
.
gid
);
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_lchown_async_000 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_lchown_async_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0
01
* @tc.name fileio_test_lchown_async_00
* @tc.desc Test
lchownASync() interface
.
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0
100
* @tc.name fileio_test_lchown_async_00
1
* @tc.desc Test
the lchownASync() interface with callback. The test file was modified successfully
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_lchown_Async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_lchown_Async_001
'
);
it
(
'
fileio_test_lchown_async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_lchown_async_001
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlinkSync
(
fpath
,
ffpath
);
let
stat
=
fileio
.
statSync
(
fpath
);
fileio
.
lchown
(
fpath
,
stat
.
uid
,
stat
.
gid
,
function
(
error
)
{
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
fileio
.
lchown
(
ffpath
,
stat
.
uid
,
stat
.
gid
,
function
(
error
)
{
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileio_lchown_A
sync_001 has failed for
'
+
e
);
console
.
info
(
'
fileio_test_lchown_a
sync_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0200
* @tc.name fileio_test_lchown_async_002
* @tc.desc Test the lchownASync() interface with promise, invalid path. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_lchown_async_002
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_lchown_async_002
'
);
let
ffpath
=
await
nextFileName
(
'
fileio_test_lchown_sync_001_1
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
stat
=
fileio
.
statSync
(
fpath
);
await
fileio
.
lchown
(
ffpath
,
stat
.
uid
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_lchown_async_002 has failed for
'
+
e
);
expect
(
e
.
message
==
"
No such file or directory
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0300
* @tc.name fileio_test_lchown_async_003
* @tc.desc Test the lchownASync() interface with promise, wrong uid, gid. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_lchown_async_003
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_lchown_async_003
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlinkSync
(
fpath
,
ffpath
);
await
fileio
.
lchown
(
ffpath
,
0
,
0
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_lchown_async_003 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Operation not permitted
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0400
* @tc.name fileio_test_lchown_async_004
* @tc.desc Test the lchownASync() interface with promise, wrong owner. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_lchown_async_004
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_lchown_async_004
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlinkSync
(
fpath
,
ffpath
);
let
stat
=
fileio
.
statSync
(
fpath
);
await
fileio
.
lchown
(
ffpath
,
null
,
stat
.
gid
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_lchown_async_004 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Invalid owner
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_LCHOWN_ASYNC_0500
* @tc.name fileio_test_lchown_async_005
* @tc.desc Test the lchownASync() interface with promise, wrong group. Test file modification failed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_lchown_async_005
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_lchown_async_005
'
);
let
ffpath
=
fpath
+
'
aaaa
'
;
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
symlinkSync
(
fpath
,
ffpath
);
let
stat
=
fileio
.
statSync
(
fpath
);
await
fileio
.
lchown
(
ffpath
,
stat
.
uid
,
null
);
}
catch
(
e
)
{
console
.
info
(
'
fileio_test_lchown_async_005 has failed for
'
+
e
);
expect
(
e
.
message
==
"
Invalid group
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
unlinkSync
(
ffpath
);
done
();
}
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录