public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/3] tst: Modify tst-clock_adjtime to allow reuse of its code
@ 2021-02-28 22:39 Lukasz Majewski
  2021-02-28 22:39 ` [PATCH 2/3] tst: Add test for adjtimex Lukasz Majewski
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Lukasz Majewski @ 2021-02-28 22:39 UTC (permalink / raw)
  To: Joseph Myers, Adhemerval Zanella, Florian Weimer, DJ Delorie
  Cc: Paul Eggert, Alistair Francis, Arnd Bergmann, Alistair Francis,
	GNU C Library, Carlos O'Donell, Florian Weimer,
	Zack Weinberg, Lukasz Majewski

The tst-clock_adjtime can be adjusted to be reused for also testing
adjtimex.
---
 sysdeps/unix/sysv/linux/tst-clock_adjtime.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sysdeps/unix/sysv/linux/tst-clock_adjtime.c b/sysdeps/unix/sysv/linux/tst-clock_adjtime.c
index 6b9bb9940c..84a3f19504 100644
--- a/sysdeps/unix/sysv/linux/tst-clock_adjtime.c
+++ b/sysdeps/unix/sysv/linux/tst-clock_adjtime.c
@@ -22,6 +22,11 @@
 #include <support/check.h>
 #include <support/timespec.h>
 
+#ifndef TST_ADJTIME_SYSCALL
+#define TST_ADJTIME_SYSCALL clock_adjtime
+#define TST_ADJTIME_ARGS (CLOCK_REALTIME, &delta)
+#endif
+
 static int
 do_test (void)
 {
@@ -40,7 +45,7 @@ do_test (void)
   delta.time.tv_usec = 0;
   delta.modes = ADJ_SETOFFSET;
 
-  int ret = clock_adjtime (CLOCK_REALTIME, &delta);
+  int ret = TST_ADJTIME_SYSCALL TST_ADJTIME_ARGS;
   if (ret == -1)
     FAIL_EXIT1 ("clock_adjtime failed: %m\n");
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] tst: Add test for adjtimex
  2021-02-28 22:39 [PATCH 1/3] tst: Modify tst-clock_adjtime to allow reuse of its code Lukasz Majewski
@ 2021-02-28 22:39 ` Lukasz Majewski
  2021-03-02 12:24   ` Adhemerval Zanella
  2021-02-28 22:39 ` [PATCH 3/3] tst: Add test for ntp_adjtime Lukasz Majewski
  2021-03-02 12:23 ` [PATCH 1/3] tst: Modify tst-clock_adjtime to allow reuse of its code Adhemerval Zanella
  2 siblings, 1 reply; 7+ messages in thread
From: Lukasz Majewski @ 2021-02-28 22:39 UTC (permalink / raw)
  To: Joseph Myers, Adhemerval Zanella, Florian Weimer, DJ Delorie
  Cc: Paul Eggert, Alistair Francis, Arnd Bergmann, Alistair Francis,
	GNU C Library, Carlos O'Donell, Florian Weimer,
	Zack Weinberg, Lukasz Majewski

This test is a wrapper on tst-clock_adjtime test.
---
 sysdeps/unix/sysv/linux/Makefile       |  2 +-
 sysdeps/unix/sysv/linux/tst-adjtimex.c | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/unix/sysv/linux/tst-adjtimex.c

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index ca3b2f9d40..5c067fd12b 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -112,7 +112,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-rlimit-infinity tst-ofdlocks tst-gettid tst-gettid-kill \
 	 tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux \
 	 tst-timerfd tst-ppoll tst-futimens tst-utime tst-utimes \
-	 tst-clock_adjtime
+	 tst-clock_adjtime tst-adjtimex
 
 tests-y2038 += \
 	 tst-futimens-y2038 \
diff --git a/sysdeps/unix/sysv/linux/tst-adjtimex.c b/sysdeps/unix/sysv/linux/tst-adjtimex.c
new file mode 100644
index 0000000000..c7272a2b84
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-adjtimex.c
@@ -0,0 +1,23 @@
+/* Test for adjtimex.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sys/timex.h>
+#define TST_ADJTIME_SYSCALL adjtimex
+#define TST_ADJTIME_ARGS (&delta)
+
+#include "tst-clock_adjtime.c"
-- 
2.20.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] tst: Add test for ntp_adjtime
  2021-02-28 22:39 [PATCH 1/3] tst: Modify tst-clock_adjtime to allow reuse of its code Lukasz Majewski
  2021-02-28 22:39 ` [PATCH 2/3] tst: Add test for adjtimex Lukasz Majewski
