Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
76507c05
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
464
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看板
提交
76507c05
编写于
8月 11, 2021
作者:
O
openharmony_ci
提交者:
Gitee
8月 11, 2021
浏览文件
操作
浏览文件
下载
差异文件
!477 fix fstatfs api
Merge pull request !477 from wcc/fstatfs
上级
9b24cc49
4c57aa26
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
384 addition
and
22 deletion
+384
-22
syscall/fs_syscall.c
syscall/fs_syscall.c
+43
-0
syscall/los_syscall.h
syscall/los_syscall.h
+2
-0
syscall/syscall_lookup.h
syscall/syscall_lookup.h
+2
-0
testsuites/unittest/fs/BUILD.gn
testsuites/unittest/fs/BUILD.gn
+4
-0
testsuites/unittest/fs/jffs/It_vfs_jffs.h
testsuites/unittest/fs/jffs/It_vfs_jffs.h
+5
-0
testsuites/unittest/fs/jffs/full/it_test_fs_jffs_001.cpp
testsuites/unittest/fs/jffs/full/it_test_fs_jffs_001.cpp
+132
-7
testsuites/unittest/fs/jffs/full/it_test_fs_jffs_002.cpp
testsuites/unittest/fs/jffs/full/it_test_fs_jffs_002.cpp
+61
-11
testsuites/unittest/fs/jffs/full/it_test_fs_jffs_003.cpp
testsuites/unittest/fs/jffs/full/it_test_fs_jffs_003.cpp
+43
-2
testsuites/unittest/fs/jffs/full/it_test_fs_jffs_004.cpp
testsuites/unittest/fs/jffs/full/it_test_fs_jffs_004.cpp
+48
-2
testsuites/unittest/fs/jffs/vfs_jffs_test.cpp
testsuites/unittest/fs/jffs/vfs_jffs_test.cpp
+44
-0
未找到文件。
syscall/fs_syscall.c
浏览文件 @
76507c05
...
...
@@ -2444,4 +2444,47 @@ OUT:
return
ret
;
}
int
SysFstatfs
(
int
fd
,
struct
statfs
*
buf
)
{
int
ret
;
struct
file
*
filep
=
NULL
;
struct
statfs
bufRet
=
{
0
};
/* Process fd convert to system global fd */
fd
=
GetAssociatedSystemFd
(
fd
);
ret
=
fs_getfilep
(
fd
,
&
filep
);
if
(
ret
<
0
)
{
ret
=
-
get_errno
();
return
ret
;
}
ret
=
statfs
(
filep
->
f_path
,
&
bufRet
);
if
(
ret
<
0
)
{
ret
=
-
get_errno
();
return
ret
;
}
ret
=
LOS_ArchCopyToUser
(
buf
,
&
bufRet
,
sizeof
(
struct
statfs
));
if
(
ret
!=
0
)
{
ret
=
-
EFAULT
;
}
return
ret
;
}
int
SysFstatfs64
(
int
fd
,
size_t
sz
,
struct
statfs
*
buf
)
{
int
ret
=
0
;
if
(
sz
!=
sizeof
(
struct
statfs
))
{
ret
=
-
EINVAL
;
return
ret
;
}
ret
=
SysFstatfs
(
fd
,
buf
);
return
ret
;
}
#endif
syscall/los_syscall.h
浏览文件 @
76507c05
...
...
@@ -258,6 +258,8 @@ extern int SysTruncate(const char *path, off_t length);
extern
int
SysFtruncate
(
int
fd
,
off_t
length
);
extern
int
SysStatfs
(
const
char
*
path
,
struct
statfs
*
buf
);
extern
int
SysStatfs64
(
const
char
*
path
,
size_t
sz
,
struct
statfs
*
buf
);
extern
int
SysFstatfs
(
int
fd
,
struct
statfs
*
buf
);
extern
int
SysFstatfs64
(
int
fd
,
size_t
sz
,
struct
statfs
*
buf
);
extern
int
SysStat
(
const
char
*
path
,
struct
kstat
*
buf
);
extern
int
SysLstat
(
const
char
*
path
,
struct
kstat
*
buffer
);
...
...
syscall/syscall_lookup.h
浏览文件 @
76507c05
...
...
@@ -72,6 +72,8 @@ SYSCALL_HAND_DEF(__NR_dup2, SysDup2, int, ARG_NUM_2)
SYSCALL_HAND_DEF
(
__NR_truncate
,
SysTruncate
,
int
,
ARG_NUM_7
)
SYSCALL_HAND_DEF
(
__NR_ftruncate
,
SysFtruncate
,
int
,
ARG_NUM_7
)
SYSCALL_HAND_DEF
(
__NR_statfs
,
SysStatfs
,
int
,
ARG_NUM_2
)
SYSCALL_HAND_DEF
(
__NR_fstatfs
,
SysFstatfs
,
int
,
ARG_NUM_2
)
SYSCALL_HAND_DEF
(
__NR_fstatfs64
,
SysFstatfs64
,
int
,
ARG_NUM_3
)
SYSCALL_HAND_DEF
(
__NR_stat
,
SysStat
,
int
,
ARG_NUM_2
)
SYSCALL_HAND_DEF
(
__NR_lstat
,
SysLstat
,
int
,
ARG_NUM_2
)
SYSCALL_HAND_DEF
(
__NR_fstat
,
SysFstat
,
int
,
ARG_NUM_2
)
...
...
testsuites/unittest/fs/BUILD.gn
浏览文件 @
76507c05
...
...
@@ -207,6 +207,10 @@ sources_pressure = [
]
sources_full = [
"jffs/full/it_test_fs_jffs_001.cpp",
"jffs/full/it_test_fs_jffs_002.cpp",
"jffs/full/it_test_fs_jffs_003.cpp",
"jffs/full/it_test_fs_jffs_004.cpp",
"jffs/full/It_jffs_001.cpp",
"jffs/full/It_jffs_002.cpp",
"jffs/full/It_jffs_003.cpp",
...
...
testsuites/unittest/fs/jffs/It_vfs_jffs.h
浏览文件 @
76507c05
...
...
@@ -96,6 +96,7 @@ constexpr const char* JFFS_CHINESE_NAME1 = "���Ϻ�";
constexpr const char* JFFS_BASE_DIR = "/";
#endif
#define JFFS_FILE_MODE 0755
#define JFFS_MAIN_DIR0 "/storage"
#define JFFS_MOUNT_DIR0 "/storage"
#define JFFS_MAIN_DIR1 "/storage1"
...
...
@@ -266,6 +267,10 @@ VOID ItFsJffs535(VOID);
#endif
#if defined(LOSCFG_USER_TEST_FULL)
void
ItTestFsJffs001
(
void
);
void
ItTestFsJffs002
(
void
);
void
ItTestFsJffs003
(
void
);
void
ItTestFsJffs004
(
void
);
VOID
ItJffs001
(
VOID
);
VOID
ItJffs002
(
VOID
);
VOID
ItJffs003
(
VOID
);
...
...
testsuites/unittest/fs/jffs/
smoke
/it_test_fs_jffs_001.cpp
→
testsuites/unittest/fs/jffs/
full
/it_test_fs_jffs_001.cpp
浏览文件 @
76507c05
...
...
@@ -28,11 +28,14 @@
* 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"
#define FILEPATH "/storage/test.txt"
#define FILEPATH "/storage/testfdopen.txt"
#define TESTFILE "/storage/testfopen"
#define MAXFD 512
#define MINFD 8
static
int
TestCase
(
void
)
static
int
TestCase
0
(
void
)
{
FILE
*
fp
=
NULL
;
int
fd
=
-
1
;
...
...
@@ -40,7 +43,7 @@ static int TestCase(void)
char
rdbuf
[
10U
]
=
{
0
};
int
ret
=
-
1
;
fd
=
open
(
FILEPATH
,
O_RDWR
|
O_EXCL
|
O_CREAT
,
JFFS_FILE_MODE
);
fd
=
open
(
FILEPATH
,
O_RDWR
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT
);
/* r+ */
...
...
@@ -58,11 +61,12 @@ static int TestCase(void)
ret
=
fclose
(
fp
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
fp
=
NULL
;
/* a+ /appen + rw */
fd
=
open
(
FILEPATH
,
O_RDWR
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT
);
/* a+ */
fp
=
fdopen
(
fd
,
"a+"
);
ICUNIT_GOTO_NOT_EQUAL
(
fp
,
JFFS_TO_NULL
,
fp
,
EXIT
);
...
...
@@ -77,14 +81,135 @@ static int TestCase(void)
ret
=
fclose
(
fp
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
fp
=
NULL
;
/* r / only read */
fd
=
open
(
FILEPATH
,
O_RDWR
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT
);
fp
=
fdopen
(
fd
,
"r"
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_TO_NULL
,
fd
,
EXIT
);
ret
=
fwrite
(
buf
,
10u
,
1
,
fp
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
1
,
ret
,
EXIT
);
ret
=
fclose
(
fp
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
fp
=
NULL
;
/* w / only write */
fd
=
open
(
FILEPATH
,
O_RDWR
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT
);
fp
=
fdopen
(
fd
,
"w"
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_TO_NULL
,
fd
,
EXIT
);
ret
=
fread
(
rdbuf
,
10u
,
1
,
fp
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
1
,
ret
,
EXIT
);
ret
=
fclose
(
fp
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
fp
=
NULL
;
/* w+ */
fd
=
open
(
FILEPATH
,
O_RDWR
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT
);
fp
=
fdopen
(
fd
,
"w+"
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_TO_NULL
,
fd
,
EXIT
);
ret
=
fwrite
(
buf
,
10u
,
1
,
fp
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
ret
=
fseek
(
fp
,
0
,
SEEK_SET
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
ret
=
fread
(
rdbuf
,
10u
,
1
,
fp
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
ret
=
fclose
(
fp
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
fp
=
NULL
;
/* a */
fd
=
open
(
FILEPATH
,
O_WRONLY
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT
);
fp
=
fdopen
(
fd
,
"a"
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_TO_NULL
,
fd
,
EXIT
);
ret
=
fwrite
(
buf
,
10u
,
1
,
fp
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
ret
=
remove
(
FILEPATH
);
ret
=
fseek
(
fp
,
0
,
SEEK_SET
);
ICUNIT_GOTO_NOT_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
ret
=
fread
(
rdbuf
,
10u
,
1
,
fp
);
ICUNIT_GOTO_EQUAL
(
ret
,
0
,
ret
,
EXIT
);
ret
=
fclose
(
fp
);
return
JFFS_NO_ERROR
;
EXIT:
if
(
fp
!=
NULL
)
{
fclose
(
fp
);
}
else
{
remove
(
FILEPATH
);
}
return
JFFS_IS_ERROR
;
}
/* error */
static
int
TestCase1
(
void
)
{
FILE
*
fp
=
NULL
;
int
fd
=
-
1
;
int
errFd
=
-
1
;
int
i
=
0
;
fd
=
open
(
FILEPATH
,
O_RDWR
,
JFFS_FILE_MODE
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT
);
/* EIVNAL */
fp
=
fdopen
(
fd
,
"hello"
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_TO_NULL
,
fd
,
EXIT
);
ICUNIT_GOTO_EQUAL
(
errno
,
EINVAL
,
errno
,
EXIT
);
close
(
fd
);
remove
(
TESTFILE
);
return
JFFS_NO_ERROR
;
EXIT:
close
(
fd
);
remove
(
TESTFILE
);
return
JFFS_IS_ERROR
;
}
static
int
TestCase
(
void
)
{
int
ret
=
-
1
;
int
fd
=
-
1
;
fd
=
open
(
FILEPATH
,
O_RDWR
|
O_EXCL
|
O_CREAT
,
JFFS_FILE_MODE
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT
);
ret
=
TestCase0
();
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_TO_NULL
,
ret
,
EXIT
);
ret
=
TestCase1
();
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_TO_NULL
,
ret
,
EXIT
);
close
(
fd
);
remove
(
FILEPATH
);
return
JFFS_NO_ERROR
;
EXIT:
fclose
(
fp
);
close
(
fd
);
remove
(
FILEPATH
);
return
JFFS_IS_ERROR
;
...
...
testsuites/unittest/fs/jffs/
smoke
/it_test_fs_jffs_002.cpp
→
testsuites/unittest/fs/jffs/
full
/it_test_fs_jffs_002.cpp
浏览文件 @
76507c05
...
...
@@ -28,36 +28,86 @@
* 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 <stdio.h>
#include <stdlib.h>
#include <sys/statvfs.h>
#define FILEPATH
"/storage/test
.txt"
#define FILEPATHLEN
(strlen(FILEPATH) + 1U)
#define FILEPATH
"/storage/testfstatvfs
.txt"
#define FILEPATHLEN (strlen(FILEPATH) + 1U)
static
int
TestCase
(
void
)
static
int
TestCase
0
(
void
)
{
INT32
fd
=
-
1
;
INT32
ret
=
0
;
CHAR
pathname
[
FILEPATHLEN
]
=
FILEPATH
;
struct
statvfs
fileInfo
=
{
0
};
fd
=
open
(
pathname
,
O_CREAT
|
O_RDWR
|
O_EXCL
,
JFFS_FILE_MODE
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
-
1
,
fd
,
EXIT
);
fd
=
open
(
FILEPATH
,
O_RDWR
,
JFFS_FILE_MODE
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
1
,
fd
,
EXIT
);
ret
=
fstatvfs
(
fd
,
&
fileInfo
);
ret
=
fstatvfs
(
fd
,
&
fileInfo
);
ICUNIT_GOTO_EQUAL
(
ret
,
0
,
ret
,
EXIT
);
/*ICUNIT_GOTO_EQUAL(fileInfo.f_flag, 0, fileInfo.f_flag, EXIT);*/
close
(
fd
);
return
JFFS_NO_ERROR
;
EXIT:
close
(
fd
);
remove
(
pathname
);
return
JFFS_IS_ERROR
;
}
return
JFFS_NO_ERROR
;
static
int
TestCase1
(
void
)
{
INT32
fd
=
-
1
;
INT32
ret
=
0
;
INT32
errFd
=
-
1
;
struct
statvfs
fileInfo
=
{
0
};
fd
=
open
(
FILEPATH
,
O_RDWR
,
JFFS_FILE_MODE
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
JFFS_IS_ERROR
,
fd
,
EXIT
);
/* EBADF */
ret
=
fstatvfs
(
errFd
,
&
fileInfo
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
ICUNIT_GOTO_EQUAL
(
errno
,
EBADF
,
errno
,
EXIT
);
/* EBADF(When the file does not exist, an error occurs when the file is
converted from the fd file to the system FD file.) */
close
(
fd
);
ret
=
remove
(
FILEPATH
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_NO_ERROR
,
ret
,
EXIT
);
errno
=
0
;
ret
=
fstatvfs
(
fd
,
&
fileInfo
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
ICUNIT_GOTO_EQUAL
(
errno
,
EBADF
,
errno
,
EXIT
);
close
(
fd
);
return
JFFS_NO_ERROR
;
EXIT:
close
(
fd
);
remove
(
pathname
);
return
JFFS_IS_ERROR
;
}
static
int
TestCase
(
void
)
{
INT32
fd
=-
1
;
int
ret
=-
1
;
fd
=
open
(
FILEPATH
,
O_CREAT
|
O_RDWR
|
O_EXCL
,
JFFS_FILE_MODE
);
ICUNIT_GOTO_NOT_EQUAL
(
fd
,
1
,
fd
,
EXIT
);
close
(
fd
);
ret
=
TestCase0
();
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_NO_ERROR
,
ret
,
EXIT
);
ret
=
TestCase1
();
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_NO_ERROR
,
ret
,
EXIT
);
remove
(
FILEPATH
);
return
JFFS_NO_ERROR
;
EXIT:
remove
(
FILEPATH
);
return
JFFS_IS_ERROR
;
}
...
...
testsuites/unittest/fs/jffs/
smoke
/it_test_fs_jffs_003.cpp
→
testsuites/unittest/fs/jffs/
full
/it_test_fs_jffs_003.cpp
浏览文件 @
76507c05
...
...
@@ -28,12 +28,13 @@
* 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"
#define DIRPATH1 "/storage/test1"
#define DIRPATH2 "/storage/test2"
#define TEST_MAXPATHLEN 4098
static
int
TestCase
(
void
)
static
int
TestCase
0
(
void
)
{
INT32
ret
=
-
1
;
INT32
dirFd
=
-
1
;
...
...
@@ -90,6 +91,46 @@ EXIT:
return
JFFS_NO_ERROR
;
}
static
int
TestCase1
(
void
)
{
int
ret
=
-
1
;
char
pathName
[
TEST_MAXPATHLEN
]
=
{
0
};
int
errFd
=
-
1
;
/* ENAMETOOLONG */
ret
=
memset_s
(
pathName
,
TEST_MAXPATHLEN
,
1
,
TEST_MAXPATHLEN
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_NO_ERROR
,
ret
,
EXIT
);
ret
=
renameat
(
AT_FDCWD
,
pathName
,
AT_FDCWD
,
pathName
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
ICUNIT_GOTO_EQUAL
(
errno
,
ENAMETOOLONG
,
ret
,
EXIT
);
/* EINVAL */
ret
=
renameat
(
AT_FDCWD
,
"
\0
"
,
AT_FDCWD
,
"
\0
"
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
ICUNIT_GOTO_EQUAL
(
errno
,
EINVAL
,
errno
,
EXIT
);
/* ENOENT */
ret
=
renameat
(
errFd
,
"/storage/test.txt"
,
errFd
,
"/storage/test1.txt"
);
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_IS_ERROR
,
ret
,
EXIT
);
ICUNIT_GOTO_EQUAL
(
errno
,
ENOENT
,
ret
,
EXIT
);
return
JFFS_NO_ERROR
;
EXIT:
return
JFFS_IS_ERROR
;
}
static
int
TestCase
(
void
)
{
int
ret
=
-
1
;
ret
=
TestCase0
();
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_NO_ERROR
,
ret
,
EXIT
);
ret
=
TestCase1
();
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_NO_ERROR
,
ret
,
EXIT
);
return
JFFS_NO_ERROR
;
EXIT:
return
JFFS_IS_ERROR
;
}
void
ItTestFsJffs003
(
void
)
{
TEST_ADD_CASE
(
"It_Test_Fs_Jffs_003"
,
TestCase
,
TEST_VFS
,
TEST_JFFS
,
TEST_LEVEL0
,
TEST_FUNCTION
);
...
...
testsuites/unittest/fs/jffs/
smoke
/it_test_fs_jffs_004.cpp
→
testsuites/unittest/fs/jffs/
full
/it_test_fs_jffs_004.cpp
浏览文件 @
76507c05
...
...
@@ -28,11 +28,14 @@
* 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"
#define MOUNT_FILEPATH "/storage/mounts"
#define TESTFILE "/storage/hellomnt"
#define MAXFD 512
#define MINFD 8
static
int
TestCase
(
void
)
static
int
TestCase
0
(
void
)
{
CHAR
pathname1
[
JFFS_STANDARD_NAME_LENGTH
]
=
MOUNT_FILEPATH
;
struct
mntent
*
mnt
=
NULL
;
...
...
@@ -65,11 +68,54 @@ static int TestCase(void)
ICUNIT_GOTO_EQUAL
(
mnt
->
mnt_freq
,
mountsData
.
mnt_freq
,
mnt
.
mnt_freq
,
EXIT
);
ICUNIT_GOTO_EQUAL
(
mnt
->
mnt_passno
,
mountsData
.
mnt_passno
,
mnt
.
mnt_passno
,
EXIT
);
endmntent
(
fp
);
return
JFFS_NO_ERROR
;
EXIT:
endmntent
(
fp
);
return
JFFS_IS_ERROR
;
}
static
int
TestCase1
(
void
)
{
int
ret
=
-
1
;
FILE
*
fp
=
NULL
;
int
i
=
0
;
int
fd
=-
1
;
/* EINVAL */
fp
=
setmntent
(
MOUNT_FILEPATH
,
"+r"
);
ICUNIT_GOTO_EQUAL
(
fp
,
NULL
,
fp
,
EXIT
);
ICUNIT_GOTO_EQUAL
(
errno
,
EINVAL
,
fp
,
EXIT
);
/* EISDIR */
fp
=
setmntent
(
"./"
,
"r+"
);
ICUNIT_GOTO_EQUAL
(
fp
,
NULL
,
fp
,
EXIT
);
ICUNIT_GOTO_EQUAL
(
errno
,
EISDIR
,
fp
,
EXIT
);
/* ENOENT */
fp
=
setmntent
(
"/storage/testmnt"
,
"r+"
);
ICUNIT_GOTO_EQUAL
(
fp
,
NULL
,
fp
,
EXIT
);
ICUNIT_GOTO_EQUAL
(
errno
,
ENOENT
,
fp
,
EXIT
);
remove
(
TESTFILE
);
return
JFFS_NO_ERROR
;
EXIT:
remove
(
TESTFILE
);
return
JFFS_IS_ERROR
;
}
static
int
TestCase
(
void
)
{
int
ret
=
-
1
;
ret
=
TestCase0
();
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_NO_ERROR
,
ret
,
EXIT
);
ret
=
TestCase1
();
ICUNIT_GOTO_EQUAL
(
ret
,
JFFS_NO_ERROR
,
ret
,
EXIT
);
return
JFFS_NO_ERROR
;
EXIT:
return
JFFS_IS_ERROR
;
}
void
ItTestFsJffs004
(
void
)
{
TEST_ADD_CASE
(
"It_Test_Fs_Jffs_004"
,
TestCase
,
TEST_VFS
,
TEST_JFFS
,
TEST_LEVEL0
,
TEST_FUNCTION
);
...
...
testsuites/unittest/fs/jffs/vfs_jffs_test.cpp
浏览文件 @
76507c05
...
...
@@ -999,6 +999,50 @@ public:
static
void
TearDownTestCase
(
void
)
{}
};
#if defined(LOSCFG_USER_TEST_FULL)
/* *
* @tc.name: ItTestFsJffs001
* @tc.desc: function for VfsJffsTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
VfsJffsTest
,
ItTestFsJffs001
,
TestSize
.
Level0
)
{
ItTestFsJffs001
();
}
/* *
* @tc.name: ItTestFsJffs002
* @tc.desc: function for VfsJffsTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
VfsJffsTest
,
ItTestFsJffs002
,
TestSize
.
Level0
)
{
ItTestFsJffs002
();
}
/* *
* @tc.name: ItTestFsJffs003
* @tc.desc: function for VfsJffsTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
VfsJffsTest
,
ItTestFsJffs003
,
TestSize
.
Level0
)
{
ItTestFsJffs003
();
}
/* *
* @tc.name: ItTestFsJffs004
* @tc.desc: function for VfsJffsTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
VfsJffsTest
,
ItTestFsJffs004
,
TestSize
.
Level0
)
{
ItTestFsJffs004
();
}
/* *
* @tc.name: IT_JFFS_002
* @tc.desc: function for VfsJffsTest
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录