From: Jacob Bachmeyer Date: Mon, 19 Sep 2022 23:38:56 +0000 (-0500) Subject: Clean up scratchpad files in mock tool testsuite X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=30349455562da678f4b82a4e23e444b44ef69db9;p=gatekeeper.git Clean up scratchpad files in mock tool testsuite --- diff --git a/testsuite/lib/mock.exp b/testsuite/lib/mock.exp index da21208..9248d45 100644 --- a/testsuite/lib/mock.exp +++ b/testsuite/lib/mock.exp @@ -1,6 +1,6 @@ # DejaGnu tool init file for testing gpgv mock tests -# Copyright (C) 2021 Jacob Bachmeyer +# Copyright (C) 2021, 2022 Jacob Bachmeyer # # This file is part of a testsuite for the GNU FTP upload system. # @@ -21,9 +21,10 @@ set MINLOGD [testsuite file -source -top lib exec minlogd.pl] set MINSMTPD [testsuite file -source -top lib exec minsmtpd.tcl] set MOCKGPGV [testsuite file -source -top lib exec mockgpgv] -set ::env(GNUPGHOME) [file join \ - [file dirname [testsuite file -object -top]] \ - test.tmp gpgv] +set GNUPGHOME [file join \ + [file dirname [testsuite file -object -top]] \ + test.tmp gpgv] +set ::env(GNUPGHOME) $GNUPGHOME load_lib mockgpg.exp @@ -33,7 +34,11 @@ proc put_file { file string } { close $chan } -proc mock_exit {} {} +proc mock_exit {} { + catch {file delete [file join \ + [file dirname [testsuite file -object -top]] \ + test.tmp]} +} proc mock_version {} {} # The mock tools do not have independent versions. diff --git a/testsuite/mock.gpgv/sign.exp b/testsuite/mock.gpgv/sign.exp index 5f8208f..4e5f1cb 100644 --- a/testsuite/mock.gpgv/sign.exp +++ b/testsuite/mock.gpgv/sign.exp @@ -1,6 +1,6 @@ # Signature "verification" tests for GPG mock -# Copyright (C) 2021 Jacob Bachmeyer +# Copyright (C) 2021, 2022 Jacob Bachmeyer # # This file is part of a testsuite for the GNU FTP upload system. # @@ -17,9 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -file mkdir $::env(GNUPGHOME) +file mkdir $GNUPGHOME -write_test_keyring [file join $::env(GNUPGHOME) dg1.gpg] { +write_test_keyring [file join $GNUPGHOME dg1.gpg] { { id 1001 name {test 1-1} } { id 1002 name {test 1-2} } { id 1003 name {test 1-3} expires {+5 minutes} } @@ -29,7 +29,7 @@ write_test_keyring [file join $::env(GNUPGHOME) dg1.gpg] { is revoked expired {5 minutes ago} } } -write_test_keyring [file join $::env(GNUPGHOME) dg2.gpg] { +write_test_keyring [file join $GNUPGHOME dg2.gpg] { { id 1011 name {test 2-1 (primary)} } { id 1012 name {test 2-2 (subkey)} subkey-of 1011 } { id 1013 name {test 2-3 (subkey)} subkey-of 1011 expires {+5 minutes} } @@ -58,6 +58,16 @@ 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 } { @@ -65,6 +75,9 @@ 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 + eval $init array set A {} @@ -114,6 +127,12 @@ proc run_gpgv_test { Name stem keyrings exitCode init phases assess expect } { } } } + + if { $gpgv_local_failure_count == 0 } { + foreach scratchfile [list "${stem}" "${stem}.asc" "${stem}.sig"] { + file delete -- [file join $test_dir $scratchfile] + } + } } proc do_gpgv_test { Name stem keyrings exitCode signature assess expect } { run_gpgv_test $Name $stem $keyrings $exitCode \ @@ -739,3 +758,11 @@ do_gpgv_test "expired signature from expired subkey" t9b {dg2.gpg} 0 \ exp_continue } } + +# + +if { $gpgv_total_failure_count == 0 } { + file delete -force $GNUPGHOME +} + +#EOF