@ 2021-02-28 22:39 ` Lukasz Majewski
  2021-03-02 12:25   ` Adhemerval Zanella
  2021-03-02 12:23 ` [PATCH 1/3] tst: Modify tst-clock_adjtime to allow reuse of its code Adhemerval Zanella
  2 siblings, 1 reply; 7+ messages in thread
From: Lukasz Majewski @ 2021-02-28 22:39 UTC (permalink / raw)
  To: Joseph Myers, Adhemerval Zanella, Florian Weimer, DJ Delorie
  Cc: Paul Eggert, Alistair Francis, Arnd Bergmann, Alistair Francis,
	GNU C Library, Carlos O'Donell, Florian Weimer,
	Zack Weinberg, Lukasz Majewski

This test is a wrapper on tst-clock_adjtime test.
---
 sysdeps/unix/sysv/linux/Makefile          |  2 +-
 sysdeps/unix/sysv/linux/tst-ntp_adjtime.c | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/unix/sysv/linux/tst-ntp_adjtime.c

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 5c067fd12b..57b39dce63 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -112,7 +112,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
 	 tst-rlimit-infinity tst-ofdlocks tst-gettid tst-gettid-kill \
 	 tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux \
 	 tst-timerfd tst-ppoll tst-futimens tst-utime tst-utimes \
-	 tst-clock_adjtime tst-adjtimex
+	 tst-clock_adjtime tst-adjtimex tst-ntp_adjtime
 
 tests-y2038 += \
 	 tst-futimens-y2038 \
diff --git a/sysdeps/unix/sysv/linux/tst-ntp_adjtime.c b/sysdeps/unix/sysv/linux/tst-ntp_adjtime.c
new file mode 100644
index 0000000000..11066048dc
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-ntp_adjtime.c
@@ -0,0 +1,23 @@
+/* Test for ntp_adjtime.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <sys/timex.h>
+#define TST_ADJTIME_SYSCALL ntp_adjtime
+#define TST_ADJTIME_ARGS (&delta)
+
+#include "tst-clock_adjtime.c"
-- 
2.20.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] tst: Modify tst-clock_adjtime to allow reuse of its code
  2021-02-28 22:39 [PATCH 1/3] tst: Modify tst-clock_adjtime to allow reuse of its code Lukasz Majewski
  2021-02-28 22:39 ` [PATCH 2/3] tst: Add test for adjtimex Lukasz Majewski
  2021-02-28 22:39 ` [PATCH 3/3] tst: Add test for ntp_adjtime Lukasz Majewski
@ 2021-03-02 12:23 ` Adhemerval Zanella
  2021-03-02 13:23   ` Lukasz Majewski
  2 siblings, 1 reply; 7+ messages in thread
From: Adhemerval Zanella @ 2021-03-02 12:23 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: GNU C Library



On 28/02/2021 19:39, Lukasz Majewski wrote:
> The tst-clock_adjtime can be adjusted to be reused for also testing
> adjtimex.

LGTM, although below there is a suggestion than simplifies the code a bit.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

> ---
>  sysdeps/unix/sysv/linux/tst-clock_adjtime.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/tst-clock_adjtime.c b/sysdeps/unix/sysv/linux/tst-clock_adjtime.c
> index 6b9bb9940c..84a3f19504 100644
> --- a/sysdeps/unix/sysv/linux/tst-clock_adjtime.c
> +++ b/sysdeps/unix/sysv/linux/tst-clock_adjtime.c
> @@ -22,6 +22,11 @@
>  #include <support/check.h>
>  #include <support/timespec.h>
>  
> +#ifndef TST_ADJTIME_SYSCALL
> +#define TST_ADJTIME_SYSCALL clock_adjtime
> +#define TST_ADJTIME_ARGS (CLOCK_REALTIME, &delta)
> +#endif
> +

It would be simpler to just do:

#ifndef ADJTIME_CALL
# define ADJTIME_CALL(__clock, __timex) clock_adjtime (__clock, __timex)
#endif

and then for adjtimex test define:

#define ADJTIME_CALL(__clock, __timex) adjtimex (__timex)

>  static int
>  do_test (void)
>  {
> @@ -40,7 +45,7 @@ do_test (void)
>    delta.time.tv_usec = 0;
>    delta.modes = ADJ_SETOFFSET;
>  
> -  int ret = clock_adjtime (CLOCK_REALTIME, &delta);
> +  int ret = TST_ADJTIME_SYSCALL TST_ADJTIME_ARGS;
>    if (ret == -1)
>      FAIL_EXIT1 ("clock_adjtime failed: %m\n");
>  
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] tst: Add test for adjtimex
  2021-02-28 22:39 ` [PATCH 2/3] tst: Add test for adjtimex Lukasz Majewski
