diff mbox series

[1/3] tst: Modify tst-clock_adjtime to allow reuse of its code

Message ID 20210228223938.8304-1-lukma@denx.de
State Committed
Delegated to: Adhemerval Zanella Netto
Headers show
Series [1/3] tst: Modify tst-clock_adjtime to allow reuse of its code | expand

Commit Message

Lukasz Majewski Feb. 28, 2021, 10:39 p.m. UTC
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(-)

Comments

Adhemerval Zanella March 2, 2021, 12:23 p.m. UTC | #1
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");
>  
>
Lukasz Majewski March 2, 2021, 1:23 p.m. UTC | #2
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
diff mbox series

Patch

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");