Skip to contentSkip to conversation

testsuite/xeno-test: Restore timesyncd running state on smokey failure

PATCH In review Florian Bezdeka 2 participants 4 messages Oct 21, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 testsuite/xeno-test: Restore timesyncd running state on smokey failure

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.

---
 testsuite/xeno-test/xeno-test.in | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
testsuite/xeno-test/xeno-test.in +12 -5
index 95bf59606..cfa28df18 100644
@@ -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
Signature · 1 line
2.31.1
#1 lore raw
Quoted 19 lines · Florian Bezdeka

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.

---
 testsuite/xeno-test/xeno-test.in | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
testsuite/xeno-test/xeno-test.in +0 -0
index 95bf59606..cfa28df18 100644

testsuite/xeno-test/xeno-test.in timer irq latency. · line 47

Quoted 9 lines
testsuite/xeno-test/xeno-test.in +6 -0
@@ -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

Quoted 31 lines
testsuite/xeno-test/xeno-test.in +6 -5
+}
+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
Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#2 lore raw
Quoted 23 lines · Jan Kiszka
Quoted 22 lines · Florian Bezdeka

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.

---
 testsuite/xeno-test/xeno-test.in | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
testsuite/xeno-test/xeno-test.in +0 -0
index 95bf59606..cfa28df18 100644
@@ -39,9 +39,19 @@ timer irq latency.
 EOF
 }
 
Quoted 8 lines

testsuite/xeno-test/xeno-test.in timer irq latency. · line 47

Quoted 6 lines
testsuite/xeno-test/xeno-test.in +6 -0
+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.

Quoted 35 lines

Jan

Quoted 31 lines
testsuite/xeno-test/xeno-test.in +6 -5
+}
+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
#3 lore raw
Quoted 33 lines · Florian (T RDA IOT SES-DE)
Quoted 23 lines · Jan Kiszka
Quoted 22 lines · Florian Bezdeka

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.

---
 testsuite/xeno-test/xeno-test.in | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
testsuite/xeno-test/xeno-test.in +0 -0
index 95bf59606..cfa28df18 100644
@@ -39,9 +39,19 @@ timer irq latency.
 EOF
 }
 
Quoted 8 lines

testsuite/xeno-test/xeno-test.in timer irq latency. · line 47

Quoted 6 lines
testsuite/xeno-test/xeno-test.in +6 -0
+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.

Quoted 5 lines

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

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux