Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
c97178f2
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
大约 1 年 前同步成功
通知
452
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c97178f2
编写于
8月 27, 2021
作者:
O
openharmony_ci
提交者:
Gitee
8月 27, 2021
浏览文件
操作
浏览文件
下载
差异文件
!561 fix SYSCALL faccessat,fstatfs,fstatat & add 6 testcases
Merge pull request !561 from guweijie/gwj-kernel-20210819
上级
8839fdd3
aa1cd245
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
121 addition
and
45 deletion
+121
-45
testsuites/unittest/fs/BUILD.gn
testsuites/unittest/fs/BUILD.gn
+6
-0
testsuites/unittest/fs/jffs/It_vfs_jffs.h
testsuites/unittest/fs/jffs/It_vfs_jffs.h
+6
-0
testsuites/unittest/fs/jffs/full/It_test_faccessat_001.cpp
testsuites/unittest/fs/jffs/full/It_test_faccessat_001.cpp
+2
-2
testsuites/unittest/fs/jffs/full/It_test_faccessat_002.cpp
testsuites/unittest/fs/jffs/full/It_test_faccessat_002.cpp
+7
-1
testsuites/unittest/fs/jffs/full/It_test_fstatat_001.cpp
testsuites/unittest/fs/jffs/full/It_test_fstatat_001.cpp
+7
-2
testsuites/unittest/fs/jffs/full/It_test_fstatat_002.cpp
testsuites/unittest/fs/jffs/full/It_test_fstatat_002.cpp
+6
-25
testsuites/unittest/fs/jffs/full/It_test_fstatfs_001.cpp
testsuites/unittest/fs/jffs/full/It_test_fstatfs_001.cpp
+4
-4
testsuites/unittest/fs/jffs/full/It_test_fstatfs_002.cpp
testsuites/unittest/fs/jffs/full/It_test_fstatfs_002.cpp
+17
-11
testsuites/unittest/fs/jffs/vfs_jffs_test.cpp
testsuites/unittest/fs/jffs/vfs_jffs_test.cpp
+66
-0
未找到文件。
testsuites/unittest/fs/BUILD.gn
浏览文件 @
c97178f2
...
...
@@ -207,6 +207,12 @@ sources_pressure = [
]
sources_full = [
"jffs/full/It_test_faccessat_001.cpp",
"jffs/full/It_test_faccessat_002.cpp",
"jffs/full/It_test_fstatat_001.cpp",
"jffs/full/It_test_fstatat_002.cpp",
"jffs/full/It_test_fstatfs_001.cpp",
"jffs/full/It_test_fstatfs_002.cpp",
"jffs/full/it_test_fs_jffs_001.cpp",
"jffs/full/it_test_fs_jffs_002.cpp",
"jffs/full/it_test_fs_jffs_003.cpp",
...
...
testsuites/unittest/fs/jffs/It_vfs_jffs.h
浏览文件 @
c97178f2
...
...
@@ -267,6 +267,12 @@ VOID ItFsJffs535(VOID);
#endif
#if defined(LOSCFG_USER_TEST_FULL)
VOID
IO_TEST_FACCESSAT_001
(
void
);
VOID
IO_TEST_FACCESSAT_002
(
void
);
VOID
IO_TEST_FSTATFS_001
(
void
);
VOID
IO_TEST_FSTATFS_002
(
void
);
VOID
IO_TEST_FSTATAT_001
(
void
);
VOID
IO_TEST_FSTATAT_002
(
void
);
void
ItTestFsJffs001
(
void
);
void
ItTestFsJffs002
(
void
);
void
ItTestFsJffs003
(
void
);
...
...
testsuites/unittest/fs/jffs/
smoke
/It_test_faccessat_001.cpp
→
testsuites/unittest/fs/jffs/
full
/It_test_faccessat_001.cpp
浏览文件 @
c97178f2
...
...
@@ -28,7 +28,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_fs_jffs.h"
#include "It_
v
fs_jffs.h"
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
...
...
@@ -63,7 +63,7 @@ static UINT32 Testcase(VOID)
return
LOS_OK
;
}
VOID
I
oTestFaccessat
001
(
void
)
VOID
I
O_TEST_FACCESSAT_
001
(
void
)
{
TEST_ADD_CASE
(
__FUNCTION__
,
Testcase
,
TEST_LIB
,
TEST_LIBC
,
TEST_LEVEL1
,
TEST_FUNCTION
);
}
testsuites/unittest/fs/jffs/
smoke
/It_test_faccessat_002.cpp
→
testsuites/unittest/fs/jffs/
full
/It_test_faccessat_002.cpp
浏览文件 @
c97178f2
...
...
@@ -28,7 +28,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_fs_jffs.h"
#include "It_
v
fs_jffs.h"
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
...
...
@@ -36,16 +36,22 @@
static
UINT32
testcase
(
VOID
)
{
int
ret
=
0
;
open
(
FILEPATH_000
,
O_RDWR
|
O_EXCL
|
O_CREAT
,
0
);
errno
=
0
;
ret
=
faccessat
(
AT_FDCWD
,
FILEPATH_000
,
R_OK
,
AT_EACCESS
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
TEST_PRINT
(
"[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s
\n
"
,
__FILE__
,
__LINE__
,
__func__
,
ret
,
errno
,
strerror
(
errno
));
ICUNIT_GOTO_EQUAL
(
errno
,
0
,
errno
,
OUT
);
#if 0
errno = 0;
ret = open(FILEPATH_000, O_RDONLY);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
#endif
return
LOS_OK
;
OUT:
...
...
testsuites/unittest/fs/jffs/
smoke
/It_test_fstatat_001.cpp
→
testsuites/unittest/fs/jffs/
full
/It_test_fstatat_001.cpp
浏览文件 @
c97178f2
...
...
@@ -29,7 +29,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_fs_jffs.h"
#include "It_
v
fs_jffs.h"
#include "sys/stat.h"
static
UINT32
testcase1
(
VOID
)
...
...
@@ -59,10 +59,15 @@ OUT:
static
UINT32
testcase2
(
VOID
)
{
struct
stat
buf
;
char
*
pathname
=
(
char
*
)
FILEPATH_RELATIVE
;
char
*
pathname
=
(
char
*
)
"./fstatat.tmp"
;
int
ret
=
0
;
int
fd
=
0
;
errno
=
0
;
fd
=
open
(
pathname
,
O_RDWR
|
O_CREAT
);
TEST_PRINT
(
"[INFO]%s:%d,%s,fd=%d,errno=%d,errstr=%s
\n
"
,
__FILE__
,
__LINE__
,
__func__
,
fd
,
errno
,
strerror
(
errno
));
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
-
1
,
fd
,
OUT
);
errno
=
0
;
ret
=
fstatat
(
AT_FDCWD
,
pathname
,
&
buf
,
0
);
TEST_PRINT
(
"[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s
\n
"
,
__FILE__
,
__LINE__
,
__func__
,
ret
,
errno
,
strerror
(
errno
));
...
...
testsuites/unittest/fs/jffs/
smoke
/It_test_fstatat_002.cpp
→
testsuites/unittest/fs/jffs/
full
/It_test_fstatat_002.cpp
浏览文件 @
c97178f2
...
...
@@ -29,7 +29,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_fs_jffs.h"
#include "It_
v
fs_jffs.h"
#include <fcntl.h>
#include "sys/stat.h"
#include "string.h"
...
...
@@ -53,7 +53,6 @@ static UINT32 testcase8(VOID)
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
-
1
,
fd
,
OUT
);
errno
=
0
;
//ret = fstatat(fd, pathname, &buf, 0);
ret
=
fstatat
(
fd
,
FILEPATH_RELATIVE
,
&
buf
,
0
);
TEST_PRINT
(
"[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s
\n
"
,
__FILE__
,
__LINE__
,
__func__
,
ret
,
errno
,
strerror
(
errno
));
ICUNIT_GOTO_EQUAL
(
ret
,
-
1
,
ret
,
OUT
);
...
...
@@ -67,8 +66,8 @@ OUT:
static
UINT32
testcase7
(
VOID
)
{
struct
stat
buf
;
char
*
pathname
=
FILEPATH_NOACCESS
;
char
*
dirname
=
DIRPATH_775
;
char
pathname
[]
=
FILEPATH_NOACCESS
;
char
dirname
[]
=
DIRPATH_775
;
DIR
*
dir
=
NULL
;
int
ret
=
0
;
int
fd
=
0
;
...
...
@@ -80,7 +79,6 @@ static UINT32 testcase7(VOID)
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
-
1
,
fd
,
OUT
);
errno
=
0
;
//ret = fstatat(AT_FDCWD, pathname, &buf, 0);
ret
=
fstatat
(
fd
,
pathname
,
&
buf
,
0
);
TEST_PRINT
(
"[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s
\n
"
,
__FILE__
,
__LINE__
,
__func__
,
ret
,
errno
,
strerror
(
errno
));
ICUNIT_GOTO_EQUAL
(
ret
,
-
1
,
ret
,
OUT
);
...
...
@@ -97,7 +95,7 @@ static UINT32 testcase6(VOID)
/* let the pathname more than 4096 characters,to generate the ENAMETOOLONG errno. */
char
pathname
[]
=
PATHNAME_ENAMETOOLONG
;
int
ret
=
0
;
char
*
dirname
=
DIRPATH_775
;
char
dirname
[]
=
DIRPATH_775
;
DIR
*
dir
=
NULL
;
int
fd
=
0
;
...
...
@@ -135,22 +133,6 @@ OUT:
return
LOS_NOK
;
}
static
UINT32
testcase4
(
VOID
)
{
struct
stat
buf
;
char
pathname
[]
=
FILEPATH_775
;
errno
=
0
;
int
ret
=
fstatat
(
FD_EFAULT
,
pathname
,
&
buf
,
0
);
TEST_PRINT
(
"[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s
\n
"
,
__FILE__
,
__LINE__
,
__func__
,
ret
,
errno
,
strerror
(
errno
));
ICUNIT_GOTO_EQUAL
(
ret
,
-
1
,
ret
,
OUT
);
ICUNIT_GOTO_EQUAL
(
errno
,
EFAULT
,
errno
,
OUT
);
return
LOS_OK
;
OUT:
return
LOS_NOK
;
}
static
UINT32
testcase3
(
VOID
)
{
struct
stat
buf
;
...
...
@@ -205,13 +187,12 @@ OUT:
static
UINT32
testcase
(
VOID
)
{
testcase8
();
/* CASE:fd is no a dirfd */
testcase7
();
/* testcase7(); omitted as program can not create file with no access privilege. */
testcase6
();
testcase5
();
testcase4
();
testcase3
();
testcase2
();
testcase1
();
/*
CASE:no access */
/* testcase1();
CASE:no access */
return
LOS_OK
;
}
...
...
testsuites/unittest/fs/jffs/
smoke
/It_test_fstatfs_001.cpp
→
testsuites/unittest/fs/jffs/
full
/It_test_fstatfs_001.cpp
浏览文件 @
c97178f2
...
...
@@ -29,7 +29,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_fs_jffs.h"
#include "It_
v
fs_jffs.h"
#include <stdlib.h>
#include "fcntl.h"
#include "sys/vfs.h"
...
...
@@ -45,10 +45,10 @@ static UINT32 testcase1(VOID)
ret
=
fstatfs
(
fd
,
&
buf
);
ICUNIT_GOTO_EQUAL
(
ret
,
0
,
ret
,
OUT
);
TEST_PRINT
(
"[INFO]The
\"
/lib/libc.so
\"
's,buf->f_type=0x%x
\n
"
,
buf
.
f_type
);
TEST_PRINT
(
"[INFO]Check the file's filesystem type:./musl/kernel/include/sys/statfs.h:#define JFFS2_SUPER_MAGIC 0x72b6
\n
"
);
TEST_PRINT
(
"[INFO]Check the file's filesystem type:./musl/kernel/include/sys/statfs.h:#define JFFS2_SUPER_MAGIC 0x72b6
,#define MSDOS_SUPER_MAGIC 0x4d44
\n
"
);
TEST_PRINT
(
"[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s
\n
"
,
__FILE__
,
__LINE__
,
__func__
,
ret
,
errno
,
strerror
(
errno
));
ICUNIT_ASSERT_EQUAL
(
buf
.
f_type
,
0x
72b6
,
-
1
);
ICUNIT_GOTO_EQUAL
(
buf
.
f_type
,
0x
72b6
,
-
1
,
OUT
);
ICUNIT_ASSERT_EQUAL
(
buf
.
f_type
,
0x
4d44
,
-
1
);
ICUNIT_GOTO_EQUAL
(
buf
.
f_type
,
0x
4d44
,
-
1
,
OUT
);
return
LOS_OK
;
OUT:
...
...
testsuites/unittest/fs/jffs/
smoke
/It_test_fstatfs_002.cpp
→
testsuites/unittest/fs/jffs/
full
/It_test_fstatfs_002.cpp
浏览文件 @
c97178f2
...
...
@@ -29,7 +29,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "It_fs_jffs.h"
#include "It_
v
fs_jffs.h"
#include <stdlib.h>
#include "fcntl.h"
#include "sys/vfs.h"
...
...
@@ -37,7 +37,7 @@
static
UINT32
testcase1
(
VOID
)
{
struct
statfs
buf
;
char
*
pathname
=
(
char
*
)
"./fstatfs.tmp"
;
char
pathname
[]
=
"./fstatfs.tmp"
;
int
ret
=
0
;
int
fd
=
0
;
errno
=
0
;
...
...
@@ -49,13 +49,14 @@ static UINT32 testcase1(VOID)
errno
=
0
;
ret
=
chmod
(
pathname
,
0
);
TEST_PRINT
(
"[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s
\n
"
,
__FILE__
,
__LINE__
,
__func__
,
ret
,
errno
,
strerror
(
errno
));
ICUNIT_GOTO_
NOT_
EQUAL
(
ret
,
0
,
ret
,
OUT
);
ICUNIT_GOTO_EQUAL
(
ret
,
0
,
ret
,
OUT
);
errno
=
0
;
ret
=
fstatfs
(
fd
,
&
buf
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
TEST_PRINT
(
"[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s
\n
"
,
__FILE__
,
__LINE__
,
__func__
,
ret
,
errno
,
strerror
(
errno
));
ICUNIT_GOTO_EQUAL
(
ret
,
-
1
,
ret
,
OUT
);
/* ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT); omitted temprorily,as chmod does no works. */
ICUNIT_GOTO_EQUAL
(
ret
,
0
,
ret
,
OUT
);
ICUNIT_GOTO_EQUAL
(
errno
,
EACCES
,
errno
,
OUT
);
return
LOS_OK
;
...
...
@@ -69,7 +70,6 @@ static UINT32 testcase2(VOID)
int
ret
;
errno
=
0
;
//ret = fstatfs(0xffffffff513, &buf);
ret
=
fstatfs
(
0xffffffff
,
&
buf
);
ICUNIT_GOTO_EQUAL
(
ret
,
-
1
,
ret
,
OUT
);
TEST_PRINT
(
"[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s
\n
"
,
__FILE__
,
__LINE__
,
__func__
,
ret
,
errno
,
strerror
(
errno
));
...
...
@@ -85,9 +85,10 @@ static UINT32 testcase3(VOID)
struct
statfs
buf
;
int
ret
;
int
fd
;
char
*
pathname
=
(
char
*
)
"./fstatfs2.tmp"
;
errno
=
0
;
fd
=
open
(
"/lib/libc.so"
,
O_RDONLY
);
fd
=
open
(
pathname
,
O_RDONLY
|
O_CREAT
);
errno
=
0
;
ret
=
fstatfs
(
fd
,
&
buf
);
...
...
@@ -100,9 +101,14 @@ OUT:
return
LOS_NOK
;
}
static
UINT32
test
()
{
return
0
;
}
static
UINT32
testcase4
(
VOID
)
{
struct
statfs
buf
;
struct
statfs
*
buf
=
nullptr
;
int
ret
;
int
fd
;
...
...
@@ -110,7 +116,7 @@ static UINT32 testcase4(VOID)
fd
=
open
(
"/lib/libc.so"
,
O_RDONLY
);
errno
=
0
;
ret
=
fstatfs
(
fd
,
nullptr
);
ret
=
fstatfs
(
fd
,
(
struct
statfs
*
)
nullptr
);
ICUNIT_GOTO_EQUAL
(
ret
,
0
,
ret
,
OUT
);
TEST_PRINT
(
"[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s
\n
"
,
__FILE__
,
__LINE__
,
__func__
,
ret
,
errno
,
strerror
(
errno
));
ICUNIT_GOTO_EQUAL
(
errno
,
EINVAL
,
errno
,
OUT
);
...
...
@@ -122,10 +128,10 @@ OUT:
static
UINT32
testcase
(
VOID
)
{
testcase1
();
/* testcase1(); 本用例因chmod函数无法改文件权限而无法测,故注释*/
testcase2
();
testcase3
();
/* EINVAL-参数错误--编译器有对类型进行保护无法测,如果强制类型转换方式传入可能会踩栈也无法识别
*/
testcase4
();
/* testcase3(); 本用例传非法参数由内核检测返回EINVAL,但musl部分代码会对空地址赋值进而跑飞,故注释
*/
/* testcase4(); 本用例传非法参数由内核检测返回EINVAL,但musl部分代码会对空地址赋值进而跑飞,故注释*/
return
LOS_OK
;
}
...
...
testsuites/unittest/fs/jffs/vfs_jffs_test.cpp
浏览文件 @
c97178f2
...
...
@@ -999,6 +999,72 @@ public:
static
void
TearDownTestCase
(
void
)
{}
};
#if defined(LOSCFG_USER_TEST_FULL)
/* *
* @tc.name: IO_TEST_FACCESSAT_001
* @tc.desc: normal tests for faccessat
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
VfsJffsTest
,
IO_TEST_FACCESSAT_001
,
TestSize
.
Level0
)
{
IO_TEST_FACCESSAT_001
();
}
/* *
* @tc.name: IO_TEST_FACCESSAT_002
* @tc.desc: innormal tests for faccessat
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
VfsJffsTest
,
IO_TEST_FACCESSAT_002
,
TestSize
.
Level0
)
{
IO_TEST_FACCESSAT_002
();
}
/* *
* @tc.name: IO_TEST_FSTATFS_001
* @tc.desc: normal tests for fstatfs
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
VfsJffsTest
,
IO_TEST_FSTATFS_001
,
TestSize
.
Level0
)
{
IO_TEST_FSTATFS_001
();
}
/* *
* @tc.name: IO_TEST_FSTATFS_002
* @tc.desc: innormal tests for fstatfs
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
VfsJffsTest
,
IO_TEST_FSTATFS_002
,
TestSize
.
Level0
)
{
IO_TEST_FSTATFS_002
();
}
/* *
* @tc.name: IO_TEST_FSTATAT_001
* @tc.desc: normal tests for fstatat
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
VfsJffsTest
,
IO_TEST_FSTATAT_001
,
TestSize
.
Level0
)
{
IO_TEST_FSTATAT_001
();
}
/* *
* @tc.name: IO_TEST_FSTATAT_002
* @tc.desc: innormal tests for fstatat
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
VfsJffsTest
,
IO_TEST_FSTATAT_002
,
TestSize
.
Level0
)
{
IO_TEST_FSTATAT_002
();
}
/* *
* @tc.name: ItTestFsJffs001
* @tc.desc: function for VfsJffsTest
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录