[1/4] time/tst-clock2.c: clock_settime CLOCK_MONOTONIC might return EPERM

Message ID 20220626205915.33201-2-mark@klomp.org
State Superseded
Headers
Series [1/4] time/tst-clock2.c: clock_settime CLOCK_MONOTONIC might return EPERM |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Mark Wielaard June 26, 2022, 8:59 p.m. UTC
  clock_settime can return errno EPERM if it does not have permission
to set the clock indicated. The test expects setting the monotonic
clock must fail. Which it does. But the errno can be either EINVAL
or EPERM.
---
 time/tst-clock2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Florian Weimer June 26, 2022, 9:15 p.m. UTC | #1
* Mark Wielaard:

> clock_settime can return errno EPERM if it does not have permission
> to set the clock indicated. The test expects setting the monotonic
> clock must fail. Which it does. But the errno can be either EINVAL
> or EPERM.
> ---
>  time/tst-clock2.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/time/tst-clock2.c b/time/tst-clock2.c
> index 4c8fb9f247..3f46220832 100644
> --- a/time/tst-clock2.c
> +++ b/time/tst-clock2.c
> @@ -27,10 +27,10 @@ do_test (void)
>        puts ("clock_settime(CLOCK_MONOTONIC) did not fail");
>        return 1;
>      }
> -  if (errno != EINVAL)
> +  if (errno != EINVAL && errno != EPERM)
>      {
> -      printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d, expected %d\n",
> -	      errno, EINVAL);
> +      printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d, expected %d or %d\n",
> +	      errno, EINVAL, EPERM);
>        return 1;
>      }
>    return 0;

You could use "errno to %d (%#m)" if you are changing this line anyway.
And isn't the line too long?

Direction looks okay to me.
  
Mark Wielaard June 27, 2022, 9:35 a.m. UTC | #2
Hi Florian,

On Sun, 2022-06-26 at 23:15 +0200, Florian Weimer wrote:
> * Mark Wielaard:
> > -      printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d,
> > expected %d\n",
> > -	      errno, EINVAL);
> > +      printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d,
> > expected %d or %d\n",
> > +	      errno, EINVAL, EPERM);
> >        return 1;
> >      }
> >    return 0;
> 
> You could use "errno to %d (%#m)" if you are changing this line
> anyway.
> And isn't the line too long?
> 
> Direction looks okay to me.

Yes, the line is too long. Sorry, my terminal window was too wide. Will
fix and add (%#m) in v2.

Thanks,

Mark
  

Patch

diff --git a/time/tst-clock2.c b/time/tst-clock2.c
index 4c8fb9f247..3f46220832 100644
--- a/time/tst-clock2.c
+++ b/time/tst-clock2.c
@@ -27,10 +27,10 @@  do_test (void)
       puts ("clock_settime(CLOCK_MONOTONIC) did not fail");
       return 1;
     }
-  if (errno != EINVAL)
+  if (errno != EINVAL && errno != EPERM)
     {
-      printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d, expected %d\n",
-	      errno, EINVAL);
+      printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d, expected %d or %d\n",
+	      errno, EINVAL, EPERM);
       return 1;
     }
   return 0;