Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
275336e1
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
275336e1
编写于
1月 20, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test cases
上级
6ceb6117
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
114 addition
and
14 deletion
+114
-14
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+13
-5
source/libs/tfs/test/tfsTest.cpp
source/libs/tfs/test/tfsTest.cpp
+97
-3
tests/script/sim/db/basic6.sim
tests/script/sim/db/basic6.sim
+0
-1
tests/script/sim/dnode/basic1.sim
tests/script/sim/dnode/basic1.sim
+4
-5
未找到文件。
source/libs/tfs/src/tfs.c
浏览文件 @
275336e1
...
...
@@ -141,6 +141,7 @@ const char *tfsGetDiskPath(STfs *pTfs, SDiskID diskId) { return TFS_DISK_AT(pTfs
void
tfsInitFile
(
STfs
*
pTfs
,
STfsFile
*
pFile
,
SDiskID
diskId
,
const
char
*
rname
)
{
STfsDisk
*
pDisk
=
TFS_DISK_AT
(
pTfs
,
diskId
);
if
(
pDisk
==
NULL
)
return
;
pFile
->
did
=
diskId
;
tstrncpy
(
pFile
->
rname
,
rname
,
TSDB_FILENAME_LEN
);
...
...
@@ -197,9 +198,7 @@ void tfsDirname(const STfsFile *pFile, char *dest) {
tstrncpy
(
dest
,
dirname
(
tname
),
TSDB_FILENAME_LEN
);
}
int32_t
tfsRemoveFile
(
const
STfsFile
*
pFile
)
{
return
remove
(
pFile
->
aname
);
}
int32_t
tfsRemoveFile
(
const
STfsFile
*
pFile
)
{
return
remove
(
pFile
->
aname
);
}
int32_t
tfsCopyFile
(
const
STfsFile
*
pFile1
,
const
STfsFile
*
pFile2
)
{
return
taosCopyFile
(
pFile1
->
aname
,
pFile2
->
aname
);
...
...
@@ -332,7 +331,12 @@ const STfsFile *tfsReaddir(STfsDir *pDir) {
// Skip . and ..
if
(
strcmp
(
dp
->
d_name
,
"."
)
==
0
||
strcmp
(
dp
->
d_name
,
".."
)
==
0
)
continue
;
snprintf
(
bname
,
TMPNAME_LEN
*
2
,
"%s%s%s"
,
pDir
->
dirname
,
TD_DIRSEP
,
dp
->
d_name
);
if
(
pDir
->
dirname
==
NULL
||
pDir
->
dirname
[
0
]
==
0
)
{
snprintf
(
bname
,
TMPNAME_LEN
*
2
,
"%s"
,
dp
->
d_name
);
}
else
{
snprintf
(
bname
,
TMPNAME_LEN
*
2
,
"%s%s%s"
,
pDir
->
dirname
,
TD_DIRSEP
,
dp
->
d_name
);
}
tfsInitFile
(
pDir
->
pTfs
,
&
pDir
->
tfile
,
pDir
->
did
,
bname
);
return
&
pDir
->
tfile
;
}
...
...
@@ -502,7 +506,11 @@ static int32_t tfsOpendirImpl(STfs *pTfs, STfsDir *pDir) {
pDir
->
did
.
level
=
pDisk
->
level
;
pDir
->
did
.
id
=
pDisk
->
id
;
snprintf
(
adir
,
TMPNAME_LEN
*
2
,
"%s%s%s"
,
pDisk
->
path
,
TD_DIRSEP
,
pDir
->
dirname
);
if
(
pDisk
->
path
==
NULL
||
pDisk
->
path
[
0
]
==
0
)
{
snprintf
(
adir
,
TMPNAME_LEN
*
2
,
"%s"
,
pDir
->
dirname
);
}
else
{
snprintf
(
adir
,
TMPNAME_LEN
*
2
,
"%s%s%s"
,
pDisk
->
path
,
TD_DIRSEP
,
pDir
->
dirname
);
}
pDir
->
dir
=
opendir
(
adir
);
if
(
pDir
->
dir
!=
NULL
)
break
;
}
...
...
source/libs/tfs/test/tfsTest.cpp
浏览文件 @
275336e1
...
...
@@ -158,7 +158,7 @@ TEST_F(TfsTest, 03_Dir) {
tfsClose
(
pTfs
);
}
#if 0
TEST_F
(
TfsTest
,
04
_File
)
{
int32_t
code
=
0
;
SDiskCfg
dCfg
=
{
0
};
...
...
@@ -194,6 +194,100 @@ TEST_F(TfsTest, 04_File) {
EXPECT_FALSE
(
tfsIsSameFile
(
&
file0
,
&
file3
));
EXPECT_FALSE
(
tfsIsSameFile
(
&
file0
,
&
file4
));
{
int32_t
size
=
1024
;
void
*
ret
=
malloc
(
size
+
sizeof
(
size_t
));
*
(
size_t
*
)
ret
=
size
;
void
*
buf
=
(
void
*
)((
char
*
)
ret
+
sizeof
(
size_t
));
file0
.
did
.
id
=
0
;
file0
.
did
.
level
=
0
;
int32_t
len
=
tfsEncodeFile
((
void
**
)
&
buf
,
&
file0
);
EXPECT_EQ
(
len
,
8
);
STfsFile
outfile
=
{
0
};
char
*
outbuf
=
(
char
*
)
tfsDecodeFile
(
pTfs
,
(
void
*
)((
char
*
)
buf
-
len
),
&
outfile
);
int32_t
decodeLen
=
(
outbuf
-
(
char
*
)
buf
);
EXPECT_EQ
(
outfile
.
did
.
id
,
0
);
EXPECT_EQ
(
outfile
.
did
.
level
,
0
);
EXPECT_STREQ
(
outfile
.
aname
,
file0
.
aname
);
EXPECT_STREQ
(
outfile
.
rname
,
"fname"
);
EXPECT_EQ
(
outfile
.
pTfs
,
pTfs
);
}
{
char
n1
[]
=
"t3/t1.json"
;
char
n2
[]
=
"t3/t2.json"
;
STfsFile
f1
=
{
0
};
STfsFile
f2
=
{
0
};
SDiskID
did
;
did
.
id
=
0
;
did
.
level
=
0
;
tfsInitFile
(
pTfs
,
&
f1
,
did
,
n1
);
tfsInitFile
(
pTfs
,
&
f2
,
did
,
n2
);
EXPECT_EQ
(
tfsMkdir
(
pTfs
,
"t3"
),
0
);
FILE
*
fp
=
fopen
(
f1
.
aname
,
"w"
);
ASSERT_NE
(
fp
,
nullptr
);
fwrite
(
"12345678"
,
1
,
5
,
fp
);
fclose
(
fp
);
char
base
[
128
]
=
{
0
};
tfsBasename
(
&
f1
,
base
);
char
dir
[
128
]
=
{
0
};
tfsDirname
(
&
f1
,
dir
);
EXPECT_STREQ
(
base
,
"t1.json"
);
char
fulldir
[
128
];
snprintf
(
fulldir
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
"t3"
);
EXPECT_STREQ
(
dir
,
fulldir
);
EXPECT_NE
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
char
af2
[
128
]
=
{
0
};
snprintf
(
af2
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
n2
);
EXPECT_EQ
(
taosDirExist
(
af2
),
0
);
tfsRemoveFile
(
&
f2
);
EXPECT_NE
(
taosDirExist
(
af2
),
0
);
EXPECT_NE
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
""
);
const
STfsFile
*
pf1
=
tfsReaddir
(
pDir
);
EXPECT_STREQ
(
pf1
->
rname
,
"t3"
);
EXPECT_EQ
(
pf1
->
did
.
id
,
0
);
EXPECT_EQ
(
pf1
->
did
.
level
,
0
);
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
const
STfsFile
*
pf2
=
tfsReaddir
(
pDir
);
EXPECT_EQ
(
pf2
,
nullptr
);
tfsClosedir
(
pDir
);
}
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"t3"
);
const
STfsFile
*
pf1
=
tfsReaddir
(
pDir
);
EXPECT_NE
(
pf1
,
nullptr
);
EXPECT_EQ
(
pf1
->
did
.
id
,
0
);
EXPECT_EQ
(
pf1
->
did
.
level
,
0
);
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
const
STfsFile
*
pf2
=
tfsReaddir
(
pDir
);
EXPECT_NE
(
pf2
,
nullptr
);
const
STfsFile
*
pf3
=
tfsReaddir
(
pDir
);
EXPECT_EQ
(
pf3
,
nullptr
);
tfsClosedir
(
pDir
);
}
}
tfsClose
(
pTfs
);
}
#endif
\ No newline at end of file
}
\ No newline at end of file
tests/script/sim/db/basic6.sim
浏览文件 @
275336e1
...
...
@@ -114,7 +114,6 @@ while $i < 5
$i = $i + 1
endw
return
print =============== step7
$i = 0
while $i < 5
...
...
tests/script/sim/dnode/basic1.sim
浏览文件 @
275336e1
...
...
@@ -177,12 +177,11 @@ if $rows != 3 then
return -1
endi
sql select * from st
if $rows != 15 then
return -1
endi
#
sql select * from st
#
if $rows != 15 then
#
return -1
#
endi
return
print =============== drop dnode
sql drop dnode 2;
sql show dnodes;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录