Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
38424281
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
38424281
编写于
11月 14, 2022
作者:
M
maweiye
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add eabi and time64 api tests
Signed-off-by:
N
maweiye
<
maweiye@huawei.com
>
上级
f5a6b72c
变更
66
隐藏空白更改
内联
并排
Showing
66 changed file
with
2183 addition
and
6 deletion
+2183
-6
libc-test/BUILD.gn
libc-test/BUILD.gn
+1
-0
libc-test/src/eabi/BUILD.gn
libc-test/src/eabi/BUILD.gn
+25
-0
libc-test/src/eabi/__aeabi_memclr.c
libc-test/src/eabi/__aeabi_memclr.c
+68
-0
libc-test/src/eabi/__aeabi_memcpy.c
libc-test/src/eabi/__aeabi_memcpy.c
+75
-0
libc-test/src/eabi/__aeabi_memmove.c
libc-test/src/eabi/__aeabi_memmove.c
+74
-0
libc-test/src/eabi/__aeabi_memset.c
libc-test/src/eabi/__aeabi_memset.c
+74
-0
libc-test/src/eabi/__aeabi_read_tp.c
libc-test/src/eabi/__aeabi_read_tp.c
+37
-0
libc-test/src/eabi/__sigtimedwait_time64.c
libc-test/src/eabi/__sigtimedwait_time64.c
+88
-0
libc-test/src/functional/clock_gettime.c
libc-test/src/functional/clock_gettime.c
+3
-0
libc-test/src/functional/dlopen.c
libc-test/src/functional/dlopen.c
+1
-1
libc-test/src/functional/stat.c
libc-test/src/functional/stat.c
+11
-0
libc-test/src/functional/test_src_functional.gni
libc-test/src/functional/test_src_functional.gni
+1
-0
libc-test/src/functional/utime64.c
libc-test/src/functional/utime64.c
+76
-0
libc-test/src/functionalext/supplement/ipc/semtimedop.c
libc-test/src/functionalext/supplement/ipc/semtimedop.c
+21
-0
libc-test/src/functionalext/supplement/legacy/futimes.c
libc-test/src/functionalext/supplement/legacy/futimes.c
+23
-0
libc-test/src/functionalext/supplement/legacy/lutimes.c
libc-test/src/functionalext/supplement/legacy/lutimes.c
+31
-0
libc-test/src/functionalext/supplement/linux/__ppoll_time64.c
...-test/src/functionalext/supplement/linux/__ppoll_time64.c
+43
-0
libc-test/src/functionalext/supplement/linux/adjtimex.c
libc-test/src/functionalext/supplement/linux/adjtimex.c
+31
-0
libc-test/src/functionalext/supplement/linux/clock_adjtime.c
libc-test/src/functionalext/supplement/linux/clock_adjtime.c
+17
-0
libc-test/src/functionalext/supplement/linux/settimeofday.c
libc-test/src/functionalext/supplement/linux/settimeofday.c
+20
-0
libc-test/src/functionalext/supplement/linux/test_src_functionalext_supplement_linux.gni
...plement/linux/test_src_functionalext_supplement_linux.gni
+1
-0
libc-test/src/functionalext/supplement/linux/timerfd_gettime.c
...test/src/functionalext/supplement/linux/timerfd_gettime.c
+42
-0
libc-test/src/functionalext/supplement/linux/timerfd_settime.c
...test/src/functionalext/supplement/linux/timerfd_settime.c
+42
-0
libc-test/src/functionalext/supplement/linux/utimes.c
libc-test/src/functionalext/supplement/linux/utimes.c
+38
-1
libc-test/src/functionalext/supplement/linux/wait4.c
libc-test/src/functionalext/supplement/linux/wait4.c
+30
-1
libc-test/src/functionalext/supplement/misc/getrusage.c
libc-test/src/functionalext/supplement/misc/getrusage.c
+15
-0
libc-test/src/functionalext/supplement/network/__recvmmsg_time64.c
.../src/functionalext/supplement/network/__recvmmsg_time64.c
+135
-0
libc-test/src/functionalext/supplement/network/test_src_functionalext_supplement_network.gni
...ent/network/test_src_functionalext_supplement_network.gni
+1
-0
libc-test/src/functionalext/supplement/sched/sched_rr_get_interval.c
...rc/functionalext/supplement/sched/sched_rr_get_interval.c
+26
-1
libc-test/src/functionalext/supplement/select/pselect.c
libc-test/src/functionalext/supplement/select/pselect.c
+24
-0
libc-test/src/functionalext/supplement/select/select.c
libc-test/src/functionalext/supplement/select/select.c
+23
-0
libc-test/src/functionalext/supplement/signal/__getitimer_time64.c
.../src/functionalext/supplement/signal/__getitimer_time64.c
+72
-0
libc-test/src/functionalext/supplement/signal/__setitimer_time64.c
.../src/functionalext/supplement/signal/__setitimer_time64.c
+83
-0
libc-test/src/functionalext/supplement/signal/test_src_functionalext_supplement_signal.gni
...ement/signal/test_src_functionalext_supplement_signal.gni
+2
-0
libc-test/src/functionalext/supplement/stat/fstatat.c
libc-test/src/functionalext/supplement/stat/fstatat.c
+27
-0
libc-test/src/functionalext/supplement/stat/futimesat.c
libc-test/src/functionalext/supplement/stat/futimesat.c
+32
-0
libc-test/src/functionalext/supplement/stat/lstat.c
libc-test/src/functionalext/supplement/stat/lstat.c
+23
-1
libc-test/src/functionalext/supplement/stat/utimensat.c
libc-test/src/functionalext/supplement/stat/utimensat.c
+33
-0
libc-test/src/functionalext/supplement/thread/cnd_timedwait.c
...-test/src/functionalext/supplement/thread/cnd_timedwait.c
+47
-0
libc-test/src/functionalext/supplement/thread/mtx_timedlock.c
...-test/src/functionalext/supplement/thread/mtx_timedlock.c
+30
-0
libc-test/src/functionalext/supplement/thread/pthread_mutex_timedlock.c
...functionalext/supplement/thread/pthread_mutex_timedlock.c
+25
-0
libc-test/src/functionalext/supplement/thread/pthread_rwlock_timedrdlock.c
...ctionalext/supplement/thread/pthread_rwlock_timedrdlock.c
+27
-0
libc-test/src/functionalext/supplement/thread/pthread_rwlock_timedwrlock.c
...ctionalext/supplement/thread/pthread_rwlock_timedwrlock.c
+27
-0
libc-test/src/functionalext/supplement/thread/thrd_sleep.c
libc-test/src/functionalext/supplement/thread/thrd_sleep.c
+16
-0
libc-test/src/functionalext/supplement/time/clock_getres.c
libc-test/src/functionalext/supplement/time/clock_getres.c
+15
-0
libc-test/src/functionalext/supplement/time/clock_nanosleep.c
...-test/src/functionalext/supplement/time/clock_nanosleep.c
+18
-0
libc-test/src/functionalext/supplement/time/clock_settime.c
libc-test/src/functionalext/supplement/time/clock_settime.c
+26
-0
libc-test/src/functionalext/supplement/time/gettimeofday.c
libc-test/src/functionalext/supplement/time/gettimeofday.c
+23
-1
libc-test/src/functionalext/supplement/time/gmtime_r_sup.c
libc-test/src/functionalext/supplement/time/gmtime_r_sup.c
+46
-0
libc-test/src/functionalext/supplement/time/gmtime_sup.c
libc-test/src/functionalext/supplement/time/gmtime_sup.c
+46
-0
libc-test/src/functionalext/supplement/time/nanosleep.c
libc-test/src/functionalext/supplement/time/nanosleep.c
+17
-0
libc-test/src/functionalext/supplement/time/timer_gettime.c
libc-test/src/functionalext/supplement/time/timer_gettime.c
+16
-0
libc-test/src/functionalext/supplement/time/timer_settime.c
libc-test/src/functionalext/supplement/time/timer_settime.c
+45
-0
libc-test/src/functionalext/supplement/time/timespec_get.c
libc-test/src/functionalext/supplement/time/timespec_get.c
+20
-0
libc-test/src/functionalext/supplement/time/utime_sup.c
libc-test/src/functionalext/supplement/time/utime_sup.c
+34
-0
libc-test/src/functionalext/symver/dlsym.c
libc-test/src/functionalext/symver/dlsym.c
+36
-0
libc-test/src/functionalext/thread/pthread_cond_timedwait.c
libc-test/src/functionalext/thread/pthread_cond_timedwait.c
+31
-0
libc-test/src/functionalext/time/ctime.c
libc-test/src/functionalext/time/ctime.c
+29
-0
libc-test/src/functionalext/time/ctime_r.c
libc-test/src/functionalext/time/ctime_r.c
+31
-0
libc-test/src/functionalext/time/difftime.c
libc-test/src/functionalext/time/difftime.c
+29
-0
libc-test/src/functionalext/time/localtime.c
libc-test/src/functionalext/time/localtime.c
+32
-0
libc-test/src/functionalext/time/localtime_r.c
libc-test/src/functionalext/time/localtime_r.c
+33
-0
libc-test/src/functionalext/time/mktime.c
libc-test/src/functionalext/time/mktime.c
+29
-0
libc-test/src/functionalext/time/time_ext.c
libc-test/src/functionalext/time/time_ext.c
+36
-0
libc-test/src/functionalext/time/timegm.c
libc-test/src/functionalext/time/timegm.c
+30
-0
libc-test/src/regression/pthread_cancel-sem_wait.c
libc-test/src/regression/pthread_cancel-sem_wait.c
+20
-0
未找到文件。
libc-test/BUILD.gn
浏览文件 @
38424281
...
...
@@ -6,6 +6,7 @@ group("musl_libc_test") {
deps = [
"src/api:main",
"src/common:runtest",
"src/eabi:eabi_test",
"src/functional:functional_test",
"src/functionalext:functionalext_test",
"src/math:math_test",
...
...
libc-test/src/eabi/BUILD.gn
0 → 100644
浏览文件 @
38424281
import("../../test_template.gni")
eabi_list = [
"__aeabi_memcpy",
"__aeabi_memmove",
"__aeabi_memset",
"__aeabi_memclr",
"__aeabi_read_tp",
"__sigtimedwait_time64",
]
foreach(s, eabi_list) {
test_unittest(s) {
target_dir = "eabi"
}
}
group("eabi_test") {
testonly = true
deps = []
foreach(s, eabi_list) {
deps += [ ":${s}" ]
}
}
libc-test/src/eabi/__aeabi_memclr.c
0 → 100644
浏览文件 @
38424281
/* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include "test.h"
/**
* @tc.name : memclr_0100
* @tc.desc : Test __aeabi_memclr method
* @tc.level : Level 1
*/
extern
int
__aeabi_memclr
(
void
*
dest
,
size_t
n
);
extern
int
__aeabi_memclr4
(
void
*
dest
,
size_t
n
);
extern
int
__aeabi_memclr8
(
void
*
dest
,
size_t
n
);
void
memclr_0100
(
void
)
{
char
dest
[]
=
"__aeabi_memclr"
;
if
(
__aeabi_memclr
(
dest
,
sizeof
(
dest
))
==
0
)
{
t_error
(
"%s __aeabi_memclr"
,
__func__
);
}
}
/**
* @tc.name : memclr_0200S
* @tc.desc : Test __aeabi_memclr4 method
* @tc.level : Level 1
*/
void
memclr_0200
(
void
)
{
char
dest
[]
=
"__aeabi_memclr"
;
if
(
__aeabi_memclr4
(
dest
,
sizeof
(
dest
))
==
0
)
{
t_error
(
"%s __aeabi_memclr4"
,
__func__
);
}
}
/**
* @tc.name : memclr_0300
* @tc.desc : Test __aeabi_memclr8 method
* @tc.level : Level 1
*/
void
memclr_0300
(
void
)
{
char
dest
[]
=
"__aeabi_memclr"
;
if
(
__aeabi_memclr8
(
dest
,
sizeof
(
dest
))
==
0
)
{
t_error
(
"%s __aeabi_memclr8"
,
__func__
);
}
}
int
main
()
{
memclr_0100
();
memclr_0200
();
memclr_0300
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/eabi/__aeabi_memcpy.c
0 → 100644
浏览文件 @
38424281
/* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include "test.h"
/**
* @tc.name : memcpy_0100
* @tc.desc : Test __aeabi_memcpy method
* @tc.level : Level 1
*/
extern
void
*
__aeabi_memcpy
(
void
*
__restrict
,
const
void
*
__restrict
,
size_t
);
extern
void
*
__aeabi_memcpy4
(
void
*
__restrict
,
const
void
*
__restrict
,
size_t
);
extern
void
*
__aeabi_memcpy8
(
void
*
__restrict
,
const
void
*
__restrict
,
size_t
);
void
memcpy_0100
(
void
)
{
int
dest
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
};
int
src
[]
=
{
4
,
5
,
6
,
7
};
void
*
result
=
__aeabi_memcpy
(
dest
,
src
,
16
);
if
(
result
<
0
)
{
t_error
(
"%s __aeabi_memcpy error get result is %d
\n
"
,
__func__
,
result
);
}
}
/**
* @tc.name : memcpy_0200
* @tc.desc : Test __aeabi_memcpy4 method
* @tc.level : Level 1
*/
void
memcpy_0200
(
void
)
{
int
dest
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
};
int
src
[]
=
{
4
,
5
,
6
,
7
};
void
*
result
=
__aeabi_memcpy4
(
dest
,
src
,
16
);
if
(
result
<
0
)
{
t_error
(
"%s __aeabi_memcpy4 error get result is %d
\n
"
,
__func__
,
result
);
}
}
/**
* @tc.name : memcpy_0300
* @tc.desc : Test __aeabi_memcpy8 method
* @tc.level : Level 1
*/
void
memcpy_0300
(
void
)
{
int
dest
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
};
int
src
[]
=
{
4
,
5
,
6
,
7
};
void
*
result
=
__aeabi_memcpy8
(
dest
,
src
,
16
);
if
(
result
<
0
)
{
t_error
(
"%s __aeabi_memcpy8 error get result is %d
\n
"
,
__func__
,
result
);
}
}
int
main
()
{
memcpy_0100
();
memcpy_0200
();
memcpy_0300
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/eabi/__aeabi_memmove.c
0 → 100644
浏览文件 @
38424281
/* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include "test.h"
extern
void
*
__aeabi_memmove
(
void
*
,
const
void
*
,
size_t
);
extern
void
*
__aeabi_memmove4
(
void
*
,
const
void
*
,
size_t
);
extern
void
*
__aeabi_memmove8
(
void
*
,
const
void
*
,
size_t
);
/**
* @tc.name : memmove_0100
* @tc.desc : Test __aeabi_memmove method
* @tc.level : Level 1
*/
void
memmove_0100
(
void
)
{
int
dest
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
};
int
src
[]
=
{
4
,
5
,
6
,
7
};
int
*
result
=
__aeabi_memmove
(
dest
,
src
,
16
);
if
(
result
<
0
)
{
t_error
(
"%s __aeabi_memmove error get result is %d
\n
"
,
__func__
,
result
);
}
}
/**
* @tc.name : memmove_0200
* @tc.desc : Test __aeabi_memmove4 method
* @tc.level : Level 1
*/
void
memmove_0200
(
void
)
{
int
dest
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
};
int
src
[]
=
{
4
,
5
,
6
,
7
};
int
*
result
=
__aeabi_memmove4
(
dest
,
src
,
16
);
if
(
result
<
0
)
{
t_error
(
"%s __aeabi_memmove4 error get result is %d
\n
"
,
__func__
,
result
);
}
}
/**
* @tc.name : memmove_0300
* @tc.desc : Test __aeabi_memmove8 method
* @tc.level : Level 1
*/
void
memmove_0300
(
void
)
{
int
dest
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
};
int
src
[]
=
{
4
,
5
,
6
,
7
};
int
*
result
=
__aeabi_memmove8
(
dest
,
src
,
16
);
if
(
result
<
0
)
{
t_error
(
"%s __aeabi_memmove8 error get result is %d
\n
"
,
__func__
,
result
);
}
}
int
main
()
{
memmove_0100
();
memmove_0200
();
memmove_0300
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/eabi/__aeabi_memset.c
0 → 100644
浏览文件 @
38424281
/* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include "test.h"
extern
void
*
__aeabi_memset
(
void
*
,
int
,
size_t
);
extern
void
*
__aeabi_memset4
(
void
*
,
int
,
size_t
);
extern
void
*
__aeabi_memset8
(
void
*
,
int
,
size_t
);
/**
* @tc.name : memset_0100
* @tc.desc : Test __aeabi_memset method
* @tc.level : Level 1
*/
void
memset_0100
(
void
)
{
int
dest
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
};
int
src
=
7
;
int
*
result
=
__aeabi_memset
(
dest
,
src
,
16
);
if
(
result
<
0
)
{
t_error
(
"%s __aeabi_memset error get result is %d
\n
"
,
__func__
,
result
);
}
}
/**
* @tc.name : memset_0200
* @tc.desc : Test __aeabi_memset4 method
* @tc.level : Level 1
*/
void
memset_0200
(
void
)
{
int
dest
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
};
int
src
=
7
;
int
*
result
=
__aeabi_memset4
(
dest
,
src
,
16
);
if
(
result
<
0
)
{
t_error
(
"%s __aeabi_memset4 error get result is %d
\n
"
,
__func__
,
result
);
}
}
/**
* @tc.name : memset_0300
* @tc.desc : Test __aeabi_memset8 method
* @tc.level : Level 1
*/
void
memset_0300
(
void
)
{
int
dest
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
};
int
src
=
7
;
int
*
result
=
__aeabi_memset8
(
dest
,
src
,
16
);
if
(
result
<
0
)
{
t_error
(
"%s __aeabi_memset8 error get result is %d
\n
"
,
__func__
,
result
);
}
}
int
main
()
{
memset_0100
();
memset_0200
();
memset_0300
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/eabi/__aeabi_read_tp.c
0 → 100644
浏览文件 @
38424281
/* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <string.h>
#include "test.h"
extern
void
*
__aeabi_read_tp
();
/**
* @tc.name : memset_0100
* @tc.desc : Test __aeabi_read_tp method
* @tc.level : Level 1
*/
void
aeabi_read_tp_0100
(
void
)
{
void
*
result
=
__aeabi_read_tp
();
if
(
result
<
0
)
{
t_error
(
"%s __aeabi_read_tp error get result is %d
\n
"
,
__func__
,
__aeabi_read_tp
);
}
}
int
main
()
{
aeabi_read_tp_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/eabi/__sigtimedwait_time64.c
0 → 100644
浏览文件 @
38424281
/* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <signal.h>
#include "test.h"
extern
int
__sigtimedwait_time64
(
const
sigset_t
*
restrict
mask
,
siginfo_t
*
restrict
si
,
const
struct
timespec
*
restrict
timeout
);
/**
* @tc.name : sigtimedwait_0100
* @tc.desc : Test sigtimedwait method
* @tc.level : Level 1
*/
void
sigtimedwait_0100
(
void
)
{
sigset_t
set
;
pid_t
pid
;
sigemptyset
(
&
set
);
sigaddset
(
&
set
,
SIGCHLD
);
sigprocmask
(
SIG_BLOCK
,
&
set
,
NULL
);
pid
=
fork
();
if
(
pid
==
-
1
)
{
exit
(
1
);
}
else
if
(
pid
)
{
sigset_t
set2
;
siginfo_t
siginfo
;
struct
timespec
timeout
=
{
3
,
0
};
int
signal
;
sigemptyset
(
&
set2
);
sigaddset
(
&
set2
,
SIGCHLD
);
signal
=
sigtimedwait
(
&
set2
,
&
siginfo
,
&
timeout
);
if
(
signal
<
0
)
{
t_error
(
"%s sigtimedwait error get result is %d
\n
"
,
__func__
,
signal
);
}
}
}
/**
* @tc.name : sigtimedwait_time64_0100
* @tc.desc : Test __sigtimedwait_time64 method
* @tc.level : Level 1
*/
void
sigtimedwait_time64_0100
(
void
)
{
sigset_t
set
;
pid_t
pid
;
sigemptyset
(
&
set
);
sigaddset
(
&
set
,
SIGCHLD
);
sigprocmask
(
SIG_BLOCK
,
&
set
,
NULL
);
pid
=
fork
();
if
(
pid
==
-
1
)
{
exit
(
1
);
}
else
if
(
pid
)
{
sigset_t
set2
;
siginfo_t
siginfo
;
struct
timespec
timeout
=
{
3
,
0
};
int
signal
;
sigemptyset
(
&
set2
);
sigaddset
(
&
set2
,
SIGCHLD
);
signal
=
__sigtimedwait_time64
(
&
set2
,
&
siginfo
,
&
timeout
);
if
(
signal
<
0
)
{
t_error
(
"%s __sigtimedwait_time64 error get result is %d
\n
"
,
__func__
,
signal
);
}
}
}
int
main
()
{
sigtimedwait_0100
();
sigtimedwait_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functional/clock_gettime.c
浏览文件 @
38424281
...
...
@@ -6,9 +6,12 @@
#define TEST(c, ...) \
( (c) || (t_error(#c " failed: " __VA_ARGS__),0) )
extern
int
__clock_gettime64
(
clockid_t
,
struct
timespec
*
);
int
main
()
{
struct
timespec
ts
;
TEST
(
clock_gettime
(
CLOCK_REALTIME
,
&
ts
)
==
0
&&
errno
==
0
,
"%s
\n
"
,
strerror
(
errno
));
TEST
(
__clock_gettime64
(
CLOCK_REALTIME
,
&
ts
)
==
0
&&
errno
==
0
,
"%s
\n
"
,
strerror
(
errno
));
return
t_status
;
}
libc-test/src/functional/dlopen.c
浏览文件 @
38424281
...
...
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
t_error
(
"reopened dso should have the same symbols, want %p, got %p
\n
"
,
i
,
i2
);
if
(
*
i2
!=
2
)
t_error
(
"reopened dso should have the same symbols, want i2==2, got i2==%d
\n
"
,
*
i2
);
if
(
!
dlclose
(
g
))
if
(
dlclose
(
g
))
t_error
(
"dlclose failed: %s
\n
"
,
dlerror
());
if
(
dlclose
(
h
))
t_error
(
"dlclose failed: %s
\n
"
,
dlerror
());
...
...
libc-test/src/functional/stat.c
浏览文件 @
38424281
...
...
@@ -9,6 +9,8 @@
#define TEST(c, ...) ((c) ? 1 : (t_error(#c" failed: " __VA_ARGS__),0))
extern
int
__stat_time64
(
const
char
*
__restrict
,
struct
stat
*
__restrict
);
int
main
(
void
)
{
struct
stat
st
;
...
...
@@ -24,6 +26,15 @@ int main(void)
TEST
(
st
.
st_atime
<=
t
,
"%jd > %jd
\n
"
,
(
intmax_t
)
st
.
st_atime
,
(
intmax_t
)
t
);
}
if
(
TEST
(
__stat_time64
(
"."
,
&
st
)
==
0
,
"errno = %s
\n
"
,
strerror
(
errno
)))
{
TEST
(
S_ISDIR
(
st
.
st_mode
),
"
\n
"
);
TEST
(
st
.
st_nlink
>
0
,
"%ju
\n
"
,
(
uintmax_t
)
st
.
st_nlink
);
t
=
time
(
0
);
TEST
(
st
.
st_ctime
<=
t
,
"%jd > %jd
\n
"
,
(
intmax_t
)
st
.
st_ctime
,
(
intmax_t
)
t
);
TEST
(
st
.
st_mtime
<=
t
,
"%jd > %jd
\n
"
,
(
intmax_t
)
st
.
st_mtime
,
(
intmax_t
)
t
);
TEST
(
st
.
st_atime
<=
t
,
"%jd > %jd
\n
"
,
(
intmax_t
)
st
.
st_atime
,
(
intmax_t
)
t
);
}
if
(
TEST
(
stat
(
"/dev/null"
,
&
st
)
==
0
,
"errno = %s
\n
"
,
strerror
(
errno
)))
{
TEST
(
S_ISCHR
(
st
.
st_mode
),
"
\n
"
);
}
...
...
libc-test/src/functional/test_src_functional.gni
浏览文件 @
38424281
...
...
@@ -74,6 +74,7 @@ functional_list = [
"udiv",
"ungetc",
"utime",
"utime64",
"vfork",
"wcsstr",
"wcstol",
...
...
libc-test/src/functional/utime64.c
0 → 100644
浏览文件 @
38424281
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
#include "test.h"
#define TEST(c, ...) ((c) ? 1 : (t_error(#c" failed: " __VA_ARGS__),0))
#define TESTVAL(v,op,x) TEST(v op x, "%jd\n", (intmax_t)(v))
extern
int
__fstat_time64
(
int
,
struct
stat
*
);
extern
int
__futimens_time64
(
int
,
const
struct
timespec
[
2
]);
int
main
(
void
)
{
struct
stat
st
;
FILE
*
f
;
int
fd
;
time_t
t
;
TEST
(
utimensat
(
AT_FDCWD
,
"/dev/null/invalid"
,
((
struct
timespec
[
2
]){{.
tv_nsec
=
UTIME_OMIT
},{.
tv_nsec
=
UTIME_OMIT
}}),
0
)
==
0
||
errno
==
ENOTDIR
,
"%s
\n
"
,
strerror
(
errno
));
TEST
(
__futimens_time64
(
-
1
,
((
struct
timespec
[
2
]){{.
tv_nsec
=
UTIME_OMIT
},{.
tv_nsec
=
UTIME_OMIT
}}))
==
0
||
errno
==
EBADF
,
"%s
\n
"
,
strerror
(
errno
));
if
(
!
TEST
(
f
=
tmpfile
()))
return
t_status
;
fd
=
fileno
(
f
);
TEST
(
__futimens_time64
(
fd
,
(
struct
timespec
[
2
]){
0
})
==
0
,
"
\n
"
);
TEST
(
__fstat_time64
(
fd
,
&
st
)
==
0
,
"
\n
"
);
TESTVAL
(
st
.
st_atim
.
tv_sec
,
==
,
0
);
TESTVAL
(
st
.
st_atim
.
tv_nsec
,
==
,
0
);
TESTVAL
(
st
.
st_mtim
.
tv_sec
,
==
,
0
);
TESTVAL
(
st
.
st_mtim
.
tv_nsec
,
==
,
0
);
TEST
(
__futimens_time64
(
fd
,
((
struct
timespec
[
2
]){{.
tv_sec
=
1
,.
tv_nsec
=
UTIME_OMIT
},{.
tv_sec
=
1
,.
tv_nsec
=
UTIME_OMIT
}}))
==
0
,
"
\n
"
);
TEST
(
__fstat_time64
(
fd
,
&
st
)
==
0
,
"
\n
"
);
TESTVAL
(
st
.
st_atim
.
tv_sec
,
==
,
0
);
TESTVAL
(
st
.
st_atim
.
tv_nsec
,
==
,
0
);
TESTVAL
(
st
.
st_mtim
.
tv_sec
,
==
,
0
);
TESTVAL
(
st
.
st_mtim
.
tv_nsec
,
==
,
0
);
t
=
time
(
0
);
TEST
(
__futimens_time64
(
fd
,
((
struct
timespec
[
2
]){{.
tv_nsec
=
UTIME_NOW
},{.
tv_nsec
=
UTIME_OMIT
}}))
==
0
,
"
\n
"
);
TEST
(
__fstat_time64
(
fd
,
&
st
)
==
0
,
"
\n
"
);
TESTVAL
(
st
.
st_atim
.
tv_sec
,
>=
,
t
);
TESTVAL
(
st
.
st_mtim
.
tv_sec
,
==
,
0
);
TESTVAL
(
st
.
st_mtim
.
tv_nsec
,
==
,
0
);
TEST
(
__futimens_time64
(
fd
,
(
struct
timespec
[
2
]){
0
})
==
0
,
"
\n
"
);
TEST
(
__futimens_time64
(
fd
,
((
struct
timespec
[
2
]){{.
tv_nsec
=
UTIME_OMIT
},{.
tv_nsec
=
UTIME_NOW
}}))
==
0
,
"
\n
"
);
TEST
(
__fstat_time64
(
fd
,
&
st
)
==
0
,
"
\n
"
);
TESTVAL
(
st
.
st_atim
.
tv_sec
,
==
,
0
);
TESTVAL
(
st
.
st_mtim
.
tv_sec
,
>=
,
t
);
TEST
(
__futimens_time64
(
fd
,
((
struct
timespec
[
2
]){{.
tv_nsec
=
UTIME_NOW
},{.
tv_nsec
=
UTIME_OMIT
}}))
==
0
,
"
\n
"
);
TEST
(
__fstat_time64
(
fd
,
&
st
)
==
0
,
"
\n
"
);
TESTVAL
(
st
.
st_atim
.
tv_sec
,
>=
,
t
);
TESTVAL
(
st
.
st_mtim
.
tv_sec
,
>=
,
t
);
if
(
TEST
((
time_t
)(
1LL
<<
32
)
==
(
1LL
<<
32
),
"implementation has Y2038 EOL
\n
"
))
{
if
(
TEST
(
__futimens_time64
(
fd
,
((
struct
timespec
[
2
]){{.
tv_sec
=
1LL
<<
32
},{.
tv_sec
=
1LL
<<
32
}}))
==
0
,
"%s
\n
"
,
strerror
(
errno
)))
{
TEST
(
__fstat_time64
(
fd
,
&
st
)
==
0
,
"
\n
"
);
TESTVAL
(
st
.
st_atim
.
tv_sec
,
==
,
1LL
<<
32
);
TESTVAL
(
st
.
st_mtim
.
tv_sec
,
==
,
1LL
<<
32
);
}
}
fclose
(
f
);
return
t_status
;
}
libc-test/src/functionalext/supplement/ipc/semtimedop.c
浏览文件 @
38424281
...
...
@@ -20,6 +20,8 @@
#include "test.h"
extern
int
__semtimedop_time64
(
int
,
struct
sembuf
*
,
size_t
,
const
struct
timespec
*
);
const
char
*
path
=
"/data/tests/libc-test/src/file.txt"
;
/**
...
...
@@ -102,10 +104,29 @@ void semtimedop_0200(void)
}
}
/**
* @tc.name : semtimedop_time64_0200
* @tc.desc : System V semaphore operations with invalid parameters
* @tc.level : Level 2
*/
void
semtimedop_time64_0200
(
void
)
{
errno
=
0
;
int
result
=
__semtimedop_time64
(
-
1
,
NULL
,
-
1
,
NULL
);
if
(
result
==
0
)
{
t_error
(
"%s failed: result = %d
\n
"
,
__func__
,
result
);
}
if
(
errno
==
0
)
{
t_error
(
"%s failed: errno = %d
\n
"
,
__func__
,
errno
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
// semtimedop_0100();
// semtimedop_0200();
// semtimedop_time64_0200();
return
t_status
;
}
libc-test/src/functionalext/supplement/legacy/futimes.c
浏览文件 @
38424281
...
...
@@ -22,6 +22,8 @@
const
int
FAIL
=
-
1
;
const
int
SUCCESS
=
0
;
extern
int
__futimes_time64
(
int
,
const
struct
timeval
[
2
]);
/**
* @tc.name : futimes_0100
* @tc.desc : All parameters are valid, TV is not 0, and futimes can modify the timestamp of the file.
...
...
@@ -70,10 +72,31 @@ void futimes_0300(void)
EXPECT_EQ
(
"futimes_0300"
,
ret
,
FAIL
);
}
/**
* @tc.name : futimes_time64_0100
* @tc.desc : All parameters are valid, TV is not 0, and futimes can modify the timestamp of the file.
* @tc.level : Level 0
*/
void
futimes_time64_0100
(
void
)
{
int
ret
=
-
1
;
struct
stat
s
;
static
struct
timeval
tv
[
2
]
=
{{
0L
,
0L
},
{
0L
,
0L
}};
tv
[
0
].
tv_sec
=
s
.
st_atime
;
tv
[
0
].
tv_usec
=
0
;
tv
[
1
].
tv_sec
=
s
.
st_mtime
;
tv
[
1
].
tv_usec
=
0
;
int
fd
=
open
(
"futimes.txt"
,
O_RDWR
|
O_CREAT
,
777
);
ret
=
__futimes_time64
(
fd
,
tv
);
EXPECT_EQ
(
"futimes_time64_0100"
,
ret
,
SUCCESS
);
remove
(
"futimes.txt"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
futimes_0100
();
futimes_0200
();
futimes_0300
();
futimes_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/legacy/lutimes.c
浏览文件 @
38424281
...
...
@@ -21,6 +21,8 @@
#define TEST_FIFO_MODE 777
#define TEST_SIZE 2
extern
int
__lutimes_time64
(
const
char
*
,
const
struct
timeval
[
2
]);
/**
* @tc.name : lutimes_0100
* @tc.desc : Verify inet_lnaofof process success. Lfutimes can modify the timestamp of the file.
...
...
@@ -63,9 +65,38 @@ void lutimes_0200(void)
EXPECT_EQ
(
"lutimes_0200"
,
ret
,
-
1
);
}
/**
* @tc.name : lutimes_time64_0100
* @tc.desc : Verify inet_lnaofof process success. Lfutimes can modify the timestamp of the file.
* @tc.level : Level 0
*/
void
lutimes_time64_0100
(
void
)
{
int
ret
;
struct
stat
s
;
static
struct
timeval
tv
[
TEST_SIZE
]
=
{{
0L
,
0L
},
{
0L
,
0L
}};
tv
[
0
].
tv_sec
=
s
.
st_atime
;
tv
[
0
].
tv_usec
=
0
;
tv
[
1
].
tv_sec
=
s
.
st_mtime
;
tv
[
1
].
tv_usec
=
0
;
int
fd
=
-
1
;
fd
=
creat
(
"./lutimes_time64_0100.txt"
,
TEST_FIFO_MODE
);
if
(
fd
<
0
)
{
EXPECT_MT
(
"lutimes_time64_0100"
,
fd
,
0
);
return
;
}
else
{
close
(
fd
);
}
ret
=
__lutimes_time64
(
"./lutimes_time64_0100.txt"
,
tv
);
EXPECT_EQ
(
"lutimes_time64_0100"
,
ret
,
0
);
ret
=
remove
(
"lutimes_time64_0100.txt"
);
EXPECT_EQ
(
"lutimes_time64_0100"
,
ret
,
0
);
}
int
main
(
void
)
{
lutimes_0100
();
lutimes_0200
();
lutimes_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/linux/__ppoll_time64.c
0 → 100755
浏览文件 @
38424281
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <sys/stat.h>
#include <poll.h>
#include <time.h>
#include <fcntl.h>
#include "functionalext.h"
extern
int
__ppoll_time64
(
struct
pollfd
*
,
nfds_t
,
const
struct
timespec
*
,
const
sigset_t
*
);
/**
* @tc.name : ppoll_time64_0300
* @tc.desc : Listen for readable file event (illegal parameter)
* @tc.level : Level 2
*/
void
ppoll_time64_0300
(
void
)
{
struct
timespec
timeout
;
timeout
.
tv_sec
=
1
;
timeout
.
tv_nsec
=
0
;
int
ret
=
__ppoll_time64
(
NULL
,
1
,
&
timeout
,
NULL
);
EXPECT_EQ
(
"ppoll_time64_0300"
,
ret
,
ERREXPECT
);
}
int
main
(
void
)
{
ppoll_time64_0300
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/linux/adjtimex.c
浏览文件 @
38424281
...
...
@@ -16,6 +16,8 @@
#include <sys/timex.h>
#include "functionalext.h"
extern
int
__adjtimex_time64
(
struct
timex
*
);
const
int32_t
NUM_NEG
=
-
1
;
/**
...
...
@@ -46,9 +48,38 @@ void adjtimex_0100(void)
EXPECT_NE
(
"adjtimex_0100"
,
result
,
NUM_NEG
);
}
/**
* @tc.name : adjtimex_time64_0100
* @tc.desc : Verify the time to tune the kernel.
* @tc.level : Level 0
*/
void
adjtimex_time64_0100
(
void
)
{
struct
timex
tx
;
tx
.
offset
=
ADJ_OFFSET
;
tx
.
tick
=
ADJ_TICK
;
tx
.
maxerror
=
ADJ_MAXERROR
;
tx
.
esterror
=
ADJ_ESTERROR
;
tx
.
constant
=
ADJ_TIMECONST
;
tx
.
freq
=
ADJ_FREQUENCY
;
tx
.
status
=
ADJ_STATUS
;
tx
.
precision
=
1
;
tx
.
tolerance
=
1
;
tx
.
ppsfreq
=
1
;
tx
.
jitter
=
1
;
tx
.
stabil
=
1
;
tx
.
jitcnt
=
1
;
tx
.
calcnt
=
1
;
tx
.
errcnt
=
1
;
tx
.
stbcnt
=
1
;
int
result
=
__adjtimex_time64
(
&
tx
);
EXPECT_NE
(
"adjtimex_time64_0100"
,
result
,
NUM_NEG
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
adjtimex_0100
();
adjtimex_time64_0100
();
return
t_status
;
}
libc-test/src/functionalext/supplement/linux/clock_adjtime.c
浏览文件 @
38424281
...
...
@@ -25,6 +25,8 @@ void exception_handler(int sig)
exit
(
t_status
);
}
extern
int
__clock_adjtime64
(
clockid_t
,
struct
timex
*
);
/**
* @tc.name : clock_adjtime_0100
* @tc.desc : Verify that the kernel time can be adjusted (all parameters are valid, clock_id is CLOCK_REALTIME)
...
...
@@ -98,6 +100,20 @@ void clock_adjtime_0500(void)
EXPECT_EQ
(
"clock_adjtime_0500"
,
errno
,
EFAULT
);
}
/**
* @tc.name : clock_adjtime64_0100
* @tc.desc : Verify that the kernel time can be adjusted (all parameters are valid, clock_id is CLOCK_REALTIME)
* @tc.level : Level 0
*/
void
clock_adjtime64_0100
(
void
)
{
struct
timex
tx
;
memset
(
&
tx
,
0
,
sizeof
(
tx
));
int
result
=
__clock_adjtime64
(
CLOCK_REALTIME
,
&
tx
);
EXPECT_NE
(
"clock_adjtime64_0100"
,
result
,
-
1
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
clock_adjtime_0100
();
...
...
@@ -105,5 +121,6 @@ int main(int argc, char *argv[])
clock_adjtime_0300
();
clock_adjtime_0400
();
clock_adjtime_0500
();
clock_adjtime64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/linux/settimeofday.c
浏览文件 @
38424281
...
...
@@ -19,6 +19,8 @@
#include <time.h>
#include "test.h"
extern
int
__settimeofday_time64
(
const
struct
timeval
*
,
const
struct
timezone
*
);
/**
* @tc.name : settimeofday_0100
* @tc.desc : Test that the function returns a value when tv points to a null pointer
...
...
@@ -66,10 +68,28 @@ void settimeofday_0300(void)
}
}
/**
* @tc.name : settimeofday_time64_0200
* @tc.desc : Test the return value of the function when usec in the parameter tv is 1000000ULL
* @tc.level : Level 1
*/
void
settimeofday_time64_0200
(
void
)
{
struct
timeval
tv
;
tv
.
tv_sec
=
0
;
tv
.
tv_usec
=
1000000ULL
;
int
result
=
__settimeofday_time64
(
&
tv
,
NULL
);
if
(
result
!=
-
1
)
{
t_error
(
"%s __settimeofday_time64 failed"
,
__func__
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
settimeofday_0100
();
settimeofday_0200
();
settimeofday_0300
();
settimeofday_time64_0200
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/linux/test_src_functionalext_supplement_linux.gni
浏览文件 @
38424281
...
...
@@ -84,4 +84,5 @@ functionalext_supplement_linux_test = [
"epoll_ctl",
"epoll_pwait",
"epoll_wait",
"__ppoll_time64",
]
libc-test/src/functionalext/supplement/linux/timerfd_gettime.c
浏览文件 @
38424281
...
...
@@ -24,6 +24,8 @@
#define NANOSECOND (1000000000)
#define MICROSECONDS (1000000)
extern
int
__timerfd_gettime64
(
int
,
struct
itimerspec
*
);
/**
* @tc.name : timerfd_gettime_0100
* @tc.desc : Get the time left by the timer until the next supermarket
...
...
@@ -76,9 +78,49 @@ void timerfd_gettime_0200(void)
}
}
/**
* @tc.name : timerfd_gettime64_0100
* @tc.desc : Get the time left by the timer until the next supermarket
* @tc.level : Level 0
*/
void
timerfd_gettime64_0100
(
void
)
{
struct
itimerspec
its
=
{{
0
,
0
},
{
2
,
0
}};
struct
itimerspec
val
;
int
fd
,
result
;
fd
=
timerfd_create
(
CLOCK_REALTIME
,
0
);
if
(
fd
<
0
)
{
t_error
(
"%s timerfd_create failed"
,
__func__
);
return
;
}
result
=
timerfd_settime
(
fd
,
0
,
&
its
,
NULL
);
if
(
result
!=
0
)
{
t_error
(
"%s timerfd_settime failed"
,
__func__
);
return
;
}
result
=
usleep
(
MICROSECONDS
);
if
(
result
!=
0
)
{
t_error
(
"%s usleep failed"
,
__func__
);
return
;
}
result
=
__timerfd_gettime64
(
fd
,
&
val
);
if
(
result
!=
0
)
{
t_error
(
"%s __timerfd_gettime64 failed"
,
__func__
);
return
;
}
if
(
val
.
it_value
.
tv_nsec
>
NANOSECOND
)
{
t_error
(
"%s timerfd error"
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
timerfd_gettime_0100
();
timerfd_gettime_0200
();
timerfd_gettime64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/linux/timerfd_settime.c
浏览文件 @
38424281
...
...
@@ -23,6 +23,8 @@
#define MICROSECONDS (1000000)
#define DATA_TWO (2)
extern
int
__timerfd_settime64
(
int
,
int
,
const
struct
itimerspec
*
,
struct
itimerspec
*
);
void
exception_handler
(
int
sig
)
{
exit
(
t_status
);
...
...
@@ -79,9 +81,49 @@ void timerfd_settime_0200(void)
timerfd_settime
(
-
1
,
0
,
NULL
,
NULL
);
}
/**
* @tc.name : timerfd_settime64_0100
* @tc.desc : Start the timer specified by fd
* @tc.level : Level 0
*/
void
timerfd_settime64_0100
(
void
)
{
struct
itimerspec
its
=
{{
0
,
0
},
{
DATA_TWO
,
0
}};
struct
itimerspec
val
;
int
fd
,
result
;
fd
=
timerfd_create
(
CLOCK_REALTIME
,
0
);
if
(
fd
<
0
)
{
t_error
(
"%s timerfd_create failed
\n
"
,
__func__
);
return
;
}
result
=
__timerfd_settime64
(
fd
,
0
,
&
its
,
NULL
);
if
(
result
!=
0
)
{
t_error
(
"%s __timerfd_settime64 failed
\n
"
,
__func__
);
return
;
}
result
=
usleep
(
MICROSECONDS
);
if
(
result
!=
0
)
{
t_error
(
"%s usleep failed
\n
"
,
__func__
);
return
;
}
result
=
timerfd_gettime
(
fd
,
&
val
);
if
(
result
!=
0
)
{
t_error
(
"%s timerfd_gettime failed
\n
"
,
__func__
);
return
;
}
if
(
val
.
it_value
.
tv_nsec
>
NANOSECOND
)
{
t_error
(
"%s timerfd error
\n
"
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
timerfd_settime_0100
();
timerfd_settime_0200
();
timerfd_settime64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/linux/utimes.c
浏览文件 @
38424281
...
...
@@ -21,6 +21,8 @@
#include <time.h>
#include "test.h"
extern
int
__utimes_time64
(
const
char
*
,
const
struct
timeval
[
2
]);
/**
* @tc.name : utimes_0100
* @tc.desc : Change file last access and modification times
...
...
@@ -56,7 +58,7 @@ void utimes_0100(void)
}
/**
* @tc.name : utimes_0
1
00
* @tc.name : utimes_0
2
00
* @tc.desc : Specify time to change file last access and modification time
* @tc.level : Level 1
*/
...
...
@@ -84,9 +86,44 @@ void utimes_0200(void)
remove
(
path
);
}
/**
* @tc.name : utimes_time64_0100
* @tc.desc : Change file last access and modification times
* @tc.level : Level 0
*/
void
utimes_time64_0100
(
void
)
{
const
char
*
path
=
"/data/utimes_time64.txt"
;
int
fd
=
open
(
path
,
O_RDWR
|
O_RSYNC
|
O_CREAT
,
0664
);
if
(
fd
==
-
1
)
{
t_error
(
"%s write create file error"
,
__func__
);
return
;
}
close
(
fd
);
struct
stat
buf1
;
struct
stat
buf2
;
time_t
t_mold
,
t_aold
,
t_now
,
t_new
;
stat
(
path
,
&
buf1
);
t_mold
=
buf1
.
st_mtime
;
t_aold
=
buf1
.
st_atime
;
t_now
=
time
(
NULL
);
if
(
__utimes_time64
(
path
,
NULL
)
!=
0
)
{
t_error
(
"%s __utimes_time64 failed"
,
__func__
);
}
else
{
stat
(
path
,
&
buf2
);
t_new
=
buf2
.
st_mtime
;
if
(
t_new
!=
t_now
)
{
t_error
(
"%s __utimes_time64 failed"
,
__func__
);
}
}
remove
(
path
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
utimes_0100
();
utimes_0200
();
utimes_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/linux/wait4.c
浏览文件 @
38424281
...
...
@@ -24,6 +24,8 @@
const
int
EXIT_CODE
=
66
;
const
int
SLEEP_TIME
=
2
;
extern
pid_t
__wait4_time64
(
pid_t
,
int
*
,
int
,
struct
rusage
*
);
/**
* @tc.name : wait4_0100
* @tc.desc : Test the wait4 function to wait4 for the child process
...
...
@@ -78,10 +80,37 @@ void wait4_0200(void)
}
}
/**
* @tc.name : wait4_time64_0100
* @tc.desc : Test the __wait4_time64 function to __wait4_time64 for the child process
* @tc.level : Level 0
*/
void
wait4_time64_0100
(
void
)
{
pid_t
pid
=
fork
();
if
(
pid
>
0
)
{
int
status
=
0
;
int
options
=
0
;
struct
rusage
ru
;
pid_t
wait4_for_pind
=
__wait4_time64
(
pid
,
&
status
,
options
,
&
ru
);
if
(
wait4_for_pind
!=
pid
)
{
t_error
(
"%s __wait4_time64 get pid is %d are not want %d
\n
"
,
__func__
,
wait4_for_pind
,
pid
);
}
if
(
status
!=
0
)
{
t_error
(
"%s __wait4_time64 get status is %d are not 0
\n
"
,
__func__
,
status
);
}
}
else
if
(
pid
==
0
)
{
sleep
(
1
);
exit
(
0
);
}
else
{
t_error
(
"%s __wait4_time64 fork error
\n
"
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
wait4_0100
();
sleep
(
SLEEP_TIME
);
wait4_0200
();
wait4_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/misc/getrusage.c
浏览文件 @
38424281
...
...
@@ -16,6 +16,8 @@
#include <sys/resource.h>
#include "functionalext.h"
extern
int
__getrusage_time64
(
int
,
struct
rusage
*
);
/**
* @tc.name : getrusage_0100
* @tc.desc : Verify the program running time (parameter is RUSAGE_SELF)
...
...
@@ -76,6 +78,18 @@ void getrusage_0500(void)
EXPECT_EQ
(
"getrusage_0500"
,
result
,
-
1
);
}
/**
* @tc.name : getrusage_time64_0100
* @tc.desc : Verify the program running time (parameter is RUSAGE_SELF)
* @tc.level : Level 0
*/
void
getrusage_time64_0100
(
void
)
{
struct
rusage
usage
;
int
result
=
__getrusage_time64
(
RUSAGE_SELF
,
&
usage
);
EXPECT_EQ
(
"getrusage_time64_0100"
,
result
,
0
);
}
int
main
(
void
)
{
getrusage_0100
();
...
...
@@ -83,5 +97,6 @@ int main(void)
getrusage_0300
();
getrusage_0400
();
getrusage_0500
();
getrusage_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/network/__recvmmsg_time64.c
0 → 100644
浏览文件 @
38424281
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <netinet/ip.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/socket.h>
#include <bits/alltypes.h>
#include <unistd.h>
#include "test.h"
extern
int
__recvmmsg_time64
(
int
,
struct
mmsghdr
*
,
unsigned
int
,
unsigned
int
,
struct
timespec
*
);
const
int
SLEEP_TIME
=
2
;
void
sendsss
(
void
)
{
int
sockfd
;
struct
sockaddr_in
addr
;
struct
mmsghdr
msg
[
2
];
struct
iovec
msg1
[
2
],
msg2
;
int
retval
;
sockfd
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
if
(
sockfd
==
-
1
)
{
t_error
(
"recvmmsg_0100 socket error"
);
exit
(
EXIT_FAILURE
);
}
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
addr
.
sin_port
=
htons
(
1234
);
if
(
connect
(
sockfd
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
))
==
-
1
)
{
t_error
(
"recvmmsg_0100 connect error"
);
exit
(
EXIT_FAILURE
);
}
memset
(
msg1
,
0
,
sizeof
(
msg1
));
msg1
[
0
].
iov_base
=
"one"
;
msg1
[
0
].
iov_len
=
3
;
msg1
[
1
].
iov_base
=
"two"
;
msg1
[
1
].
iov_len
=
3
;
memset
(
&
msg2
,
0
,
sizeof
(
msg2
));
msg2
.
iov_base
=
"three"
;
msg2
.
iov_len
=
5
;
memset
(
msg
,
0
,
sizeof
(
msg
));
msg
[
0
].
msg_hdr
.
msg_iov
=
msg1
;
msg
[
0
].
msg_hdr
.
msg_iovlen
=
2
;
msg
[
1
].
msg_hdr
.
msg_iov
=
&
msg2
;
msg
[
1
].
msg_hdr
.
msg_iovlen
=
1
;
retval
=
sendmmsg
(
sockfd
,
msg
,
2
,
0
);
if
(
retval
==
-
1
)
t_error
(
"recvmmsg_0100 sendmmsg error"
);
}
void
recvsss
(
void
)
{
#define VLEN 10
#define BUFSIZE 200
#define TIMEOUT 1
int
sockfd
,
retval
;
struct
sockaddr_in
addr
;
struct
mmsghdr
msgs
[
VLEN
];
struct
iovec
iovecs
[
VLEN
];
char
bufs
[
VLEN
][
BUFSIZE
+
1
];
struct
timespec
timeout
;
sockfd
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
if
(
sockfd
==
-
1
)
{
t_error
(
"recvmmsg_time64_0100 recv socket error"
);
exit
(
EXIT_FAILURE
);
}
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
addr
.
sin_port
=
htons
(
1234
);
if
(
bind
(
sockfd
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
))
==
-
1
)
{
t_error
(
"recvmmsg_time64_0100 recv bind error"
);
exit
(
EXIT_FAILURE
);
}
memset
(
msgs
,
0
,
sizeof
(
msgs
));
for
(
int
i
=
0
;
i
<
VLEN
;
i
++
)
{
iovecs
[
i
].
iov_base
=
bufs
[
i
];
iovecs
[
i
].
iov_len
=
BUFSIZE
;
msgs
[
i
].
msg_hdr
.
msg_iov
=
&
iovecs
[
i
];
msgs
[
i
].
msg_hdr
.
msg_iovlen
=
1
;
}
timeout
.
tv_sec
=
TIMEOUT
;
timeout
.
tv_nsec
=
0
;
retval
=
__recvmmsg_time64
(
sockfd
,
msgs
,
VLEN
,
0
,
&
timeout
);
if
(
retval
==
-
1
)
{
t_error
(
"recvmmsg_time64_0100 recv recvmmsg error"
);
exit
(
EXIT_FAILURE
);
}
}
/**
* @tc.name : recvmmsg_time64_0100
* @tc.desc : Test recvmmsg to recv messages through socket
* @tc.level : Level 0
*/
int
main
(
int
argc
,
char
*
argv
[])
{
pid_t
pid
=
fork
();
if
(
pid
>
0
)
{
recvsss
();
}
else
if
(
pid
==
0
)
{
sleep
(
SLEEP_TIME
);
sendsss
();
}
else
{
t_error
(
"recvmmsg_time64_0100 fork error"
);
}
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/network/test_src_functionalext_supplement_network.gni
浏览文件 @
38424281
...
...
@@ -12,6 +12,7 @@
# limitations under the License.
functionalext_supplement_network_test = [
"__recvmmsg_time64",
"__h_errno_location",
"res_mkquery",
"res_query",
...
...
libc-test/src/functionalext/supplement/sched/sched_rr_get_interval.c
浏览文件 @
38424281
...
...
@@ -18,6 +18,8 @@
#include "test.h"
extern
int
__sched_rr_get_interval_time64
(
pid_t
,
struct
timespec
*
);
/**
* @tc.name : sched_rr_get_interval_0100
* @tc.desc : get the SCHED_RR interval for the named process
...
...
@@ -59,10 +61,33 @@ void sched_rr_get_interval_0200(void)
}
}
/**
* @tc.name : sched_rr_get_interval_time64_0100
* @tc.desc : get the SCHED_RR interval for the named process
* @tc.level : Level 0
*/
void
sched_rr_get_interval_time64_0100
(
void
)
{
pid_t
pid
=
getpid
();
struct
timespec
ts
=
{
0
};
errno
=
0
;
int
result
=
__sched_rr_get_interval_time64
(
pid
,
&
ts
);
if
(
result
!=
0
||
errno
!=
0
)
{
t_error
(
"%s failed: result = %d
\n
"
,
__func__
,
result
);
t_error
(
"%s failed: errno = %d
\n
"
,
__func__
,
errno
);
}
if
(
ts
.
tv_sec
<
0
||
ts
.
tv_nsec
<
0
)
{
t_error
(
"%s failed: ts.tv_sec = %ld
\n
"
,
__func__
,
ts
.
tv_sec
);
t_error
(
"%s failed: ts.tv_nsec = %ld
\n
"
,
__func__
,
ts
.
tv_nsec
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
sched_rr_get_interval_0100
();
sched_rr_get_interval_0200
();
sched_rr_get_interval_time64_0100
();
return
t_status
;
}
libc-test/src/functionalext/supplement/select/pselect.c
浏览文件 @
38424281
...
...
@@ -20,6 +20,10 @@
#include <unistd.h>
#include "functionalext.h"
extern
int
__pselect_time64
(
int
,
fd_set
*
__restrict
,
fd_set
*
__restrict
,
fd_set
*
__restrict
,
const
struct
timespec
*
__restrict
,
const
sigset_t
*
__restrict
);
/**
* @tc.name : pselect_fdset_0100
* @tc.desc : Determine whether the fdset macro is normal
...
...
@@ -105,12 +109,32 @@ void pselect_timeout_0100(void)
}
}
/**
* @tc.name : pselect_time64_normal_0100
* @tc.desc : Monitor stdout file for writability (normal)
* @tc.level : Level 0
*/
void
pselect_time64_normal_0100
(
void
)
{
fd_set
set
;
struct
timespec
timeout
;
timeout
.
tv_sec
=
5
;
timeout
.
tv_nsec
=
0
;
FD_ZERO
(
&
set
);
FD_SET
(
STDOUT_FILENO
,
&
set
);
int
ret
=
__pselect_time64
(
STDOUT_FILENO
+
1
,
NULL
,
&
set
,
NULL
,
&
timeout
,
NULL
);
EXPECT_EQ
(
"pselect_time64_normal_0100"
,
ret
,
1
);
EXPECT_TRUE
(
"pselect_time64_normal_0100"
,
FD_ISSET
(
STDOUT_FILENO
,
&
set
));
}
int
main
(
void
)
{
pselect_fdset_0100
();
pselect_normal_0100
();
pselect_error_0100
();
pselect_timeout_0100
();
pselect_time64_normal_0100
();
return
t_status
;
}
libc-test/src/functionalext/supplement/select/select.c
浏览文件 @
38424281
...
...
@@ -24,6 +24,8 @@
#include <fcntl.h>
#include "functionalext.h"
extern
int
__select_time64
(
int
,
fd_set
*
__restrict
,
fd_set
*
__restrict
,
fd_set
*
__restrict
,
struct
timeval
*
__restrict
);
const
int32_t
COUNT_ZERO
=
0
;
const
int32_t
COUNT_FAILED
=
-
1
;
...
...
@@ -88,10 +90,31 @@ void select_0300(void)
EXPECT_EQ
(
"select_0300"
,
result
,
COUNT_ZERO
);
}
/**
* @tc.name : select_time64_0100
* @tc.desc : Verify that the monitoring descriptor is successful (valid parameters)
* @tc.level : Level 0
*/
void
select_time64_0100
(
void
)
{
struct
timeval
timeout
;
timeout
.
tv_sec
=
5
;
timeout
.
tv_usec
=
0
;
fd_set
readfds
,
writefds
;
FD_ZERO
(
&
readfds
);
FD_ZERO
(
&
writefds
);
FD_SET
(
0
,
&
readfds
);
FD_SET
(
1
,
&
writefds
);
int
result
;
result
=
__select_time64
(
2
,
&
readfds
,
&
writefds
,
0
,
&
timeout
);
EXPECT_TRUE
(
"select_time64_0100"
,
result
>
0
);
}
int
main
(
void
)
{
select_0100
();
select_0200
();
select_0300
();
select_time64_0100
();
return
t_status
;
}
libc-test/src/functionalext/supplement/signal/__getitimer_time64.c
0 → 100644
浏览文件 @
38424281
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <signal.h>
#include <sys/time.h>
#include "functionalext.h"
extern
int
__getitimer_time64
(
int
,
struct
itimerval
*
);
static
int
count
=
0
;
void
expireTimer
(
int
signo
)
{
struct
itimerval
val
;
count
++
;
if
(
count
>
1
)
{
__getitimer_time64
(
signo
,
&
val
);
val
.
it_value
.
tv_sec
=
0
;
val
.
it_value
.
tv_usec
=
0
;
setitimer
(
signo
,
&
val
,
NULL
);
count
=
0
;
}
}
void
signalHandler
(
int
signo
)
{
switch
(
signo
)
{
case
SIGALRM
:
printf
(
"catch a SIGALRM signal
\n
"
);
expireTimer
(
signo
);
break
;
case
SIGVTALRM
:
printf
(
"catch a SIGVTALRM signal
\n
"
);
break
;
case
SIGPROF
:
printf
(
"catch a SIGPROF signal
\n
"
);
break
;
default:
printf
(
"no signal
\n
"
);
break
;
}
}
/**
* @tc.name : getitimer_0100
* @tc.desc : Verify the value of the interval timer (parameter is ITIMER_REAL)
* @tc.level : Level 0
*/
void
getitimer_time64_0100
(
void
)
{
signal
(
SIGALRM
,
signalHandler
);
struct
itimerval
old
;
int
result
=
__getitimer_time64
(
ITIMER_REAL
,
&
old
);
EXPECT_EQ
(
"getitimer_time64_0100"
,
result
,
0
);
}
int
main
(
void
)
{
getitimer_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/signal/__setitimer_time64.c
0 → 100644
浏览文件 @
38424281
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include "test.h"
extern
int
__setitimer_time64
(
int
,
const
struct
itimerval
*
__restrict
,
struct
itimerval
*
__restrict
);
static
int
count
=
0
;
void
expireTimer
(
int
signo
)
{
struct
itimerval
val
;
count
++
;
if
(
count
>
1
)
{
getitimer
(
signo
,
&
val
);
val
.
it_value
.
tv_sec
=
0
;
val
.
it_value
.
tv_usec
=
0
;
__setitimer_time64
(
signo
,
&
val
,
NULL
);
count
=
0
;
}
}
void
signalHandler
(
int
signo
)
{
switch
(
signo
)
{
case
SIGALRM
:
printf
(
"catch a SIGALRM signal
\n
"
);
expireTimer
(
signo
);
break
;
case
SIGVTALRM
:
printf
(
"catch a SIGVTALRM signal
\n
"
);
break
;
case
SIGPROF
:
printf
(
"catch a SIGPROF signal
\n
"
);
break
;
default:
printf
(
"no signal
\n
"
);
break
;
}
}
/**
* @tc.name : setitimer_time64_0100
* @tc.desc : Set value of an interval timer
* @tc.level : Level 0
*/
void
setitimer_time64_0100
(
void
)
{
signal
(
SIGALRM
,
signalHandler
);
struct
itimerval
it
;
memset
(
&
it
,
0
,
sizeof
(
it
));
it
.
it_value
.
tv_sec
=
0
;
it
.
it_value
.
tv_usec
=
100000
;
it
.
it_interval
.
tv_sec
=
0
;
it
.
it_interval
.
tv_usec
=
100000
;
if
(
__setitimer_time64
(
ITIMER_REAL
,
&
it
,
NULL
))
{
t_error
(
"%s set timer failed"
,
__func__
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
setitimer_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/signal/test_src_functionalext_supplement_signal.gni
浏览文件 @
38424281
...
...
@@ -32,4 +32,6 @@ functionalext_supplement_signal_test = [
"__libc_current_sigrtmax",
"__libc_current_sigrtmin",
"getitimer",
"__getitimer_time64",
"__setitimer_time64",
]
libc-test/src/functionalext/supplement/stat/fstatat.c
浏览文件 @
38424281
...
...
@@ -20,6 +20,8 @@
const
int
SUCCESS
=
0
;
extern
int
__fstatat_time64
(
int
,
const
char
*
__restrict
,
struct
stat
*
__restrict
,
int
);
/**
* @tc.name : fstatat_0100
* @tc.desc : The parameter fd is equal to AT_FDCWD, the flag is 0,
...
...
@@ -98,10 +100,35 @@ void fstatat_0300(void)
ptr
=
NULL
;
}
/**
* @tc.name : fstatat_time64_0100
* @tc.desc : The parameter fd is equal to AT_FDCWD, the flag is 0,
* and the information of the file can be obtained.
* @tc.level : Level 0
*/
void
fstatat_time64_0100
(
void
)
{
const
char
*
ptr
=
"fstatat_time64_test.txt"
;
struct
stat
st
;
int
fd
=
open
(
ptr
,
O_RDWR
|
O_CREAT
);
EXPECT_TRUE
(
"fstatat_0100"
,
fd
>=
0
);
lseek
(
fd
,
0
,
SEEK_SET
);
int
ret
=
__fstatat_time64
(
AT_FDCWD
,
ptr
,
&
st
,
0
);
EXPECT_EQ
(
"fstatat_0100"
,
ret
,
SUCCESS
);
uid_t
uid
=
getuid
();
EXPECT_EQ
(
"fstatat_0100"
,
st
.
st_uid
,
uid
);
gid_t
gid
=
getgid
();
EXPECT_EQ
(
"fstatat_0100"
,
st
.
st_gid
,
gid
);
close
(
fd
);
remove
(
ptr
);
ptr
=
NULL
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
fstatat_0100
();
fstatat_0200
();
fstatat_0300
();
fstatat_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/stat/futimesat.c
浏览文件 @
38424281
...
...
@@ -20,6 +20,8 @@
const
char
*
path
=
"/data"
;
extern
int
__futimesat_time64
(
int
,
const
char
*
,
const
struct
timeval
[
2
]);
/**
* @tc.name : futimesat_0100
* @tc.desc : Change timestamps of a file relative to a directory file descriptor
...
...
@@ -127,11 +129,41 @@ void futimesat_0400(void)
}
}
/**
* @tc.name : futimesat_time64_0200
* @tc.desc : Test the return value of the function when timeval is NULL
* @tc.level : Level 1
*/
void
futimesat_time64_0200
(
void
)
{
int
dir_fd
=
open
(
path
,
O_RDONLY
|
O_DIRECTORY
);
if
(
dir_fd
<
0
)
{
t_error
(
"%s open failed
\n
"
,
__func__
);
}
int
fd
=
openat
(
dir_fd
,
"test.txt"
,
O_CREAT
|
O_RDWR
|
O_EXCL
,
0666
);
if
(
fd
<
0
)
{
t_error
(
"%s openat failed
\n
"
,
__func__
);
}
int
result
=
__futimesat_time64
(
dir_fd
,
"test.txt"
,
NULL
);
if
(
result
!=
0
)
{
t_error
(
"%s __futimesat_time64 failed
\n
"
,
__func__
);
}
if
(
unlinkat
(
dir_fd
,
"test.txt"
,
0
)
!=
0
)
{
t_error
(
"%s unlinkat failed
\n
"
,
__func__
);
}
close
(
dir_fd
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
futimesat_0100
();
futimesat_0200
();
futimesat_0300
();
futimesat_0400
();
futimesat_time64_0200
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/stat/lstat.c
浏览文件 @
38424281
...
...
@@ -19,6 +19,8 @@
#include <stdlib.h>
#include "functionalext.h"
extern
int
__lstat_time64
(
const
char
*
__restrict
,
struct
stat
*
__restrict
);
typedef
void
(
*
TEST_FUN
)();
/*
...
...
@@ -41,6 +43,26 @@ void lstat_0100(void)
remove
(
ptr
);
}
/*
* @tc.name : lstat_time64_0100
* @tc.desc : Verify that the parameters are valid, get the file status successfully
* @tc.level : Level 0
*/
void
lstat_time64_0100
(
void
)
{
const
char
*
ptr
=
"/data/tests/libc-test/src/functionalext/supplement/stattest.txt"
;
const
char
str
[]
=
"this is a sample!"
;
FILE
*
fptr
=
fopen
(
ptr
,
"w+"
);
struct
stat
statbuff
;
fwrite
(
str
,
sizeof
(
char
),
strlen
(
str
),
fptr
);
fseek
(
fptr
,
0L
,
SEEK_SET
);
int32_t
back
=
__lstat_time64
(
ptr
,
&
statbuff
);
EXPECT_EQ
(
"lstat_0100"
,
back
,
0
);
EXPECT_EQ
(
"lstat_0100"
,
statbuff
.
st_size
,
17
);
fclose
(
fptr
);
remove
(
ptr
);
}
/*
* @tc.name : lstat_0200
* @tc.desc : Validation failed to get file status (parameter invalid file does not exist)
...
...
@@ -86,7 +108,7 @@ TEST_FUN G_Fun_Array[] = {
lstat_0100
,
lstat_0200
,
lstat_0300
,
lstat_time64_0100
,
};
int
main
(
int
argc
,
char
*
argv
[])
...
...
libc-test/src/functionalext/supplement/stat/utimensat.c
浏览文件 @
38424281
...
...
@@ -23,6 +23,8 @@
const
char
*
path
=
"/data/tests/libc-test/src/file.txt"
;
const
long
sec
=
123840
;
extern
int
__utimensat_time64
(
int
,
const
char
*
,
const
struct
timespec
[
2
],
int
);
/**
* @tc.name : utimensat_0100
* @tc.desc : change file timestamps with nanosecond precision
...
...
@@ -71,10 +73,41 @@ void utimensat_0200(void)
}
}
/**
* @tc.name : utimensat_time64_0100
* @tc.desc : change file timestamps with nanosecond precision
* @tc.level : Level 0
*/
void
utimensat_time64_0100
(
void
)
{
int
fd
=
open
(
path
,
O_RDWR
|
O_CREAT
);
struct
timespec
times
[]
=
{{.
tv_sec
=
0
},
{.
tv_sec
=
sec
}};
int
result
=
__utimensat_time64
(
fd
,
path
,
times
,
0
);
if
(
result
!=
0
)
{
t_error
(
"%s failed: result = %d
\n
"
,
__func__
,
result
);
}
close
(
fd
);
struct
stat
statbuf
;
result
=
stat
(
path
,
&
statbuf
);
if
(
result
!=
0
)
{
t_error
(
"%s failed: result = %d
\n
"
,
__func__
,
result
);
}
if
(
statbuf
.
st_mtim
.
tv_sec
!=
sec
)
{
t_error
(
"%s failed: statbuf.st_mtim.tv_sec = %ld
\n
"
,
__func__
,
statbuf
.
st_mtim
.
tv_sec
);
}
remove
(
path
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
utimensat_0100
();
utimensat_0200
();
utimensat_time64_0100
();
return
t_status
;
}
libc-test/src/functionalext/supplement/thread/cnd_timedwait.c
浏览文件 @
38424281
...
...
@@ -20,6 +20,8 @@
static
cnd_t
cond
;
static
mtx_t
mutex
;
extern
int
__cnd_timedwait_time64
(
cnd_t
*
__restrict
,
mtx_t
*
__restrict
,
const
struct
timespec
*
__restrict
);
static
int
signal_parent
(
void
*
arg
)
{
if
(
mtx_lock
(
&
mutex
)
!=
thrd_success
)
{
...
...
@@ -79,8 +81,53 @@ void cnd_timedwait_0100(void)
cnd_destroy
(
&
cond
);
}
/**
* @tc.name : cnd_timedwait_time64_0100
* @tc.desc : The parameter is valid and can block the calling thread and release the specified mutex.
* @tc.level : Level 0
*/
void
cnd_timedwait_time64_0100
(
void
)
{
thrd_t
id
;
struct
timespec
w_time
;
if
(
cnd_init
(
&
cond
)
!=
thrd_success
)
{
t_error
(
"%s cnd_init failed
\n
"
,
__func__
);
}
if
(
mtx_init
(
&
mutex
,
mtx_plain
)
!=
thrd_success
)
{
t_error
(
"%s mtx_init failed
\n
"
,
__func__
);
}
if
(
mtx_lock
(
&
mutex
)
!=
thrd_success
)
{
t_error
(
"%s mtx_lock failed
\n
"
,
__func__
);
}
if
(
clock_gettime
(
CLOCK_REALTIME
,
&
w_time
)
!=
0
)
{
t_error
(
"%s clock_gettime failed
\n
"
,
__func__
);
}
w_time
.
tv_sec
+=
3600
;
if
(
thrd_create
(
&
id
,
signal_parent
,
NULL
)
!=
thrd_success
)
{
t_error
(
"%s thrd_create failed
\n
"
,
__func__
);
}
if
(
__cnd_timedwait_time64
(
&
cond
,
&
mutex
,
&
w_time
)
!=
thrd_success
)
{
t_error
(
"%s cnd_timedwait failed
\n
"
,
__func__
);
}
if
(
thrd_join
(
id
,
NULL
)
!=
thrd_success
)
{
t_error
(
"%s thrd_join failed
\n
"
,
__func__
);
}
if
(
mtx_unlock
(
&
mutex
)
!=
thrd_success
)
{
t_error
(
"%s mtx_unlock failed
\n
"
,
__func__
);
}
mtx_destroy
(
&
mutex
);
cnd_destroy
(
&
cond
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
cnd_timedwait_0100
();
cnd_timedwait_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/thread/mtx_timedlock.c
浏览文件 @
38424281
...
...
@@ -20,6 +20,8 @@
const
int
TWO
=
2
;
extern
int
__mtx_timedlock_time64
(
mtx_t
*
__restrict
,
const
struct
timespec
*
__restrict
);
/**
* @tc.name : mtx_timedlock_0100
* @tc.desc : Provide correct parameters, test timeout and lock
...
...
@@ -79,9 +81,37 @@ void mtx_timedlock_0200(void)
mtx_destroy
(
&
mutex
);
}
/**
* @tc.name : mtx_timedlock_time64_0100
* @tc.desc : Provide correct parameters, test timeout and lock
* @tc.level : Level 0
*/
void
mtx_timedlock_time64_0100
(
void
)
{
struct
timespec
timeout
;
timeout
.
tv_sec
=
TWO
;
timeout
.
tv_nsec
=
0
;
mtx_t
mutex
;
int
ret
=
0
;
ret
=
mtx_init
(
&
mutex
,
mtx_timed
);
if
(
ret
!=
thrd_success
)
{
t_error
(
"%s mtx_init failed"
,
__func__
);
return
;
}
ret
=
__mtx_timedlock_time64
(
&
mutex
,
&
timeout
);
EXPECT_EQ
(
"mtx_timedlock_time64_0100"
,
ret
,
thrd_success
);
ret
=
mtx_unlock
(
&
mutex
);
if
(
ret
!=
thrd_success
)
{
t_error
(
"%s mtx_unlock failed"
,
__func__
);
return
;
}
mtx_destroy
(
&
mutex
);
}
int
main
(
void
)
{
mtx_timedlock_0100
();
mtx_timedlock_0200
();
mtx_timedlock_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/thread/pthread_mutex_timedlock.c
浏览文件 @
38424281
...
...
@@ -19,6 +19,8 @@
#define TEST_MUTEX_ATTR 15
extern
int
__pthread_mutex_timedlock_time64
(
pthread_mutex_t
*
__restrict
,
const
struct
timespec
*
__restrict
);
/**
* @tc.name : pthread_mutex_timedlock_0100
* @tc.desc : Provide correct parameters, test timeout and lock
...
...
@@ -86,10 +88,33 @@ void pthread_mutex_timedlock_0300(void)
pthread_mutexattr_destroy
(
&
mutex_attr
);
}
/**
* @tc.name : pthread_mutex_timedlock_time64_0100
* @tc.desc : Provide correct parameters, test timeout and lock
* @tc.level : Level 0
*/
void
pthread_mutex_timedlock_time64_0100
(
void
)
{
struct
timespec
ts
=
{.
tv_nsec
=
0
,
.
tv_sec
=
1
};
pthread_mutexattr_t
mutex_attr
;
pthread_mutex_t
mutex
;
pthread_mutexattr_init
(
&
mutex_attr
);
pthread_mutexattr_settype
(
&
mutex_attr
,
TEST_MUTEX_ATTR
);
pthread_mutex_init
(
&
mutex
,
&
mutex_attr
);
int
rev
=
__pthread_mutex_timedlock_time64
(
&
mutex
,
&
ts
);
EXPECT_EQ
(
"pthread_mutex_timedlock_time64_0100"
,
rev
,
0
);
pthread_mutex_unlock
(
&
mutex
);
pthread_mutex_destroy
(
&
mutex
);
pthread_mutexattr_destroy
(
&
mutex_attr
);
}
int
main
(
void
)
{
pthread_mutex_timedlock_0100
();
pthread_mutex_timedlock_0200
();
pthread_mutex_timedlock_0300
();
pthread_mutex_timedlock_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/thread/pthread_rwlock_timedrdlock.c
浏览文件 @
38424281
...
...
@@ -17,6 +17,8 @@
#include <stdlib.h>
#include "functionalext.h"
extern
int
__pthread_rwlock_timedrdlock_time64
(
pthread_rwlock_t
*
__restrict
,
const
struct
timespec
*
__restrict
);
/**
* @tc.name : pthread_rwlock_timedrdlock_0100
* @tc.desc : Provide correct parameters, test timeout and rwlock
...
...
@@ -89,10 +91,35 @@ void pthread_rwlock_timedrdlock_0300(void)
pthread_rwlock_destroy
(
&
rwlock
);
}
/**
* @tc.name : pthread_rwlock_timedrdlock_time64_0100
* @tc.desc : Provide correct parameters, test timeout and rwlock
* @tc.level : Level 0
*/
void
pthread_rwlock_timedrdlock_time64_0100
(
void
)
{
struct
timespec
ts
=
{.
tv_nsec
=
0
,
.
tv_sec
=
0
};
pthread_rwlock_t
rwlock
;
pthread_rwlock_init
(
&
rwlock
,
NULL
);
clock_gettime
(
CLOCK_REALTIME
,
&
ts
);
struct
tm
*
tmp
=
localtime
(
&
ts
.
tv_sec
);
int
rev
=
-
1
;
if
(
tmp
)
{
ts
.
tv_sec
+=
1
;
rev
=
__pthread_rwlock_timedrdlock_time64
(
&
rwlock
,
&
ts
);
}
EXPECT_EQ
(
"pthread_rwlock_timedrdlock_time64_0100"
,
rev
,
0
);
if
(
rev
==
0
)
{
pthread_rwlock_unlock
(
&
rwlock
);
}
pthread_rwlock_destroy
(
&
rwlock
);
}
int
main
(
void
)
{
pthread_rwlock_timedrdlock_0100
();
pthread_rwlock_timedrdlock_0200
();
pthread_rwlock_timedrdlock_0300
();
pthread_rwlock_timedrdlock_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/thread/pthread_rwlock_timedwrlock.c
浏览文件 @
38424281
...
...
@@ -17,6 +17,8 @@
#include <stdlib.h>
#include "functionalext.h"
extern
int
__pthread_rwlock_timedwrlock_time64
(
pthread_rwlock_t
*
__restrict
,
const
struct
timespec
*
__restrict
);
/**
* @tc.name : pthread_rwlock_timedwrlock_0100
* @tc.desc : Provide correct parameters, test timeout and rwlock
...
...
@@ -89,10 +91,35 @@ void pthread_rwlock_timedwrlock_0300(void)
pthread_rwlock_destroy
(
&
rwlock
);
}
/**
* @tc.name : pthread_rwlock_timedwrlock_time64_0100
* @tc.desc : Provide correct parameters, test timeout and rwlock
* @tc.level : Level 0
*/
void
pthread_rwlock_timedwrlock_time64_0100
(
void
)
{
struct
timespec
ts
=
{.
tv_nsec
=
0
,
.
tv_sec
=
0
};
pthread_rwlock_t
rwlock
;
pthread_rwlock_init
(
&
rwlock
,
NULL
);
clock_gettime
(
CLOCK_REALTIME
,
&
ts
);
struct
tm
*
tmp
=
localtime
(
&
ts
.
tv_sec
);
int
rev
=
-
1
;
if
(
tmp
)
{
ts
.
tv_sec
+=
1
;
rev
=
__pthread_rwlock_timedwrlock_time64
(
&
rwlock
,
&
ts
);
}
EXPECT_EQ
(
"pthread_rwlock_timedwrlock_time64_0100"
,
rev
,
0
);
if
(
rev
==
0
)
{
pthread_rwlock_unlock
(
&
rwlock
);
}
pthread_rwlock_destroy
(
&
rwlock
);
}
int
main
(
void
)
{
pthread_rwlock_timedwrlock_0100
();
pthread_rwlock_timedwrlock_0200
();
pthread_rwlock_timedwrlock_0300
();
pthread_rwlock_timedwrlock_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/thread/thrd_sleep.c
浏览文件 @
38424281
...
...
@@ -18,6 +18,8 @@
#include <threads.h>
#include "test.h"
extern
int
__thrd_sleep_time64
(
const
struct
timespec
*
,
struct
timespec
*
);
static
int
count
=
0
;
void
exception_handler
(
int
sig
)
...
...
@@ -89,10 +91,24 @@ void thrd_sleep_0300(void)
thrd_sleep
(
NULL
,
NULL
);
}
/**
* @tc.name : thrd_sleep_time64_0200
* @tc.desc : Negative value
* @tc.level : Level 1
*/
void
thrd_sleep_time64_0200
(
void
)
{
int
result
=
__thrd_sleep_time64
(
&
(
struct
timespec
){.
tv_sec
=
-
1
},
NULL
);
if
(
result
!=
-
2
)
{
t_error
(
"%s negative value"
,
__func__
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
thrd_sleep_0100
();
thrd_sleep_0200
();
thrd_sleep_0300
();
thrd_sleep_time64_0200
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/time/clock_getres.c
浏览文件 @
38424281
...
...
@@ -16,6 +16,8 @@
#include <time.h>
#include "functionalext.h"
extern
int
__clock_getres_time64
(
clockid_t
,
struct
timespec
*
);
/**
* @tc.name : clock_getres_0100
* @tc.desc : Verify that the resolution in the specified poem can be found (the parameter is CLOCK_REALTIME)
...
...
@@ -76,6 +78,18 @@ void clock_getres_0500(void)
EXPECT_EQ
(
"clock_getres_0500"
,
result
,
-
1
);
}
/**
* @tc.name : clock_getres_time64_0100
* @tc.desc : Verify that the resolution in the specified poem can be found (the parameter is CLOCK_REALTIME)
* @tc.level : Level 0
*/
void
clock_getres_time64_0100
(
void
)
{
struct
timespec
ts
;
int
result
=
__clock_getres_time64
(
CLOCK_REALTIME
,
&
ts
);
EXPECT_EQ
(
"clock_getres_time64_0100"
,
result
,
0
);
}
int
main
(
void
)
{
clock_getres_0100
();
...
...
@@ -83,5 +97,6 @@ int main(void)
clock_getres_0300
();
clock_getres_0400
();
clock_getres_0500
();
clock_getres_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/time/clock_nanosleep.c
浏览文件 @
38424281
...
...
@@ -19,6 +19,8 @@
const
int
SUCCESS
=
0
;
extern
int
__clock_nanosleep_time64
(
clockid_t
,
int
,
const
struct
timespec
*
,
struct
timespec
*
);
/**
* @tc.name : clock_nanosleep_0100
* @tc.desc : Each parameter is valid, clk is CLOCK_REALTIME, which can specify the sleep of the clock.
...
...
@@ -111,6 +113,21 @@ void clock_nanosleep_0600(void)
EXPECT_EQ
(
"clock_nanosleep_0600"
,
ret
,
EINVAL
);
}
/**
* @tc.name : clock_nanosleep_time64_0100
* @tc.desc : Each parameter is valid, clk is CLOCK_REALTIME, which can specify the sleep of the clock.
* @tc.level : Level 0
*/
void
clock_nanosleep_time64_0100
(
void
)
{
struct
timespec
ts
;
ts
.
tv_sec
=
ts
.
tv_nsec
/
1000000000
;
ts
.
tv_nsec
=
200000000
;
int
ret
=
-
1
;
ret
=
__clock_nanosleep_time64
(
CLOCK_REALTIME
,
TIMER_ABSTIME
,
&
ts
,
NULL
);
EXPECT_EQ
(
"clock_nanosleep_time64_0100"
,
ret
,
SUCCESS
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
clock_nanosleep_0100
();
...
...
@@ -119,5 +136,6 @@ int main(int argc, char *argv[])
clock_nanosleep_0400
();
clock_nanosleep_0500
();
clock_nanosleep_0600
();
clock_nanosleep_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/time/clock_settime.c
浏览文件 @
38424281
...
...
@@ -17,6 +17,8 @@
#include <unistd.h>
#include "functionalext.h"
extern
int
__clock_settime64
(
clockid_t
,
const
struct
timespec
*
);
/**
* @tc.name : clock_settime_0100
* @tc.desc : Each parameter is valid, the clk parameter is CLOCK_REALTIME, which can set the system
...
...
@@ -40,8 +42,32 @@ void clock_settime_0100(void)
EXPECT_EQ
(
"clock_settime_0100"
,
ret
,
0
);
}
/**
* @tc.name : clock_settime64_0100
* @tc.desc : Each parameter is valid, the clk parameter is CLOCK_REALTIME, which can set the system
* time seconds and nanoseconds.
* @tc.level : Level 0
*/
void
clock_settime64_0100
(
void
)
{
struct
timespec
ts
;
struct
tm
tim
=
{
.
tm_year
=
2022
-
1900
,
.
tm_min
=
16
,
.
tm_hour
=
18
,
.
tm_mon
=
6
,
.
tm_mday
=
6
,
};
ts
.
tv_sec
=
mktime
(
&
tim
);
ts
.
tv_nsec
=
0
;
int
ret
=
-
1
;
ret
=
__clock_settime64
(
CLOCK_REALTIME
,
&
ts
);
EXPECT_EQ
(
"clock_settime64_0100"
,
ret
,
0
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
clock_settime_0100
();
clock_settime64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/time/gettimeofday.c
浏览文件 @
38424281
...
...
@@ -21,6 +21,8 @@
const
int
SUCCESS
=
0
;
extern
int
__gettimeofday_time64
(
struct
timeval
*
__restrict
,
void
*
__restrict
);
/**
* @tc.name : gettimeofday_0100
* @tc.desc : Each parameter is valid, and the current system time can be obtained.
...
...
@@ -52,10 +54,30 @@ void gettimeofday_0200(void)
EXPECT_EQ
(
"gettimeofday_0200"
,
returnflag
,
SUCCESS
);
}
/**
* @tc.name : gettimeofday_time64_0100
* @tc.desc : Each parameter is valid, and the current system time can be obtained.
* @tc.level : Level 0
*/
void
gettimeofday_time64_0100
(
void
)
{
struct
timeval
tv
;
char
str
[
10
];
system
(
"date +%s > ./time.txt"
);
FILE
*
fptr
=
fopen
(
"time.txt"
,
"r"
);
fflush
(
fptr
);
fread
(
str
,
sizeof
(
str
),
1
,
fptr
);
int
sec
=
atoi
(
str
);
int
returnflag
=
__gettimeofday_time64
(
&
tv
,
NULL
);
EXPECT_EQ
(
"gettimeofday_time64_0100"
,
returnflag
,
SUCCESS
);
EXPECT_EQ
(
"gettimeofday_time64_0100"
,
(
long
)
sec
,
(
long
)
tv
.
tv_sec
);
remove
(
"time.txt"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
gettimeofday_0100
();
gettimeofday_0200
();
gettimeofday_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/time/gmtime_r_sup.c
浏览文件 @
38424281
...
...
@@ -17,6 +17,8 @@
#include <time.h>
#include "functionalext.h"
struct
tm
*
__gmtime64_r
(
const
time_t
*
__restrict
,
struct
tm
*
__restrict
);
struct
gmtime_r_struct
{
const
char
*
tz
;
const
char
*
result
;
...
...
@@ -509,8 +511,52 @@ void gmtime_r_0100(void)
}
}
/**
* @tc.name : gmtime64_r_0100
* @tc.desc : according to different time zones, convert date and time to GMT time
* @tc.level : Level 0
*/
void
gmtime64_r_0100
(
void
)
{
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)(
sizeof
(
gResultData
)
/
sizeof
(
gResultData
[
0
]));
i
++
)
{
const
char
*
tz
=
gResultData
[
i
].
tz
;
const
char
*
handlerChar
;
#ifdef TIME_ZONE_SUB_TAG
char
*
str
=
strrchr
(
tz
,
TIME_ZONE_SUB_TAG
);
if
(
str
)
{
handlerChar
=
++
str
;
}
else
{
handlerChar
=
tz
;
}
#else
handlerChar
=
tz
;
#endif
setenv
(
"TZ"
,
handlerChar
,
1
);
tzset
();
struct
tm
res
=
{
0
};
struct
tm
*
gmtm
=
__gmtime64_r
(
&
gTime
,
&
res
);
char
buff
[
gBufferSize
];
int
cnt
=
sprintf
(
buff
,
"%d-%d-%d %d:%d:%d wday=%d,yday=%d,isdst=%d,gmtoff=%ld,zone=%s"
,
(
gmtm
->
tm_year
+
gYearBase
),
gmtm
->
tm_mon
,
gmtm
->
tm_mday
,
gmtm
->
tm_hour
,
gmtm
->
tm_min
,
gmtm
->
tm_sec
,
gmtm
->
tm_wday
,
gmtm
->
tm_yday
,
gmtm
->
tm_isdst
,
gmtm
->
tm_gmtoff
,
gmtm
->
tm_zone
);
EXPECT_TRUE
(
"gmtime64_r_0100"
,
cnt
>
0
);
EXPECT_STREQ
(
"gmtime64_r_0100"
,
gResultData
[
i
].
result
,
buff
);
}
}
int
main
(
void
)
{
gmtime_r_0100
();
gmtime64_r_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/time/gmtime_sup.c
浏览文件 @
38424281
...
...
@@ -17,6 +17,8 @@
#include <time.h>
#include "functionalext.h"
struct
tm
*
__gmtime64
(
const
time_t
*
);
struct
gmtime_struct
{
const
char
*
tz
;
const
char
*
result
;
...
...
@@ -509,8 +511,52 @@ void gmtime_0100(void)
}
}
/**
* @tc.name : gmtime64_0100
* @tc.desc : according to different time zones, convert date and time to GMT time
* @tc.level : Level 0
*/
void
gmtime64_0100
(
void
)
{
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)(
sizeof
(
gResultData
)
/
sizeof
(
gResultData
[
0
]));
i
++
)
{
const
char
*
tz
=
gResultData
[
i
].
tz
;
const
char
*
handlerChar
;
#ifdef TIME_ZONE_SUB_TAG
char
*
str
=
strrchr
(
tz
,
TIME_ZONE_SUB_TAG
);
if
(
str
)
{
handlerChar
=
++
str
;
}
else
{
handlerChar
=
tz
;
}
#else
handlerChar
=
tz
;
#endif
setenv
(
"TZ"
,
handlerChar
,
1
);
tzset
();
struct
tm
*
gmtm
;
gmtm
=
__gmtime64
(
&
gTime
);
char
buff
[
gBufferSize
];
int
cnt
=
sprintf
(
buff
,
"%d-%d-%d %d:%d:%d wday=%d,yday=%d,isdst=%d,gmtoff=%ld,zone=%s"
,
(
gmtm
->
tm_year
+
gYearBase
),
gmtm
->
tm_mon
,
gmtm
->
tm_mday
,
gmtm
->
tm_hour
,
gmtm
->
tm_min
,
gmtm
->
tm_sec
,
gmtm
->
tm_wday
,
gmtm
->
tm_yday
,
gmtm
->
tm_isdst
,
gmtm
->
tm_gmtoff
,
gmtm
->
tm_zone
);
EXPECT_TRUE
(
"gmtime64_0100"
,
cnt
>
0
);
EXPECT_STREQ
(
"gmtime64_0100"
,
gResultData
[
i
].
result
,
buff
);
}
}
int
main
(
void
)
{
gmtime_0100
();
gmtime64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/time/nanosleep.c
浏览文件 @
38424281
...
...
@@ -16,6 +16,8 @@
#include <time.h>
#include "functionalext.h"
extern
int
__nanosleep_time64
(
const
struct
timespec
*
,
struct
timespec
*
);
/*
* @tc.name : nanosleep_0100
* @tc.desc : Verify that the execution of the program can be paused
...
...
@@ -30,8 +32,23 @@ void nanosleep_0100(void)
EXPECT_EQ
(
"nanosleep_0100"
,
data
,
0
);
}
/*
* @tc.name : nanosleep_time64_0100
* @tc.desc : Verify that the execution of the program can be paused with time64
* @tc.level : Level 0
*/
void
nanosleep_time64_0100
(
void
)
{
struct
timespec
n_sleep
;
n_sleep
.
tv_sec
=
0
;
n_sleep
.
tv_nsec
=
5e8L
;
int
data
=
__nanosleep_time64
(
&
n_sleep
,
NULL
);
EXPECT_EQ
(
"nanosleep_time64_0100"
,
data
,
0
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
nanosleep_0100
();
nanosleep_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/time/timer_gettime.c
浏览文件 @
38424281
...
...
@@ -23,6 +23,8 @@
#define Nanoseconds (1000000000)
static
int
count
=
0
;
extern
int
__timer_gettime64
(
timer_t
,
struct
itimerspec
*
);
void
timerHandler
(
int
sig
)
{
count
++
;
...
...
@@ -96,9 +98,23 @@ void timer_gettime_0200(void)
}
}
/**
* @tc.name : timer_gettime64_0200
* @tc.desc : The return value of the function when the parameter is abnormal
* @tc.level : Level 2
*/
void
timer_gettime64_0200
(
void
)
{
int
result
=
__timer_gettime64
(
NULL
,
NULL
);
if
(
result
!=
-
1
&&
errno
!=
EINVAL
)
{
t_error
(
"%s failed result = %d"
,
__func__
,
result
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
timer_gettime_0100
();
timer_gettime_0200
();
timer_gettime64_0200
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/time/timer_settime.c
浏览文件 @
38424281
...
...
@@ -23,6 +23,8 @@
static
int
count
=
0
;
extern
int
__timer_settime64
(
timer_t
,
int
,
const
struct
itimerspec
*
__restrict
,
struct
itimerspec
*
__restrict
);
void
handler
(
int
sig
)
{
count
++
;
...
...
@@ -89,10 +91,53 @@ void timer_settime_0200(void)
timer_settime
(
NULL
,
0
,
NULL
,
NULL
);
}
/**
* @tc.name : timer_settime64_0100
* @tc.desc : arms the timer
* @tc.level : Level 0
*/
void
timer_settime64_0100
(
void
)
{
struct
sigevent
sev
;
timer_t
timerid
;
sev
.
sigev_notify
=
SIGEV_SIGNAL
;
sev
.
sigev_signo
=
SIGRTMIN
;
sev
.
sigev_value
.
sival_ptr
=
&
timerid
;
signal
(
SIGRTMIN
,
handler
);
int
result
=
timer_create
(
CLOCK_REALTIME
,
&
sev
,
&
timerid
);
if
(
result
!=
0
)
{
t_error
(
"%s failed: result = %d
\n
"
,
__func__
,
result
);
}
struct
itimerspec
its
;
its
.
it_value
.
tv_sec
=
1
;
its
.
it_value
.
tv_nsec
=
0
;
its
.
it_interval
.
tv_sec
=
0
;
its
.
it_interval
.
tv_nsec
=
0
;
result
=
__timer_settime64
(
timerid
,
0
,
&
its
,
NULL
);
if
(
result
!=
0
)
{
t_error
(
"%s failed: result = %d
\n
"
,
__func__
,
result
);
}
while
(
count
<=
0
)
{
sleep
(
1
);
}
result
=
timer_delete
(
timerid
);
if
(
result
!=
0
)
{
t_error
(
"%s failed: result = %d
\n
"
,
__func__
,
result
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
timer_settime_0100
();
timer_settime_0200
();
timer_settime64_0100
();
return
t_status
;
}
libc-test/src/functionalext/supplement/time/timespec_get.c
浏览文件 @
38424281
...
...
@@ -19,6 +19,8 @@
#define NANOSECOND (1000000000)
extern
int
__timespec_get_time64
(
struct
timespec
*
,
int
);
/**
* @tc.name : timespec_get_0100
* @tc.desc : Base is not TIME_UTC
...
...
@@ -50,9 +52,27 @@ void timespec_get_0200(void)
}
}
/**
* @tc.name : timespec_get_time64_0200
* @tc.desc : Base is TIME_UTC
* @tc.level : Level 1
*/
void
timespec_get_time64_0200
(
void
)
{
struct
timespec
ts
;
int
result
=
__timespec_get_time64
(
&
ts
,
TIME_UTC
);
if
(
result
!=
TIME_UTC
)
{
t_error
(
"%s __timespec_get_time64 failed, result is %d"
,
__func__
,
result
);
}
if
(
ts
.
tv_nsec
<
0
||
ts
.
tv_nsec
>=
NANOSECOND
)
{
t_error
(
"%s ts invalid"
,
__func__
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
timespec_get_0100
();
timespec_get_0200
();
timespec_get_time64_0200
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/supplement/time/utime_sup.c
浏览文件 @
38424281
...
...
@@ -20,6 +20,8 @@
#include <utime.h>
#include "test.h"
extern
int
__utime64
(
const
char
*
,
const
struct
utimbuf
*
);
/**
* @tc.name : utime_0100
* @tc.desc : Specify file modification and access times
...
...
@@ -84,9 +86,41 @@ void utime_0200(void)
remove
(
path
);
}
/**
* @tc.name : utime64_0100
* @tc.desc : Specify file modification and access times
* @tc.level : Level 0
*/
void
utime64_0100
(
void
)
{
int
fd
;
char
file
[]
=
"/data/utime641.txt"
;
struct
utimbuf
ubuf
;
struct
stat
info
;
if
((
fd
=
creat
(
file
,
S_IWUSR
))
<
0
)
{
t_error
(
"%s creat failed"
,
__func__
);
}
else
{
close
(
fd
);
stat
(
file
,
&
info
);
ubuf
.
modtime
=
0
;
time
(
&
ubuf
.
actime
);
if
(
__utime64
(
file
,
&
ubuf
)
!=
0
)
{
t_error
(
"%s __utime64 failed"
,
__func__
);
}
else
{
stat
(
file
,
&
info
);
if
(
info
.
st_mtim
.
tv_sec
!=
0
)
{
t_error
(
"%s modify file time failed"
,
__func__
);
}
}
}
remove
(
file
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
utime_0100
();
utime_0200
();
utime64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/symver/dlsym.c
浏览文件 @
38424281
...
...
@@ -20,6 +20,8 @@
#include "dso_no_symver.h"
#include "dso_symver.h"
extern
void
*
__dlsym_time64
(
void
*
__restrict
,
const
char
*
__restrict
);
/**
* @tc.name : dlsym_no_symver_0100
* @tc.desc : invoke a symbol programmatically
...
...
@@ -247,12 +249,46 @@ void dlsym_hard_symver_0300(void)
symver_log
(
"end"
);
}
/**
* @tc.name : dlsym_time64_no_symver_0100
* @tc.desc : invoke a symbol programmatically
* @tc.level : Level 0
*/
void
dlsym_time64_no_symver_0100
(
void
)
{
symver_log
(
"start"
);
void
*
handle
=
dlopen
(
dso_no_symver_name
,
RTLD_LAZY
);
if
(
!
handle
)
{
symver_error
(
"%s"
,
dlerror
());
return
;
}
// Clear any existing error
dlerror
();
functype
func
=
(
functype
)
__dlsym_time64
(
handle
,
dso_no_symver_symbol
);
const
char
*
error
=
dlerror
();
if
(
error
!=
NULL
)
{
symver_error
(
"%s"
,
error
);
return
;
}
const
char
*
result
=
func
();
symver_streq
(
result
,
dso_no_symver_symbol
);
dlclose
(
handle
);
symver_log
(
"end"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
symver_log
(
"start"
);
dlsym_no_symver_0100
();
dlsym_no_symver_0200
();
dlsym_time64_no_symver_0100
();
dlsym_easy_symver_0100
();
dlsym_easy_symver_0200
();
...
...
libc-test/src/functionalext/thread/pthread_cond_timedwait.c
浏览文件 @
38424281
...
...
@@ -16,6 +16,9 @@
#include <pthread.h>
#include "pthread_util.h"
extern
int
__pthread_cond_timedwait_time64
(
pthread_cond_t
*
__restrict
,
pthread_mutex_t
*
__restrict
,
const
struct
timespec
*
__restrict
);
// pthread_cond_clockwait
static
pthread_mutex_t
c_mtx1
=
PTHREAD_MUTEX_INITIALIZER
;
static
pthread_cond_t
c_cond1
=
PTHREAD_COND_INITIALIZER
;
...
...
@@ -92,6 +95,33 @@ void pthread_cond_timedwait_0020(void)
EXPECT_EQ
(
pthread_mutex_destroy
(
&
mutex
),
0
);
}
/**
* @tc.number : pthread_cond_timedwait_time64_0010
* @tc.desc : Test whether the pthread_cond_timedwait is normal
* @tc.level : Level 0
*/
void
pthread_cond_timedwait_time64_0010
(
void
)
{
pthread_condattr_t
a
;
EXPECT_EQ
(
pthread_condattr_init
(
&
a
),
0
);
pthread_cond_t
cond
=
PTHREAD_COND_INITIALIZER
;
EXPECT_EQ
(
pthread_cond_init
(
&
cond
,
&
a
),
0
);
pthread_mutex_t
mutex
=
PTHREAD_MUTEX_INITIALIZER
;
struct
timespec
ts
=
{
0
};
EXPECT_EQ
(
pthread_mutex_lock
(
&
mutex
),
0
);
EXPECT_EQ
(
clock_gettime
(
CLOCK_REALTIME
,
&
ts
),
0
);
ts
.
tv_nsec
+=
SLEEP_10_MS
*
MS_PER_S
*
MS_PER_S
;
if
(
ts
.
tv_nsec
>=
MS_PER_S
*
MS_PER_S
*
MS_PER_S
)
{
ts
.
tv_nsec
-=
MS_PER_S
*
MS_PER_S
*
MS_PER_S
;
ts
.
tv_sec
+=
1
;
}
EXPECT_EQ
(
__pthread_cond_timedwait_time64
(
&
cond
,
&
mutex
,
&
ts
),
ETIMEDOUT
);
EXPECT_EQ
(
pthread_mutex_unlock
(
&
mutex
),
0
);
EXPECT_EQ
(
pthread_cond_destroy
(
&
cond
),
0
);
EXPECT_EQ
(
pthread_mutex_destroy
(
&
mutex
),
0
);
}
/**
* @tc.number : pthread_cond_timedwait_monotonic_np_0010
* @tc.desc : Test whether the pthread_cond_timedwait_monotonic_np is normal
...
...
@@ -675,6 +705,7 @@ void timeoutnp_timewait_0020(void)
TEST_FUN
G_Fun_Array
[]
=
{
pthread_cond_timedwait_0010
,
pthread_cond_timedwait_0020
,
pthread_cond_timedwait_time64_0010
,
pthread_cond_timedwait_monotonic_np_0010
,
pthread_cond_timeout_np_0010
,
pthread_cond_clockwait_0010
,
...
...
libc-test/src/functionalext/time/ctime.c
浏览文件 @
38424281
...
...
@@ -20,6 +20,8 @@
static
time_t
gTime
=
1659177614
;
extern
char
*
__ctime64
(
const
time_t
*
);
/**
* @tc.name : ctime_0100
* @tc.desc : according to different time zones,covert date and time to string
...
...
@@ -46,8 +48,35 @@ void ctime_0100(void)
}
}
/**
* @tc.name : ctime64_0100
* @tc.desc : according to different time zones,covert date and time to string
* @tc.level : Level 0
*/
void
ctime64_0100
(
void
)
{
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)(
sizeof
(
test_asctime_data
)
/
sizeof
(
test_asctime_data
[
0
]));
i
++
)
{
const
char
*
handlerChar
=
test_handle_path
(
test_asctime_data
[
i
].
tz
);
if
(
!
handlerChar
)
{
t_error
(
"ctime_0100 failed: handlerChar is NULL
\n
"
);
continue
;
}
setenv
(
"TZ"
,
handlerChar
,
1
);
tzset
();
char
*
returnStr
=
__ctime64
(
&
gTime
);
if
(
returnStr
==
NULL
)
{
EXPECT_FALSE
(
"ctime_0100"
,
returnStr
==
NULL
);
return
;
}
returnStr
[
strlen
(
returnStr
)
-
1
]
=
0x00
;
EXPECT_STREQ
(
"ctime_0100"
,
returnStr
,
test_asctime_data
[
i
].
result
);
}
}
int
main
(
void
)
{
ctime_0100
();
ctime64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/time/ctime_r.c
浏览文件 @
38424281
...
...
@@ -21,6 +21,8 @@
static
time_t
gTime
=
1659177614
;
static
int16_t
gBufferSize
=
256
;
extern
char
*
__ctime64_r
(
const
time_t
*
,
char
*
);
/**
* @tc.name : ctime_r_0100
* @tc.desc : according to different time zones, covert date and time to string
...
...
@@ -49,8 +51,37 @@ void ctime_r_0100(void)
}
}
/**
* @tc.name : ctime64_r_0100
* @tc.desc : according to different time zones, covert date and time to string
* @tc.level : Level 0
*/
void
ctime64_r_0100
(
void
)
{
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)(
sizeof
(
test_asctime_data
)
/
sizeof
(
test_asctime_data
[
0
]));
i
++
)
{
const
char
*
handlerChar
=
test_handle_path
(
test_asctime_data
[
i
].
tz
);
if
(
!
handlerChar
)
{
t_error
(
"ctime64_r_0100 failed: handlerChar is NULL
\n
"
);
continue
;
}
setenv
(
"TZ"
,
handlerChar
,
1
);
tzset
();
char
s
[
gBufferSize
];
char
*
returnStr
=
__ctime64_r
(
&
gTime
,
s
);
if
(
returnStr
==
NULL
)
{
EXPECT_FALSE
(
"ctime64_r_0100"
,
returnStr
==
NULL
);
return
;
}
returnStr
[
strlen
(
returnStr
)
-
1
]
=
0x00
;
EXPECT_STREQ
(
"ctime64_r_0100"
,
returnStr
,
test_asctime_data
[
i
].
result
);
EXPECT_STREQ
(
"ctime64_r_0100"
,
returnStr
,
s
);
}
}
int
main
(
void
)
{
ctime_r_0100
();
ctime64_r_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/time/difftime.c
浏览文件 @
38424281
...
...
@@ -18,6 +18,8 @@
#include "difftime_data.h"
#include "functionalext.h"
extern
double
__difftime64
(
time_t
,
time_t
);
/**
* @tc.name : difftime_0100
* @tc.desc : according to different time zones, calculate the time difference between two moments
...
...
@@ -43,8 +45,35 @@ void difftime_0100(void)
}
}
/**
* @tc.name : difftime64_0100
* @tc.desc : according to different time zones, calculate the time difference between two moments
* @tc.level : Level 0
*/
void
difftime64_0100
(
void
)
{
time_t
timeStart
=
20000
;
time_t
timeEnd
=
20010
;
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)(
sizeof
(
test_difftime_data
)
/
sizeof
(
test_difftime_data
[
0
]));
i
++
)
{
const
char
*
handlerChar
=
test_handle_path
(
test_difftime_data
[
i
].
tz
);
if
(
!
handlerChar
)
{
t_error
(
"difftime_0100 failed: handlerChar is NULL
\n
"
);
continue
;
}
setenv
(
"TZ"
,
handlerChar
,
1
);
tzset
();
double
returnVal
;
returnVal
=
__difftime64
(
timeEnd
,
timeStart
);
EXPECT_TRUE
(
"difftime64_0100"
,
abs
(
test_difftime_data
[
i
].
result
-
returnVal
)
>=
0
&&
abs
(
test_difftime_data
[
i
].
result
-
returnVal
)
<
1
);
}
}
int
main
(
void
)
{
difftime_0100
();
difftime64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/time/localtime.c
浏览文件 @
38424281
...
...
@@ -22,6 +22,8 @@ static time_t gTime = 1659177614;
static
int16_t
gYearBase
=
1900
;
static
int16_t
gBufferSize
=
500
;
extern
struct
tm
*
__localtime64
(
const
time_t
*
);
/**
* @tc.name : localtime_0100
* @tc.desc : according to different time zones, converts the time in seconds from 1970-1-1 0:00
...
...
@@ -51,8 +53,38 @@ void localtime_0100(void)
}
}
/**
* @tc.name : localtime64_0100
* @tc.desc : according to different time zones, converts the time in seconds from 1970-1-1 0:00
* to the current time system offset to local time
* @tc.level : Level 0
*/
void
localtime64_0100
(
void
)
{
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)(
sizeof
(
test_localtime_data
)
/
sizeof
(
test_localtime_data
[
0
]));
i
++
)
{
const
char
*
handlerChar
=
test_handle_path
(
test_localtime_data
[
i
].
tz
);
if
(
!
handlerChar
)
{
t_error
(
"localtime64_0100 failed: handlerChar is NULL
\n
"
);
continue
;
}
setenv
(
"TZ"
,
handlerChar
,
1
);
tzset
();
struct
tm
*
localtm
;
localtm
=
__localtime64
(
&
gTime
);
char
buff
[
gBufferSize
];
int
cnt
=
sprintf
(
buff
,
"%d-%d-%d %d:%d:%d wday=%d,yday=%d,isdst=%d,gmtoff=%ld,zone=%s"
,
(
localtm
->
tm_year
+
gYearBase
),
localtm
->
tm_mon
,
localtm
->
tm_mday
,
localtm
->
tm_hour
,
localtm
->
tm_min
,
localtm
->
tm_sec
,
localtm
->
tm_wday
,
localtm
->
tm_yday
,
localtm
->
tm_isdst
,
localtm
->
tm_gmtoff
,
localtm
->
tm_zone
);
EXPECT_TRUE
(
"localtime64_0100"
,
cnt
>
0
);
EXPECT_STREQ
(
"localtime64_0100"
,
test_localtime_data
[
i
].
result
,
buff
);
}
}
int
main
(
void
)
{
localtime_0100
();
localtime64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/time/localtime_r.c
浏览文件 @
38424281
...
...
@@ -22,6 +22,8 @@ static time_t gTime = 1659177614;
static
int16_t
gYearBase
=
1900
;
static
int16_t
gBufferSize
=
500
;
extern
struct
tm
*
__localtime64_r
(
const
time_t
*
__restrict
,
struct
tm
*
__restrict
);
/**
* @tc.name : localtime_r_0100
* @tc.desc : according to different time zones, converts the time in seconds from 1970-1-1 0:00
...
...
@@ -52,8 +54,39 @@ void localtime_r_0100(void)
}
}
/**
* @tc.name : localtime64_r_0100
* @tc.desc : according to different time zones, converts the time in seconds from 1970-1-1 0:00
* to the current time system offset to local time
* @tc.level : Level 0
*/
void
localtime64_r_0100
(
void
)
{
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)(
sizeof
(
test_localtime_data
)
/
sizeof
(
test_localtime_data
[
0
]));
i
++
)
{
const
char
*
handlerChar
=
test_handle_path
(
test_localtime_data
[
i
].
tz
);
if
(
!
handlerChar
)
{
t_error
(
"localtime_r_0100 failed: handlerChar is NULL
\n
"
);
continue
;
}
setenv
(
"TZ"
,
handlerChar
,
1
);
tzset
();
struct
tm
*
localtm
=
NULL
;
struct
tm
res
=
{
0
};
localtm
=
__localtime64_r
(
&
gTime
,
&
res
);
char
buff
[
gBufferSize
];
int
cnt
=
sprintf
(
buff
,
"%d-%d-%d %d:%d:%d wday=%d,yday=%d,isdst=%d,gmtoff=%ld,zone=%s"
,
(
localtm
->
tm_year
+
gYearBase
),
localtm
->
tm_mon
,
localtm
->
tm_mday
,
localtm
->
tm_hour
,
localtm
->
tm_min
,
localtm
->
tm_sec
,
localtm
->
tm_wday
,
localtm
->
tm_yday
,
localtm
->
tm_isdst
,
localtm
->
tm_gmtoff
,
localtm
->
tm_zone
);
EXPECT_TRUE
(
"localtime64_r_0100"
,
cnt
>
0
);
EXPECT_STREQ
(
"localtime64_r_0100"
,
test_localtime_data
[
i
].
result
,
buff
);
}
}
int
main
(
void
)
{
localtime_r_0100
();
localtime64_r_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/time/mktime.c
浏览文件 @
38424281
...
...
@@ -20,6 +20,8 @@
static
time_t
gTime
=
1659177614
;
extern
time_t
__mktime64
(
struct
tm
*
);
/**
* @tc.name : mktime_0100
* @tc.desc : according to different time zones, convert time to seconds in duration since 1970-1-1
...
...
@@ -46,8 +48,35 @@ void mktime_0100(void)
}
}
/**
* @tc.name : mktime64_0100
* @tc.desc : according to different time zones, convert time to seconds in duration since 1970-1-1
* @tc.level : Level 0
*/
void
mktime64_0100
(
void
)
{
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)(
sizeof
(
test_mktime_data
)
/
sizeof
(
test_mktime_data
[
0
]));
i
++
)
{
const
char
*
handlerChar
=
test_handle_path
(
test_mktime_data
[
i
].
tz
);
if
(
!
handlerChar
)
{
t_error
(
"mktime64_0100 failed: handlerChar is NULL
\n
"
);
continue
;
}
setenv
(
"TZ"
,
handlerChar
,
1
);
tzset
();
struct
tm
*
timeptr
=
localtime
(
&
gTime
);
if
(
!
timeptr
)
{
EXPECT_PTRNE
(
"mktime64_0100"
,
timeptr
,
NULL
);
return
;
}
time_t
mk
=
__mktime64
(
timeptr
);
EXPECT_EQ
(
"mktime64_0100"
,
mk
,
test_mktime_data
[
i
].
result
);
}
}
int
main
(
void
)
{
mktime_0100
();
mktime64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/time/time_ext.c
浏览文件 @
38424281
...
...
@@ -24,6 +24,8 @@
#define __TEST_DATA_HOUR__ 9
#define __TEST_DATA_MINUTE__ 12
extern
time_t
__time64
(
time_t
*
);
struct
time_struct
{
const
char
*
tz
;
};
...
...
@@ -69,8 +71,42 @@ void time_0100(void)
}
}
/**
* @tc.name : time64_0100
* @tc.desc : according to different time zones, get time
* @tc.level : Level 0
*/
void
time64_0100
(
void
)
{
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)(
sizeof
(
gResultData
)
/
sizeof
(
gResultData
[
0
]));
i
++
)
{
const
char
*
handlerChar
=
test_handle_path
(
gResultData
[
i
].
tz
);
if
(
!
handlerChar
)
{
t_error
(
"time64_0100 failed: handlerChar is NULL
\n
"
);
continue
;
}
setenv
(
"TZ"
,
handlerChar
,
1
);
tzset
();
system
(
"date '2021-10-3 9:12:12' > /dev/NULL"
);
time_t
curClock
;
time_t
t
=
__time64
(
&
curClock
);
EXPECT_TRUE
(
"time64_0100"
,
t
>
0
);
struct
tm
*
localtm
=
localtime
(
&
curClock
);
if
(
!
localtm
)
{
EXPECT_PTRNE
(
"time64_0100"
,
localtm
,
NULL
);
return
;
}
EXPECT_EQ
(
"time64_0100"
,
__TEST_DATA_YEAR__
,
localtm
->
tm_year
);
EXPECT_EQ
(
"time64_0100"
,
__TEST_DATA_MONTH__
,
localtm
->
tm_mon
);
EXPECT_EQ
(
"time64_0100"
,
__TEST_DATA_DAY__
,
localtm
->
tm_mday
);
EXPECT_EQ
(
"time64_0100"
,
__TEST_DATA_HOUR__
,
localtm
->
tm_hour
);
EXPECT_EQ
(
"time64_0100"
,
__TEST_DATA_MINUTE__
,
localtm
->
tm_min
);
}
}
int
main
(
void
)
{
time_0100
();
time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/time/timegm.c
浏览文件 @
38424281
...
...
@@ -18,6 +18,8 @@
#include "functionalext.h"
#include "timegm_data.h"
extern
time_t
__timegm_time64
(
struct
tm
*
);
static
time_t
gTime
=
1659177614
;
/**
...
...
@@ -47,8 +49,36 @@ void timegm_0100(void)
}
}
/**
* @tc.name : timegm_time64_0100
* @tc.desc : according to different time zones, return a timestamp from 1970-1-1 to the specified date
* @tc.level : Level 0
*/
void
timegm_time64_0100
(
void
)
{
time_t
timeThis
;
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)(
sizeof
(
test_timegm_data
)
/
sizeof
(
test_timegm_data
[
0
]));
i
++
)
{
const
char
*
handlerChar
=
test_handle_path
(
test_timegm_data
[
i
].
tz
);
if
(
!
handlerChar
)
{
t_error
(
"timegm_time64_0100 failed: handlerChar is NULL
\n
"
);
continue
;
}
setenv
(
"TZ"
,
handlerChar
,
1
);
tzset
();
struct
tm
*
timeptr
=
localtime
(
&
gTime
);
if
(
!
timeptr
)
{
EXPECT_PTRNE
(
"timegm_time64_0100"
,
timeptr
,
NULL
);
return
;
}
timeThis
=
__timegm_time64
(
timeptr
);
EXPECT_EQ
(
"timegm_time64_0100"
,
test_timegm_data
[
i
].
result
,
timeThis
);
}
}
int
main
(
void
)
{
timegm_0100
();
timegm_time64_0100
();
return
t_status
;
}
\ No newline at end of file
libc-test/src/regression/pthread_cancel-sem_wait.c
浏览文件 @
38424281
...
...
@@ -8,6 +8,8 @@
#define TESTR(r, f, m) ( \
((r) = (f)) == 0 || (t_error("%s failed: %s (" m ")\n", #f, strerror(r)), 0) )
extern
int
__sem_timedwait_time64
(
sem_t
*
__restrict
,
const
struct
timespec
*
__restrict
);
static
sem_t
sem1
,
sem2
;
static
int
seqno
;
...
...
@@ -36,6 +38,14 @@ static void *start_sem_timedwait(void *arg)
return
0
;
}
static
void
*
start_sem_timedwait_time64
(
void
*
arg
)
{
wait_cancel
(
arg
);
__sem_timedwait_time64
(
&
sem2
,
&
(
struct
timespec
){
1
,
0
});
seqno
=
2
;
return
0
;
}
int
main
(
void
)
{
pthread_t
td
;
...
...
@@ -84,5 +94,15 @@ int main(void)
TESTC
(
res
==
PTHREAD_CANCELED
,
"canceled thread exit status after blocking sem_timedwait"
);
TESTC
(
seqno
==
1
,
"blocking sem_timedwait"
);
/* Cancellation on blocking __sem_timedwait_time64 */
seqno
=
0
;
sem_trywait
(
&
sem2
);
TESTR
(
r
,
pthread_create
(
&
td
,
0
,
start_sem_timedwait_time64
,
0
),
"failed to create thread"
);
TESTR
(
r
,
pthread_cancel
(
td
),
"canceling"
);
sem_post
(
&
sem1
);
TESTR
(
r
,
pthread_join
(
td
,
&
res
),
"joining canceled thread after blocking __sem_timedwait_time64"
);
TESTC
(
res
==
PTHREAD_CANCELED
,
"canceled thread exit status after blocking __sem_timedwait_time64"
);
TESTC
(
seqno
==
1
,
"blocking __sem_timedwait_time64"
);
return
t_status
;
}
鸿蒙社区
@harmonycommunity
mentioned in commit
56c728cb
·
11月 18, 2022
mentioned in commit
56c728cb
mentioned in commit 56c728cbd661628a4eb97527d4c605d38596d970
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录