All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] testsuite/xeno-test: Restore timesyncd running state on smokey failure
@ 2021-10-21 11:55 Florian Bezdeka
  2021-10-21 12:15 ` Jan Kiszka
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Bezdeka @ 2021-10-21 11:55 UTC (permalink / raw)
  To: xenomai

We stop systemd-timesyncd before running the smokey testsuite and start
it again once the smokey tests are complete. As xeno-test has a "set -e"
we will stop the execution on the first error. So if smokey reports an
error systemd-timesyncd is not started again. We don't properly restore
the system state in this case.

Install a bash trap to make sure that we restart the service in all
cases if it was running on script entry.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 testsuite/xeno-test/xeno-test.in | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/testsuite/xeno-test/xeno-test.in b/testsuite/xeno-test/xeno-test.in
index 95bf59606..cfa28df18 100644
--- a/testsuite/xeno-test/xeno-test.in
+++ b/testsuite/xeno-test/xeno-test.in
@@ -39,9 +39,19 @@ timer irq latency.
 EOF
 }
 
+start_timesyncd()
+{
+    if $timesyncd_was_running; then
+        systemctl start systemd-timesyncd
+        timesyncd_was_running=false
+    fi
+}
+trap start_timesyncd EXIT
+
 keep_going=
 run_on_vm=
 rt_load=false
+timesyncd_was_running=false
 
 while :; do
     case "$1" in
@@ -82,17 +92,14 @@ echo 0 > /proc/xenomai/latency || :
 
 testdir=@testdir@
 
-timesyncd_running=false
 if which systemctl > /dev/null && systemctl is-active --quiet systemd-timesyncd; then
-    timesyncd_running=true
+    timesyncd_was_running=true
     systemctl stop systemd-timesyncd
 fi
 
 $testdir/smokey --run $run_on_vm $keep_going random_alloc_rounds=64 pattern_check_rounds=64
 
-if $timesyncd_running; then
-    systemctl start systemd-timesyncd
-fi
+start_timesyncd
 
 $testdir/clocktest -D -T 30 -C CLOCK_HOST_REALTIME || $testdir/clocktest -T 30
 $testdir/switchtest -T 30
-- 
2.31.1



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

* Re: [PATCH] testsuite/xeno-test: Restore timesyncd running state on smokey failure
  2021-10-21 11:55 [PATCH] testsuite/xeno-test: Restore timesyncd running state on smokey failure Florian Bezdeka
@ 2021-10-21 12:15 ` Jan Kiszka
  2021-10-21 12:18   ` Bezdeka, Florian
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2021-10-21 12:15 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai

On 21.10.21 13:55, Florian Bezdeka wrote:
> We stop systemd-timesyncd before running the smokey testsuite and start
> it again once the smokey tests are complete. As xeno-test has a "set -e"
> we will stop the execution on the first error. So if smokey reports an
> error systemd-timesyncd is not started again. We don't properly restore
> the system state in this case.
> 
> Install a bash trap to make sure that we restart the service in all
> cases if it was running on script entry.
> 
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
>  testsuite/xeno-test/xeno-test.in | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/testsuite/xeno-test/xeno-test.in b/testsuite/xeno-test/xeno-test.in
> index 95bf59606..cfa28df18 100644
> --- a/testsuite/xeno-test/xeno-test.in
> +++ b/testsuite/xeno-test/xeno-test.in
> @@ -39,9 +39,19 @@ timer irq latency.
>  EOF
>  }
>  
> +start_timesyncd()
> +{
> +    if $timesyncd_was_running; then
> +        systemctl start systemd-timesyncd
> +        timesyncd_was_running=false
> +    fi

Plus "trap - EXIT" here? Or at least after explicit start_timesyncd below.

Jan

> +}
> +trap start_timesyncd EXIT
> +
>  keep_going=
>  run_on_vm=
>  rt_load=false
> +timesyncd_was_running=false
>  
>  while :; do
>      case "$1" in
> @@ -82,17 +92,14 @@ echo 0 > /proc/xenomai/latency || :
>  
>  testdir=@testdir@
>  
> -timesyncd_running=false
>  if which systemctl > /dev/null && systemctl is-active --quiet systemd-timesyncd; then
> -    timesyncd_running=true
> +    timesyncd_was_running=true
>      systemctl stop systemd-timesyncd
>  fi
>  
>  $testdir/smokey --run $run_on_vm $keep_going random_alloc_rounds=64 pattern_check_rounds=64
>  
> -if $timesyncd_running; then
> -    systemctl start systemd-timesyncd
> -fi
> +start_timesyncd
>  
>  $testdir/clocktest -D -T 30 -C CLOCK_HOST_REALTIME || $testdir/clocktest -T 30
>  $testdir/switchtest -T 30
> 

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


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

* Re: [PATCH] testsuite/xeno-test: Restore timesyncd running state on smokey failure
  2021-10-21 12:15 ` Jan Kiszka
@ 2021-10-21 12:18   ` Bezdeka, Florian
  2021-10-21 16:38     ` Jan Kiszka
  0 siblings, 1 reply; 4+ messages in thread
From: Bezdeka, Florian @ 2021-10-21 12:18 UTC (permalink / raw)
  To: xenomai, jan.kiszka