@ 2021-03-02 12:24   ` Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2021-03-02 12:24 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: GNU C Library



On 28/02/2021 19:39, Lukasz Majewski wrote:
> This test is a wrapper on tst-clock_adjtime test.

LGTM, although with the previous suggestion on first patch on the set 
it should be simpler to define the adjtime call.

> ---
>  sysdeps/unix/sysv/linux/Makefile       |  2 +-
>  sysdeps/unix/sysv/linux/tst-adjtimex.c | 23 +++++++++++++++++++++++
>  2 files changed, 24 insertions(+), 1 deletion(-)
>  create mode 100644 sysdeps/unix/sysv/linux/tst-adjtimex.c
> 
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index ca3b2f9d40..5c067fd12b 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -112,7 +112,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
>  	 tst-rlimit-infinity tst-ofdlocks tst-gettid tst-gettid-kill \
>  	 tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux \
>  	 tst-timerfd tst-ppoll tst-futimens tst-utime tst-utimes \
> -	 tst-clock_adjtime
> +	 tst-clock_adjtime tst-adjtimex
>  
>  tests-y2038 += \
>  	 tst-futimens-y2038 \

Ok.

> diff --git a/sysdeps/unix/sysv/linux/tst-adjtimex.c b/sysdeps/unix/sysv/linux/tst-adjtimex.c
> new file mode 100644
> index 0000000000..c7272a2b84
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/tst-adjtimex.c
> @@ -0,0 +1,23 @@
> +/* Test for adjtimex.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sys/timex.h>
> +#define TST_ADJTIME_SYSCALL adjtimex
> +#define TST_ADJTIME_ARGS (&delta)
> +
> +#include "tst-clock_adjtime.c"
> 

Ok.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] tst: Add test for ntp_adjtime
  2021-02-28 22:39 ` [PATCH 3/3] tst: Add test for ntp_adjtime Lukasz Majewski
@ 2021-03-02 12:25   ` Adhemerval Zanella
  0 siblings, 0 replies; 7+ messages in thread
From: Adhemerval Zanella @ 2021-03-02 12:25 UTC (permalink / raw)
  To: Lukasz Majewski; +Cc: GNU C Library



On 28/02/2021 19:39, Lukasz Majewski wrote:
> This test is a wrapper on tst-clock_adjtime test.

LGTM, although the simplification also applies here.

> ---
>  sysdeps/unix/sysv/linux/Makefile          |  2 +-
>  sysdeps/unix/sysv/linux/tst-ntp_adjtime.c | 23 +++++++++++++++++++++++
>  2 files changed, 24 insertions(+), 1 deletion(-)
>  create mode 100644 sysdeps/unix/sysv/linux/tst-ntp_adjtime.c
> 
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index 5c067fd12b..57b39dce63 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -112,7 +112,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
>  	 tst-rlimit-infinity tst-ofdlocks tst-gettid tst-gettid-kill \
>  	 tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux \
>  	 tst-timerfd tst-ppoll tst-futimens tst-utime tst-utimes \
> -	 tst-clock_adjtime tst-adjtimex
> +	 tst-clock_adjtime tst-adjtimex tst-ntp_adjtime
>  
>  tests-y2038 += \
>  	 tst-futimens-y2038 \

Ok.

> diff --git a/sysdeps/unix/sysv/linux/tst-ntp_adjtime.c b/sysdeps/unix/sysv/linux/tst-ntp_adjtime.c
> new file mode 100644
> index 0000000000..11066048dc
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/tst-ntp_adjtime.c
> @@ -0,0 +1,23 @@
> +/* Test for ntp_adjtime.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <sys/timex.h>
> +#define TST_ADJTIME_SYSCALL ntp_adjtime
> +#define TST_ADJTIME_ARGS (&delta)
> +
> +#include "tst-clock_adjtime.c"
> 

OK.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] tst: Modify tst-clock_adjtime to allow reuse of its code
  2021-03-02 12:23 ` [PATCH 1/3] tst: Modify tst-clock_adjtime to allow reuse of its code Adhemerval Zanella
