From be8d1d7d99e79445b44ce72e732ba27a4e8642ab Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Thu, 15 Dec 2022 21:08:21 -0600 Subject: [PATCH] Move infrastructure for failure tracking to common "mock" tool init file --- testsuite/lib/mock.exp | 22 ++++++++++++++++++++++ testsuite/mock.gpgv/sign.exp | 17 +++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/testsuite/lib/mock.exp b/testsuite/lib/mock.exp index 223faea..2db0b79 100644 --- a/testsuite/lib/mock.exp +++ b/testsuite/lib/mock.exp @@ -29,6 +29,28 @@ set ::env(GNUPGHOME) $GNUPGHOME load_lib mockgpg.exp +# invoked by DejaGnu framework when a failure is recorded +proc mock_count_failures { args } { + global mock_total_failure_count mock_local_failure_count + incr mock_total_failure_count + incr mock_local_failure_count +} +set local_record_procs(fail) mock_count_failures +set mock_total_failure_count 0 +set mock_local_failure_count 0 +proc mock_total_failures {} { + global mock_total_failure_count + return $mock_total_failure_count +} +proc mock_local_failures {} { + global mock_local_failure_count + return $mock_local_failure_count +} +proc mock_reset_local_failures {} { + global mock_local_failure_count + set mock_local_failure_count 0 +} + proc put_file { file string } { set chan [open $file w] puts -nonewline $chan $string diff --git a/testsuite/mock.gpgv/sign.exp b/testsuite/mock.gpgv/sign.exp index d1340ff..607b0fe 100644 --- a/testsuite/mock.gpgv/sign.exp +++ b/testsuite/mock.gpgv/sign.exp @@ -58,16 +58,6 @@ proc spawn_gpgv { keyrings args } { eval $cmd $args } -# invoked by DejaGnu framework when a failure is recorded -proc gpgv_count_failures {args } { - global gpgv_total_failure_count gpgv_local_failure_count - incr gpgv_total_failure_count - incr gpgv_local_failure_count -} -set local_record_procs(fail) gpgv_count_failures -set gpgv_total_failure_count 0 -set gpgv_local_failure_count 0 - # InitialCapital variable names may be used in the $expect block. # The "test_dir" variable is also set for the $init block. proc run_gpgv_test { Name stem keyrings exitCode init phases assess expect } { @@ -75,8 +65,7 @@ proc run_gpgv_test { Name stem keyrings exitCode init phases assess expect } { [file dirname [testsuite file -object -top]] test.tmp] file mkdir $test_dir - global gpgv_local_failure_count - set gpgv_local_failure_count 0 + mock_reset_local_failures eval $init @@ -128,7 +117,7 @@ proc run_gpgv_test { Name stem keyrings exitCode init phases assess expect } { } } - if { $gpgv_local_failure_count == 0 } { + if { [mock_local_failures] == 0 } { foreach scratchfile [list "${stem}" "${stem}.asc" "${stem}.sig"] { file delete -- [file join $test_dir $scratchfile] } @@ -761,7 +750,7 @@ do_gpgv_test "expired signature from expired subkey" t9b {dgS2.gpg} 0 \ # -if { $gpgv_total_failure_count == 0 } { +if { [mock_total_failures] == 0 } { file delete -force $GNUPGHOME } -- 2.25.1