On Thu, 2021-10-21 at 14:15 +0200, Jan Kiszka wrote:
> On 21.10.21 13:55, Florian Bezdeka wrote:
> > We stop systemd-timesyncd before running the smokey testsuite and start
> > it again once the smokey tests are complete. As xeno-test has a "set -e"
> > we will stop the execution on the first error. So if smokey reports an
> > error systemd-timesyncd is not started again. We don't properly restore
> > the system state in this case.
> > 
> > Install a bash trap to make sure that we restart the service in all
> > cases if it was running on script entry.
> > 
> > Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> > ---
> >  testsuite/xeno-test/xeno-test.in | 17 ++++++++++++-----
> >  1 file changed, 12 insertions(+), 5 deletions(-)
> > 
> > diff --git a/testsuite/xeno-test/xeno-test.in b/testsuite/xeno-test/xeno-test.in
> > index 95bf59606..cfa28df18 100644
> > --- a/testsuite/xeno-test/xeno-test.in
> > +++ b/testsuite/xeno-test/xeno-test.in
> > @@ -39,9 +39,19 @@ timer irq latency.
> >  EOF
> >  }
> >  
> > +start_timesyncd()
> > +{
> > +    if $timesyncd_was_running; then
> > +        systemctl start systemd-timesyncd
> > +        timesyncd_was_running=false
> > +    fi
> 
> Plus "trap - EXIT" here? Or at least after explicit start_timesyncd below.

We set timesyncd_was_running to false once the service has been
started. So even if called twice (on test suite success) everything is
fine. Even if called twice, starting an already running service is a
NOOP.

> 
> Jan
> 
> > +}
> > +trap start_timesyncd EXIT
> > +
> >  keep_going=
> >  run_on_vm=
> >  rt_load=false
> > +timesyncd_was_running=false
> >  
> >  while :; do
> >      case "$1" in
> > @@ -82,17 +92,14 @@ echo 0 > /proc/xenomai/latency || :
> >  
> >  testdir=@testdir@
> >  
> > -timesyncd_running=false
> >  if which systemctl > /dev/null && systemctl is-active --quiet systemd-timesyncd; then
> > -    timesyncd_running=true
> > +    timesyncd_was_running=true
> >      systemctl stop systemd-timesyncd
> >  fi
> >  
> >  $testdir/smokey --run $run_on_vm $keep_going random_alloc_rounds=64 pattern_check_rounds=64
> >  
> > -if $timesyncd_running; then
> > -    systemctl start systemd-timesyncd
> > -fi
> > +start_timesyncd
> >  
> >  $testdir/clocktest -D -T 30 -C CLOCK_HOST_REALTIME || $testdir/clocktest -T 30
> >  $testdir/switchtest -T 30
> > 
> 


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

* Re: [PATCH] testsuite/xeno-test: Restore timesyncd running state on smokey failure
  2021-10-21 12:18   ` Bezdeka, Florian
@ 2021-10-21 16:38     ` Jan Kiszka
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2021-10-21 16:38 UTC (permalink / raw)
  To: Bezdeka, Florian (T RDA IOT SES-DE), xenomai

On 21.10.21 14:18, Bezdeka, Florian (T RDA IOT SES-DE) wrote:
> On Thu, 2021-10-21 at 14:15 +0200, Jan Kiszka wrote:
>> On 21.10.21 13:55, Florian Bezdeka wrote:
>>> We stop systemd-timesyncd before running the smokey testsuite and start
>>> it again once the smokey tests are complete. As xeno-test has a "set -e"
>>> we will stop the execution on the first error. So if smokey reports an
>>> error systemd-timesyncd is not started again. We don't properly restore
>>> the system state in this case.
>>>
>>> Install a bash trap to make sure that we restart the service in all
>>> cases if it was running on script entry.
>>>
>>> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
>>> ---
>>>  testsuite/xeno-test/xeno-test.in | 17 ++++++++++++-----
>>>  1 file changed, 12 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/testsuite/xeno-test/xeno-test.in b/testsuite/xeno-test/xeno-test.in
>>> index 95bf59606..cfa28df18 100644
>>> --- a/testsuite/xeno-test/xeno-test.in
>>> +++ b/testsuite/xeno-test/xeno-test.in
>>> @@ -39,9 +39,19 @@ timer irq latency.
>>>  EOF
>>>  }
>>>
>>> +start_timesyncd()
>>> +{
>>> +    if $timesyncd_was_running; then
>>> +        systemctl start systemd-timesyncd
>>> +        timesyncd_was_running=false
>>> +    fi
>>
>> Plus "trap - EXIT" here? Or at least after explicit start_timesyncd below.
> 
> We set timesyncd_was_running to false once the service has been
> started. So even if called twice (on test suite success) everything is
> fine. Even if called twice, starting an already running service is a
> NOOP.
> 

OK - applied.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


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

end of thread, other threads:[~2021-10-21 16:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 11:55 [PATCH] testsuite/xeno-test: Restore timesyncd running state on smokey failure Florian Bezdeka
2021-10-21 12:15 ` Jan Kiszka
2021-10-21 12:18   ` Bezdeka, Florian
2021-10-21 16:38     ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.