diff mbox series

[3/3] check: ensure sect_stop is initialized if interrupted

Message ID 20221212230820.3466-3-ddiss@suse.de (mailing list archive)
State New, archived
Headers show
Series [1/3] common/attr: require xfs_spaceman for xfs acl_get_max | expand

Commit Message

David Disseldorp Dec. 12, 2022, 11:08 p.m. UTC
sect_stop is normally set immediately prior to calling _wrapup() via
run_section(). However, when called via a trap signal handler,
sect_stop may be uninitialized, leading to a negative section time
(sect_stop - sect_start) in the xunit report. E.g.
  Interrupted!
  Passed all 1 tests
  Xunit report: /home/david/xfstests/results//result.xml
  rapido1:/# head /home/david/xfstests/results//result.xml
  <?xml version="1.0" encoding="UTF-8"?>
  <testsuite name="xfstests" failures="0" skipped="0" tests="1"
   time="-1670885797" ... >

This commit uses the existing $interrupt flag to determine when
sect_stop needs to be initialised.

Signed-off-by: David Disseldorp <ddiss@suse.de>
---
 check | 1 +
 1 file changed, 1 insertion(+)

Comments

Zorro Lang Dec. 13, 2022, 2:51 p.m. UTC | #1
On Tue, Dec 13, 2022 at 12:08:20AM +0100, David Disseldorp wrote:
> sect_stop is normally set immediately prior to calling _wrapup() via
> run_section(). However, when called via a trap signal handler,
> sect_stop may be uninitialized, leading to a negative section time
> (sect_stop - sect_start) in the xunit report. E.g.
>   Interrupted!
>   Passed all 1 tests
>   Xunit report: /home/david/xfstests/results//result.xml
>   rapido1:/# head /home/david/xfstests/results//result.xml
>   <?xml version="1.0" encoding="UTF-8"?>
>   <testsuite name="xfstests" failures="0" skipped="0" tests="1"
>    time="-1670885797" ... >
> 
> This commit uses the existing $interrupt flag to determine when
> sect_stop needs to be initialised.
> 
> Signed-off-by: David Disseldorp <ddiss@suse.de>
> ---

I don't use Xunit report generally, but this change makes sense to me.

Reviewed-by: Zorro Lang <zlang@redhat.com>

>  check | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/check b/check
> index d2e51296..cb3ea155 100755
> --- a/check
> +++ b/check
> @@ -433,6 +433,7 @@ _wrapup()
>  {
>  	seq="check"
>  	check="$RESULT_BASE/check"
> +	$interrupt && sect_stop=`_wallclock`
>  
>  	if $showme && $needwrap; then
>  		if $do_report; then
> -- 
> 2.35.3
>
diff mbox series

Patch

diff --git a/check b/check
index d2e51296..cb3ea155 100755
--- a/check
+++ b/check
@@ -433,6 +433,7 @@  _wrapup()
 {
 	seq="check"
 	check="$RESULT_BASE/check"
+	$interrupt && sect_stop=`_wallclock`
 
 	if $showme && $needwrap; then
 		if $do_report; then