Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
2839f4a3
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2839f4a3
编写于
2月 27, 2020
作者:
W
wujing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support local offset convention for created time of image
Signed-off-by:
N
wujing
<
wujing50@huawei.com
>
上级
d33b7c7b
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
44 addition
and
23 deletion
+44
-23
src/cutils/utils_verify.c
src/cutils/utils_verify.c
+1
-1
src/image/embedded/lim.c
src/image/embedded/lim.c
+0
-6
src/services/image/image_cb.c
src/services/image/image_cb.c
+14
-4
src/types_def.c
src/types_def.c
+7
-7
src/types_def.h
src/types_def.h
+0
-2
test/services/execution/spec/selinux_label_mock_llt.cc
test/services/execution/spec/selinux_label_mock_llt.cc
+22
-3
未找到文件。
src/cutils/utils_verify.c
浏览文件 @
2839f4a3
...
...
@@ -386,7 +386,7 @@ cleanup:
bool
util_valid_time_tz
(
const
char
*
time
)
{
char
*
patten
=
"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]{2,9})?
Z
$"
;
char
*
patten
=
"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]{2,9})?
(Z|[+-][0-9]{2}:[0-9]{2})
$"
;
if
(
time
==
NULL
)
{
ERROR
(
"invalid NULL param"
);
...
...
src/image/embedded/lim.c
浏览文件 @
2839f4a3
...
...
@@ -382,12 +382,6 @@ static bool validate_create_time(char *created)
return
false
;
}
/* ensure time can be processed by us */
if
(
time_tz_to_seconds_nanos
(
created
,
NULL
,
NULL
))
{
ERROR
(
"invalid created time %s, invalid time value"
,
created
);
isulad_try_set_error_message
(
"Invalid content in manifest: invalid created time"
);
return
false
;
}
return
true
;
}
...
...
src/services/image/image_cb.c
浏览文件 @
2839f4a3
...
...
@@ -428,13 +428,23 @@ static int trans_one_image(image_list_images_response *response, size_t image_in
}
if
(
im_image
->
created
!=
NULL
)
{
if
(
time_tz_to_seconds_nanos
(
im_image
->
created
,
&
(
out_image
->
created_at
->
seconds
),
&
(
out_image
->
created_at
->
nanos
)))
{
ERROR
(
"Failed to translate created to seconds and nanos"
);
int64_t
created_nanos
=
0
;
types_timestamp_t
timestamp
;
if
(
to_unix_nanos_from_str
(
im_image
->
created
,
&
created_nanos
)
!=
0
)
{
ERROR
(
"Failed to translate created time to nanos"
);
ret
=
-
1
;
goto
out
;
}
if
(
!
unix_nanos_to_timestamp
(
created_nanos
,
&
timestamp
)
!=
0
)
{
ERROR
(
"Failed to translate nanos to timestamp"
);
ret
=
-
1
;
goto
out
;
}
out_image
->
created_at
->
seconds
=
timestamp
.
seconds
;
out_image
->
created_at
->
nanos
=
timestamp
.
nanos
;
}
out:
...
...
src/types_def.c
浏览文件 @
2839f4a3
...
...
@@ -836,7 +836,7 @@ int time_format_duration_ago(const char *in, char *out, size_t len)
return
0
;
}
int
time_tz_to_seconds_nanos
(
const
char
*
time_tz
,
int64_t
*
seconds
,
int32_t
*
nanos
)
static
int
time_tz_to_seconds_nanos
(
const
char
*
time_tz
,
int64_t
*
seconds
,
int32_t
*
nanos
)
{
int
nret
=
0
;
struct
tm
t
=
{
0
};
...
...
@@ -853,14 +853,9 @@ int time_tz_to_seconds_nanos(const char *time_tz, int64_t *seconds, int32_t *nan
return
0
;
}
if
(
!
util_valid_time_tz
(
time_tz
))
{
ERROR
(
"invalid time %s"
,
time_tz
);
return
-
1
;
}
/* translate to rfc339NanoLocal */
time_str
=
util_strdup_s
(
time_tz
);
time_str
[
strlen
(
time_str
)
-
1
]
=
0
;
/* strip last 'Z' */
time_str
[
strlen
(
time_str
)
-
1
]
=
'\0'
;
/* strip last 'Z' */
if
(
!
get_tm_from_str
(
time_str
,
&
t
,
&
nano
))
{
ERROR
(
"get tm from string %s failed"
,
time_str
);
...
...
@@ -897,6 +892,11 @@ int to_unix_nanos_from_str(const char *str, int64_t *nanos)
return
0
;
}
if
(
!
util_valid_time_tz
(
str
))
{
ERROR
(
"invalid time %s"
,
str
);
return
-
1
;
}
if
(
str
[
strlen
(
str
)
-
1
]
==
'Z'
)
{
int
ret
=
time_tz_to_seconds_nanos
(
str
,
&
ts
.
seconds
,
&
ts
.
nanos
);
if
(
ret
!=
0
)
{
...
...
src/types_def.h
浏览文件 @
2839f4a3
...
...
@@ -52,8 +52,6 @@ bool get_now_time_buffer(char *timebuffer, size_t maxsize);
int
get_time_interval
(
types_timestamp_t
first
,
types_timestamp_t
last
,
int64_t
*
result
);
int
time_tz_to_seconds_nanos
(
const
char
*
time_tz
,
int64_t
*
seconds
,
int32_t
*
nanos
);
int
to_unix_nanos_from_str
(
const
char
*
str
,
int64_t
*
nanos
);
bool
parsing_time
(
const
char
*
format
,
const
char
*
time
,
struct
tm
*
tm
,
int32_t
*
nanos
);
...
...
test/services/execution/spec/selinux_label_mock_llt.cc
浏览文件 @
2839f4a3
...
...
@@ -16,14 +16,17 @@
#include "selinux_label.h"
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "selinux_mock.h"
#include "syscall_mock.h"
using
namespace
std
;
using
::
testing
::
DoAll
;
using
::
testing
::
SetArgPointee
;
using
::
testing
::
ByRef
;
using
::
testing
::
NiceMock
;
using
::
testing
::
Return
;
using
::
testing
::
_
;
#include "selinux_mock.h"
#include "syscall_mock.h"
class
SELinuxGetEnableUnitTest
:
public
testing
::
Test
{
public:
void
SetUp
()
override
...
...
@@ -41,9 +44,25 @@ public:
NiceMock
<
MockSyscall
>
m_syscall
;
};
TEST_F
(
SELinuxGetEnableUnitTest
,
test_selinux_get_enable
)
TEST_F
(
SELinuxGetEnableUnitTest
,
test_selinux_get_enable
_abnormal
)
{
EXPECT_CALL
(
m_syscall
,
Statfs
(
_
,
_
)).
WillRepeatedly
(
Return
(
EPERM
));
EXPECT_CALL
(
m_selinux
,
SelinuxfsExists
()).
WillOnce
(
Return
(
-
1
));
ASSERT_EQ
(
selinux_get_enable
(),
false
);
}
TEST_F
(
SELinuxGetEnableUnitTest
,
test_selinux_get_enable_normal
)
{
const
uint32_t
selinuxfsMagic
=
0xf97cff8c
;
struct
statfs
sfbuf
{
.
f_type
=
selinuxfsMagic
,
.
f_flags
=
0
};
EXPECT_CALL
(
m_syscall
,
Statfs
(
_
,
_
))
.
WillOnce
(
Return
(
EPERM
))
.
WillOnce
(
DoAll
(
SetArgPointee
<
1
>
(
ByRef
(
sfbuf
)),
Return
(
0
)));
EXPECT_CALL
(
m_selinux
,
SelinuxfsExists
()).
WillOnce
(
Return
(
-
1
));
ASSERT_EQ
(
selinux_get_enable
(),
true
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录