@ 2021-03-02 13:23   ` Lukasz Majewski
  0 siblings, 0 replies; 7+ messages in thread
From: Lukasz Majewski @ 2021-03-02 13:23 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GNU C Library

[-- Attachment #1: Type: text/plain, Size: 1917 bytes --]

Hi Adhemerval,

> On 28/02/2021 19:39, Lukasz Majewski wrote:
> > The tst-clock_adjtime can be adjusted to be reused for also testing
> > adjtimex.  
> 
> LGTM, although below there is a suggestion than simplifies the code a
> bit.
> 
> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> 
> > ---
> >  sysdeps/unix/sysv/linux/tst-clock_adjtime.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/sysdeps/unix/sysv/linux/tst-clock_adjtime.c
> > b/sysdeps/unix/sysv/linux/tst-clock_adjtime.c index
> > 6b9bb9940c..84a3f19504 100644 ---
> > a/sysdeps/unix/sysv/linux/tst-clock_adjtime.c +++
> > b/sysdeps/unix/sysv/linux/tst-clock_adjtime.c @@ -22,6 +22,11 @@
> >  #include <support/check.h>
> >  #include <support/timespec.h>
> >  
> > +#ifndef TST_ADJTIME_SYSCALL
> > +#define TST_ADJTIME_SYSCALL clock_adjtime
> > +#define TST_ADJTIME_ARGS (CLOCK_REALTIME, &delta)
> > +#endif
> > +  
> 
> It would be simpler to just do:
> 
> #ifndef ADJTIME_CALL
> # define ADJTIME_CALL(__clock, __timex) clock_adjtime (__clock,
> __timex) #endif
> 
> and then for adjtimex test define:
> 
> #define ADJTIME_CALL(__clock, __timex) adjtimex (__timex)
> 

Yes, this approach is far more clear. I will use it.

> >  static int
> >  do_test (void)
> >  {
> > @@ -40,7 +45,7 @@ do_test (void)
> >    delta.time.tv_usec = 0;
> >    delta.modes = ADJ_SETOFFSET;
> >  
> > -  int ret = clock_adjtime (CLOCK_REALTIME, &delta);
> > +  int ret = TST_ADJTIME_SYSCALL TST_ADJTIME_ARGS;
> >    if (ret == -1)
> >      FAIL_EXIT1 ("clock_adjtime failed: %m\n");
> >  
> >   




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-02 13:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-28 22:39 [PATCH 1/3] tst: Modify tst-clock_adjtime to allow reuse of its code Lukasz Majewski
2021-02-28 22:39 ` [PATCH 2/3] tst: Add test for adjtimex Lukasz Majewski
2021-03-02 12:24   ` Adhemerval Zanella
2021-02-28 22:39 ` [PATCH 3/3] tst: Add test for ntp_adjtime Lukasz Majewski
2021-03-02 12:25   ` Adhemerval Zanella
2021-03-02 12:23 ` [PATCH 1/3] tst: Modify tst-clock_adjtime to allow reuse of its code Adhemerval Zanella
2021-03-02 13:23   ` Lukasz Majewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).