Add basic time namespace testcases
cover Add basic time namespace testcases
This is a set of test for the time namespaces that are going to be part of 5.6 kernel.
Cyril Hrubis (8):
lapi/namespace_constants.h: Add CLONE_NEWTIME
lapi: Add a configure check and fallback for setns include/tst_timer: Fix normalization syscalls/sysinfo03: Add time namespace test syscalls/clock_nanosleep03: Add test for time namespace syscalls/clock_gettime03: Add basic time namespace test containers/timens: Add basic error test syscalls/timerfd04: Add time namespace test
configure.ac | 1 + include/lapi/namespaces_constants.h | 3 + include/lapi/setns.h | 20 ++++ include/tst_timer.h | 35 +++--- runtest/containers | 7 ++ runtest/syscalls | 4 + testcases/kernel/containers/timens/.gitignore | 1 + testcases/kernel/containers/timens/Makefile | 6 + testcases/kernel/containers/timens/timens01.c | 75 ++++++++++++ .../kernel/syscalls/clock_gettime/.gitignore | 1 + .../syscalls/clock_gettime/clock_gettime03.c | 113 ++++++++++++++++++ .../syscalls/clock_nanosleep/.gitignore | 1 + .../clock_nanosleep/clock_nanosleep03.c | 71 +++++++++++ testcases/kernel/syscalls/sysinfo/.gitignore | 1 + testcases/kernel/syscalls/sysinfo/sysinfo03.c | 78 ++++++++++++ testcases/kernel/syscalls/timerfd/.gitignore | 1 + testcases/kernel/syscalls/timerfd/timerfd04.c | 95 +++++++++++++++ 17 files changed, 496 insertions(+), 17 deletions(-) create mode 100644 include/lapi/setns.h create mode 100644 testcases/kernel/containers/timens/.gitignore create mode 100644 testcases/kernel/containers/timens/Makefile create mode 100644 testcases/kernel/containers/timens/timens01.c create mode 100644 testcases/kernel/syscalls/clock_gettime/clock_gettime03.c create mode 100644 testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep03.c create mode 100644 testcases/kernel/syscalls/sysinfo/sysinfo03.c create mode 100644 testcases/kernel/syscalls/timerfd/timerfd04.c
Signature · 1 line
2.23.0
PATCH 1/8 lapi/namespace_constants.h: Add CLONE_NEWTIME
--- include/lapi/namespaces_constants.h | 3 +++ 1 file changed, 3 insertions(+)
include/lapi/namespaces_constants.h +3 -0
@@ -24,5 +24,8 @@#ifndef CLONE_NEWUTS # define CLONE_NEWUTS 0x04000000#endif +#ifndef CLONE_NEWTIME +# define CLONE_NEWTIME 0x00000080 +#endif #endif /* __NAMESPACES_CONSTANTS_H__ */
Signature · 1 line
2.23.0
PATCH 2/8 lapi: Add a configure check and fallback for setns
In reply to Cyril Hrubis--- configure.ac | 1 + include/lapi/setns.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 include/lapi/setns.h
configure.ac +1 -0
@@ -110,6 +110,7 @@ AC_CHECK_FUNCS([ \ renameat2 \ sched_getcpu \ sendmmsg \ + setns \ sigpending \ splice \ statx \
include/lapi/setns.h new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +Copyright (c) 2020 Cyril Hrubis <[email protected]> +*/ + +#ifndef LAPI_SETNS_H__ +#define LAPI_SETNS_H__ + +#include "config.h" +#include "lapi/syscalls.h" +#include <sched.h> + +#ifndef HAVE_SETNS +int setns (int fd,int nstype) +{ +return tst_syscall (__NR_setns, fd, nstype); +} +#endif + +#endif /* LAPI_SETNS_H__ */
Signature · 1 line
2.23.0
PATCH 2/8 lapi: Add a configure check and fallback for setns
Hi Cyril,
your patchset looks good to me.
There is an error for old glibc on centos 06:
https://api.travis-ci.org/v3/job/659994070/log.txt
In file included from /usr/src/ltp/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c:21:
/usr/src/ltp/include/lapi/setns.h: In function 'setns':
/usr/src/ltp/include/lapi/setns.h:16: error: implicit declaration of function 'syscall'
/usr/src/ltp/include/lapi/setns.h:16: error: implicit declaration of function 'tst_brk'
/usr/src/ltp/include/lapi/setns.h:16: error: 'TCONF' undeclared (first use in this function)
/usr/src/ltp/include/lapi/setns.h:16: error: (Each undeclared identifier is reported only once
/usr/src/ltp/include/lapi/setns.h:16: error: for each function it appears in.)
In file included from /usr/src/ltp/include/tst_test.h:14,
from /usr/src/ltp/include/tst_safe_clocks.h:13,
from /usr/src/ltp/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c:22:/usr/include/unistd.h: At top level:
/usr/include/unistd.h:1068: error: conflicting types for 'syscall'
/usr/src/ltp/include/lapi/setns.h:16: note: previous implicit declaration of 'syscall' was here
Kind regards,
Petr
PATCH 2/8 lapi: Add a configure check and fallback for setns
Hi!
Quoted 9 lines
There is an error for old glibc on centos 06:
https://api.travis-ci.org/v3/job/659994070/log.txt
In file included from
/usr/src/ltp/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c:21:
/usr/src/ltp/include/lapi/setns.h: In function 'setns':
/usr/src/ltp/include/lapi/setns.h:16: error: implicit declaration of function 'syscall'
Hmm, I guess that we can include unistd.h in the lapi/syscalls.h so that the syscall() function has a prototype.
Quoted 6 lines
/usr/src/ltp/include/lapi/setns.h:16: error: implicit declaration of function 'tst_brk'
/usr/src/ltp/include/lapi/setns.h:16: error: 'TCONF' undeclared (first use in this function)
/usr/src/ltp/include/lapi/setns.h:16: error: (Each undeclared identifier is reported only once
Quoted 7 lines
/usr/src/ltp/include/lapi/setns.h:16: error: for each function it appears in.)In file included from
/usr/src/ltp/include/tst_test.h:14,from /usr/src/ltp/include/tst_safe_clocks.h:13, from /usr/src/ltp/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c:22:
Okay, I guess that both errors could be fixed by moving the lapi/setns.h include after the tst_test.h in the test, because tst_test.h both includes unistd.h as well as defines the tst_brk() and TCONF.
Thanks for spotting this.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 3/8 include/tst_timer: Fix normalization
In reply to Cyril HrubisThe timespec_add and timespec_sub functions were producing incorrect results when passed negative input. We have to normalize the result in both cases for nseconds < 0 && nseconds > 1s.
--- include/tst_timer.h | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
include/tst_timer.h +18 -17
@@ -134,6 +134,21 @@ static inline int tst_timespec_lt(struct timespec t1, struct timespec t2)return t1.tv_sec < t2.tv_sec; } +static inline struct timespec tst_timespec_normalize (struct timespec t) +{ +if (t.tv_nsec >=1000000000 ) { + t.tv_sec++; + t.tv_nsec -=1000000000 ; + } + +if (t.tv_nsec <0 ) { + t.tv_sec--; + t.tv_nsec +=1000000000 ; + } + +return t; +} +/* * Adds us microseconds to t. */
@@ -143,12 +158,8 @@ static inline struct timespec tst_timespec_add_us(struct timespec t, t.tv_sec += us /1000000 ; t.tv_nsec += (us %1000000 ) *1000 ; -if (t.tv_nsec >=1000000000 ) { - t.tv_sec++; - t.tv_nsec -=1000000000 ; - } -return t; +return tst_timespec_normalize (t); }/*
@@ -162,12 +173,7 @@ static inline struct timespec tst_timespec_add(struct timespec t1, res.tv_sec = t1.tv_sec + t2.tv_sec; res.tv_nsec = t1.tv_nsec + t2.tv_nsec; -if (res.tv_nsec >=1000000000 ) { - res.tv_sec++; - res.tv_nsec -=1000000000 ; - } - -return res; +return tst_timespec_normalize (res); }/*
@@ -179,12 +185,7 @@ static inline struct timespec tst_timespec_sub_us(struct timespec t, t.tv_sec -= us /1000000 ; t.tv_nsec -= (us %1000000 ) *1000 ; -if (t.tv_nsec <0 ) { - t.tv_sec--; - t.tv_nsec +=1000000000 ; - } - -return t; +return tst_timespec_normalize (t); }/*
Signature · 1 line
2.23.0
PATCH 4/8 syscalls/sysinfo03: Add time namespace test
In reply to Cyril HrubisThis tests that the uptime in sysinfo() is adjusted correctly by the namespace offset.
Also check that /proc/uptime is consistent with the uptime from the sysinfo() syscall.
--- runtest/containers | 3 + runtest/syscalls | 1 + testcases/kernel/syscalls/sysinfo/.gitignore | 1 + testcases/kernel/syscalls/sysinfo/sysinfo03.c | 78 +++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 testcases/kernel/syscalls/sysinfo/sysinfo03.c
runtest/containers +3 -0
@@ -85,3 +85,6 @@ userns04 userns04 userns05 userns05 userns06 userns06 userns07 userns07 + +# time namespaces +sysinfo03 sysinfo03
runtest/syscalls +1 -0
@@ -1441,6 +1441,7 @@ sysfs06 sysfs06 sysinfo01 sysinfo01 sysinfo02 sysinfo02 +sysinfo03 sysinfo03 syslog01 syslog01 syslog02 syslog02
testcases/kernel/syscalls/sysinfo/.gitignore +1 -0
@@ -1,2 +1,3 @@ /sysinfo01 /sysinfo02 +/sysinfo03
testcases/kernel/syscalls/sysinfo/sysinfo03.c new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH 4/8 syscalls/sysinfo03: Add time namespace test
Hello,
Quoted 120 lines · Cyril Hrubis
This tests that the uptime in
sysinfo()is adjusted correctly by the namespace offset.Also check that
/proc/uptimeis consistent with the uptime from thesysinfo()syscall.Signed-off-by Cyril Hrubis <[email protected]>--- runtest/containers | 3 + runtest/syscalls | 1 + testcases/kernel/syscalls/sysinfo/.gitignore | 1 + testcases/kernel/syscalls/sysinfo/sysinfo03.c | 78 +++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 testcases/kernel/syscalls/sysinfo/sysinfo03.cruntest/containers +3
-0@@ -85,3 +85,6 @@ userns04 userns04 userns05 userns05 userns06 userns06 userns07 userns07 + +# time namespaces +sysinfo03 sysinfo03runtest/syscalls +1
-0@@ -1441,6 +1441,7 @@ sysfs06 sysfs06 sysinfo01 sysinfo01 sysinfo02 sysinfo02 +sysinfo03 sysinfo03 syslog01 syslog01 syslog02 syslog02testcases/kernel/syscalls/sysinfo/.gitignore +1
-0@@ -1,2 +1,3 @@ /sysinfo01 /sysinfo02 +/sysinfo03testcases/kernel/syscalls/sysinfo/sysinfo03.c new file +68
-0@@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +Copyright (c) 2020 Cyril Hrubis <[email protected]> +*/ +/* + +Test if CLOCK_BOOTTIME namespace offset is applied to sysinfo uptime and that +it's consistent with /proc/uptime as well. + +After a call to unshare(CLONE_NEWTIME) a new timer namespace is created, the +process that has called the unshare() can adjust offsets for CLOCK_MONOTONIC +and CLOCK_BOOTTIME for its children by writing to the '/proc/self/timens_offsets'. + +*/ + +#include <sys/sysinfo.h> +#include "lapi/namespaces_constants.h" +#include "tst_test.h" + +static int offsets[] = { +10 , +-10 , +3600 , +}; + +static long read_proc_uptime (void ) +{ +long sec, sec_rem; + +SAFE_FILE_SCANF ("/proc/uptime" ,"%li.%li" , &sec, &sec_rem); + +return sec + (sec_rem ?1 :0 ); +} + +static void verify_sysinfo (unsigned int n) +{ +struct sysinfo si; +long uptime; +int off = offsets[n]; + +SAFE_UNSHARE (CLONE_NEWTIME ); + +SAFE_FILE_PRINTF ("/proc/self/timens_offsets" ,"%d %d 0" , +CLOCK_BOOTTIME , off); + +sysinfo (&si); + + uptime = si.uptime; + +if (!SAFE_FORK ()) { +sysinfo (&si); +long proc_uptime =read_proc_uptime (); + +long diff = si.uptime - uptime; + +if (diff < off || diff > off +1 ) +tst_res (TFAIL ,"Wrong sysinfo uptime offset %li" , diff); +else +tst_res (TPASS ,"Correct sysinfo uptime offset %i" , off); + +if (si.uptime < proc_uptime || si.uptime > proc_uptime +1 ) { +tst_res (TFAIL ,"/proc/uptime %li differs from sysinfo %li" , + proc_uptime, si.uptime); + }else { +tst_res (TPASS ,"/proc/uptime is consistent with sysinfo" ); + } + } +}
testcases/kernel/syscalls/sysinfo/sysinfo03.c line 78
Quoted 10 lines
testcases/kernel/syscalls/sysinfo/sysinfo03.c new file +10
-0+ +static struct tst_test test = { + .tcnt =ARRAY_SIZE (offsets), + .test = verify_sysinfo, + .needs_root =1 , + .forks_child =1 , + .needs_kconfigs = (const char *[]) { +"CONFIG_TIME_NS=y" + } +};
Will you add a git ref when the fix is in mainline/for-next?
Should be safe to add it as soon as it is in the for-next tree.
Quoted 2 lines
Signature · 1 line
2.23.0
Signature · 2 lines
Thank you, Richard.
PATCH 4/8 syscalls/sysinfo03: Add time namespace test
Hi!
Quoted 12 lines
testcases/kernel/syscalls/sysinfo/sysinfo03.c line 78
Quoted 9 lines
testcases/kernel/syscalls/sysinfo/sysinfo03.c new file +9
-0+static struct tst_test test = { + .tcnt =ARRAY_SIZE (offsets), + .test = verify_sysinfo, + .needs_root =1 , + .forks_child =1 , + .needs_kconfigs = (const char *[]) { +"CONFIG_TIME_NS=y" + } +};Will you add a git ref when the fix is in mainline/for-next?
Quoted 1 line
Should be safe to add it as soon as it is in the for-next tree.
I'm not sure how usefull that will be because the fix should get in during the RC phase the functionality was introduced, so technically the missing support of sysinfo() in time namespaces should not reach any officially released kernel.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 4/8 syscalls/sysinfo03: Add time namespace test
Hello,
Quoted 13 lines · Cyril Hrubis
Hi!
Quoted 12 lines
testcases/kernel/syscalls/sysinfo/sysinfo03.c line 78
Quoted 9 lines
testcases/kernel/syscalls/sysinfo/sysinfo03.c new file +9
-0+static struct tst_test test = { + .tcnt =ARRAY_SIZE (offsets), + .test = verify_sysinfo, + .needs_root =1 , + .forks_child =1 , + .needs_kconfigs = (const char *[]) { +"CONFIG_TIME_NS=y" + } +};Will you add a git ref when the fix is in mainline/for-next?
Quoted 6 lines
Quoted 1 line
Should be safe to add it as soon as it is in the for-next tree.
I'm not sure how usefull that will be because the fix should get in during the RC phase the functionality was introduced, so technically the missing support of
sysinfo()in time namespaces should not reach any officially released kernel.
What is the downside to including it?
Also, I can imagine some people will try backporting this and may miss something not in the original patch set.
--
Thank you,
Richard.
PATCH 4/8 syscalls/sysinfo03: Add time namespace test
Hi!
Quoted 19 lines
Quoted 12 lines
Quoted 12 lines
testcases/kernel/syscalls/sysinfo/sysinfo03.c line 78
Quoted 9 lines
testcases/kernel/syscalls/sysinfo/sysinfo03.c new file +9
-0+static struct tst_test test = { + .tcnt =ARRAY_SIZE (offsets), + .test = verify_sysinfo, + .needs_root =1 , + .forks_child =1 , + .needs_kconfigs = (const char *[]) { +"CONFIG_TIME_NS=y" + } +};Will you add a git ref when the fix is in mainline/for-next?
Quoted 6 lines
Quoted 1 line
Should be safe to add it as soon as it is in the for-next tree.
I'm not sure how usefull that will be because the fix should get in during the RC phase the functionality was introduced, so technically the missing support of
sysinfo()in time namespaces should not reach any officially released kernel.
Quoted 4 lines
What is the downside to including it?
Also, I can imagine some people will try backporting this and may miss something not in the original patch set.
Okay, that's a valid reason to include the hash.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 5/8 syscalls/clock_nanosleep03: Add test for time namespace
In reply to Cyril HrubisTest that absolute timeout for clock nanosleep is adjusted by the offset correctly inside of a time namespace.
--- runtest/containers | 1 + runtest/syscalls | 1 + .../syscalls/clock_nanosleep/.gitignore | 1 + .../clock_nanosleep/clock_nanosleep03.c | 71 +++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep03.c
runtest/containers +1 -0
@@ -88,3 +88,4 @@ userns07 userns07 # time namespaces sysinfo03 sysinfo03 +clock_nanosleep03 clock_nanosleep03
runtest/syscalls +1 -0
@@ -87,6 +87,7 @@ clock_getres01 clock_getres01 clock_nanosleep01 clock_nanosleep01 clock_nanosleep02 clock_nanosleep02 clock_nanosleep2_01 clock_nanosleep2_01 +clock_nanosleep03 clock_nanosleep03 clock_gettime01 clock_gettime01 clock_gettime02 clock_gettime02
testcases/kernel/syscalls/clock_nanosleep/.gitignore +1 -0
@@ -1,2 +1,3 @@ /clock_nanosleep01 /clock_nanosleep02 +/clock_nanosleep03
testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep03.c new file +71 -0
71 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH 6/8 syscalls/clock_gettime03: Add basic time namespace test
In reply to Cyril Hrubis--- runtest/containers | 1 + runtest/syscalls | 1 + .../kernel/syscalls/clock_gettime/.gitignore | 1 + .../syscalls/clock_gettime/clock_gettime03.c | 113 ++++++++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 testcases/kernel/syscalls/clock_gettime/clock_gettime03.c
runtest/containers +1 -0
@@ -89,3 +89,4 @@ userns07 userns07 # time namespaces sysinfo03 sysinfo03 clock_nanosleep03 clock_nanosleep03 +clock_gettime03 clock_gettime03
runtest/syscalls +1 -0
@@ -91,6 +91,7 @@ clock_nanosleep03 clock_nanosleep03 clock_gettime01 clock_gettime01 clock_gettime02 clock_gettime02 +clock_gettime03 clock_gettime03 leapsec01 leapsec01 clock_settime01 clock_settime01
testcases/kernel/syscalls/clock_gettime/.gitignore +1 -0
@@ -1,3 +1,4 @@ clock_gettime01 clock_gettime02 +clock_gettime03 leapsec01
testcases/kernel/syscalls/clock_gettime/clock_gettime03.c new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH 6/8 syscalls/clock_gettime03: Add basic time namespace test
Hi,
Quoted 88 lines · Cyril Hrubis
Signed-off-by Cyril Hrubis <[email protected]>--- runtest/containers | 1 + runtest/syscalls | 1 + .../kernel/syscalls/clock_gettime/.gitignore | 1 + .../syscalls/clock_gettime/clock_gettime03.c | 113 ++++++++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 testcases/kernel/syscalls/clock_gettime/clock_gettime03.cruntest/containers +1
-0@@ -89,3 +89,4 @@ userns07 userns07 # time namespaces sysinfo03 sysinfo03 clock_nanosleep03 clock_nanosleep03 +clock_gettime03 clock_gettime03runtest/syscalls +1
-0@@ -91,6 +91,7 @@ clock_nanosleep03 clock_nanosleep03 clock_gettime01 clock_gettime01 clock_gettime02 clock_gettime02 +clock_gettime03 clock_gettime03 leapsec01 leapsec01 clock_settime01 clock_settime01testcases/kernel/syscalls/clock_gettime/.gitignore +1
-0@@ -1,3 +1,4 @@ clock_gettime01 clock_gettime02 +clock_gettime03 leapsec01testcases/kernel/syscalls/clock_gettime/clock_gettime03.c new file +43
-0@@ -0,0 +1,113 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + +Copyright (c) 2020 Cyril Hrubis <[email protected]> + +*/ +/* + +Basic test for timer namespaces. + +After a call to unshare(CLONE_NEWTIME) a new timer namespace is created, the +process that has called the unshare() can adjust offsets for CLOCK_MONOTONIC +and CLOCK_BOOTTIME for its children by writing to the '/proc/self/timens_offsets'. + +The child processes also switch to the initial parent namespace and checks +that the offset is set to 0. + +*/ + +#define _GNU_SOURCE +#include "lapi/setns.h" +#include "tst_safe_clocks.h" +#include "tst_timer.h" +#include "lapi/namespaces_constants.h" +#include "tst_test.h" + +static struct tcase { +int clk_id; +int clk_off; +int off; +} tcases[] = { + {CLOCK_MONOTONIC ,CLOCK_MONOTONIC ,10 }, + {CLOCK_BOOTTIME ,CLOCK_BOOTTIME ,10 }, + + {CLOCK_MONOTONIC ,CLOCK_MONOTONIC ,-10 }, + {CLOCK_BOOTTIME ,CLOCK_BOOTTIME ,-10 }, + + {CLOCK_MONOTONIC_RAW ,CLOCK_MONOTONIC ,100 }, + {CLOCK_MONOTONIC_COARSE ,CLOCK_MONOTONIC ,100 }, +}; + +static struct timespec now; +static int parent_ns;
testcases/kernel/syscalls/clock_gettime/clock_gettime03.c line 53
Quoted 10 lines
testcases/kernel/syscalls/clock_gettime/clock_gettime03.c new file +10
-0+ +static void child (struct tcase *tc) +{ +struct timespec then; +struct timespec parent_then; +long long diff; + +SAFE_CLOCK_GETTIME (tc->clk_id, &then); + +setns (parent_ns,CLONE_NEWTIME );
Maybe check the error code?
Signature · 2 lines
Thank you, Richard.
PATCH 6/8 syscalls/clock_gettime03: Add basic time namespace test
Hi!
Quoted 11 lines
testcases/kernel/syscalls/clock_gettime/clock_gettime03.c line 53
Quoted 9 lines
testcases/kernel/syscalls/clock_gettime/clock_gettime03.c new file +9
-0+static void child (struct tcase *tc) +{ +struct timespec then; +struct timespec parent_then; +long long diff; + +SAFE_CLOCK_GETTIME (tc->clk_id, &then); + +setns (parent_ns,CLONE_NEWTIME );Maybe check the error code?
Indeed, I guess that I should add SAFE_SETNS() and then make use of that in the tests.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 7/8 containers/timens: Add basic error test
In reply to Cyril HrubisAdd basic error handling test for the /proc/$PID/timens_offsets file.
--- runtest/containers | 1 + testcases/kernel/containers/timens/.gitignore | 1 + testcases/kernel/containers/timens/Makefile | 6 ++ testcases/kernel/containers/timens/timens01.c | 75 +++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 testcases/kernel/containers/timens/.gitignore create mode 100644 testcases/kernel/containers/timens/Makefile create mode 100644 testcases/kernel/containers/timens/timens01.c
runtest/containers +1 -0
@@ -90,3 +90,4 @@ userns07 userns07 sysinfo03 sysinfo03 clock_nanosleep03 clock_nanosleep03 clock_gettime03 clock_gettime03 +timens01 timens01
testcases/kernel/containers/timens/.gitignore new file +1 -0
@@ -0,0 +1 @@ +timens01
testcases/kernel/containers/timens/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/containers/timens/timens01.c new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH 7/8 containers/timens: Add basic error test
Hi,
Quoted 64 lines · Cyril Hrubis
Add basic error handling test for the
/proc/$PID/timens_offsetsfile.Signed-off-by Cyril Hrubis <[email protected]>--- runtest/containers | 1 + testcases/kernel/containers/timens/.gitignore | 1 + testcases/kernel/containers/timens/Makefile | 6 ++ testcases/kernel/containers/timens/timens01.c | 75 +++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 testcases/kernel/containers/timens/.gitignore create mode 100644 testcases/kernel/containers/timens/Makefile create mode 100644 testcases/kernel/containers/timens/timens01.cruntest/containers +1
-0@@ -90,3 +90,4 @@ userns07 userns07 sysinfo03 sysinfo03 clock_nanosleep03 clock_nanosleep03 clock_gettime03 clock_gettime03 +timens01 timens01testcases/kernel/containers/timens/.gitignore new file +1
-0@@ -0,0 +1 @@ +timens01testcases/kernel/containers/timens/Makefile new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mktestcases/kernel/containers/timens/timens01.c new file +17
-0@@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + +Copyright (c) 2020 Cyril Hrubis <[email protected]> + +*/ +/* + +Basic test for timens_offsets error handling. + +After a call to unshare(CLONE_NEWTIME) a new timer namespace is created, the +process that has called the unshare() can adjust offsets for CLOCK_MONOTONIC +and CLOCK_BOOTTIME for its children by writing to the '/proc/self/timens_offsets'. + +*/ + +#define _GNU_SOURCE
testcases/kernel/containers/timens/timens01.c line 27
Quoted 10 lines
testcases/kernel/containers/timens/timens01.c new file +10
-0+#include "lapi/setns.h" +#include "lapi/namespaces_constants.h" +#include "lapi/posix_clocks.h" +#include "tst_test.h" + +static struct tcase { +const char *offsets; +int exp_err; +} tcases[] = { +/* obvious garbage */
You could include these comments in the struct and print them.
Signature · 2 lines
Thank you, Richard.
PATCH 8/8 syscalls/timerfd04: Add time namespace test
In reply to Cyril Hrubis--- runtest/containers | 1 + runtest/syscalls | 1 + testcases/kernel/syscalls/timerfd/.gitignore | 1 + testcases/kernel/syscalls/timerfd/timerfd04.c | 95 +++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 testcases/kernel/syscalls/timerfd/timerfd04.c
runtest/containers +1 -0
@@ -91,3 +91,4 @@ sysinfo03 sysinfo03 clock_nanosleep03 clock_nanosleep03 clock_gettime03 clock_gettime03 timens01 timens01 +timerfd04 timerfd04
runtest/syscalls +1 -0
@@ -1473,6 +1473,7 @@ times03 times03 timerfd01 timerfd01 timerfd02 timerfd02 timerfd03 timerfd03 +timerfd04 timerfd04 timerfd_create01 timerfd_create01 timerfd_gettime01 timerfd_gettime01 timerfd_settime01 timerfd_settime01
testcases/kernel/syscalls/timerfd/.gitignore +1 -0
@@ -1,6 +1,7 @@ /timerfd01 /timerfd02 /timerfd03 +/timerfd04 /timerfd_create01 /timerfd_gettime01 /timerfd_settime01
testcases/kernel/syscalls/timerfd/timerfd04.c new file +95 -0
95 lines not on this page · raw message
Signature · 1 line
2.23.0