summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2014-07-11 18:56:33 -0700
committerRuss Allbery <rra@stanford.edu>2014-07-11 19:03:34 -0700
commit02a629dcc319e418b2f4185acb5bfb22bc86b3eb (patch)
treee4cb07e929c06f6ea1bdc654713f1c13b108b5eb
parentcc9bb004ad8bc00b5685021848eeb1c0b6bd1f51 (diff)
Fix test cleanup code to run during global destruction
If we don't run the code to delete the wallet database very late, destruction of the SQLite objects may recreate the database file. Move the unlink to an END block to avoid this problem. Change-Id: Ib5ec2cbd08ba24c99f3dfa1daa01488931c5958f Reviewed-on: https://gerrit.stanford.edu/1525 Reviewed-by: Russ Allbery <rra@stanford.edu> Tested-by: Russ Allbery <rra@stanford.edu>
-rwxr-xr-xperl/t/acl.t4
-rwxr-xr-xperl/t/admin.t4
-rwxr-xr-xperl/t/duo.t6
-rwxr-xr-xperl/t/file.t6
-rwxr-xr-xperl/t/init.t6
-rwxr-xr-xperl/t/keytab.t4
-rwxr-xr-xperl/t/object.t6
-rwxr-xr-xperl/t/report.t6
-rwxr-xr-xperl/t/server.t4
-rwxr-xr-xperl/t/stanford-naming.t6
-rwxr-xr-xperl/t/wa-keyring.t6
-rw-r--r--tests/client/full-t.in8
12 files changed, 45 insertions, 21 deletions
diff --git a/perl/t/acl.t b/perl/t/acl.t
index 7f82259..e633f46 100755
--- a/perl/t/acl.t
+++ b/perl/t/acl.t
@@ -227,4 +227,6 @@ like ($acl->id, qr{\A[23]\z}, ' and an ID of 2 or 3');
# Clean up.
$setup->destroy;
-unlink 'wallet-db';
+END {
+ unlink 'wallet-db';
+}
diff --git a/perl/t/admin.t b/perl/t/admin.t
index 1bcb85e..41bc33a 100755
--- a/perl/t/admin.t
+++ b/perl/t/admin.t
@@ -101,4 +101,6 @@ SKIP: {
# Clean up.
is ($admin->destroy, 1, 'Destruction succeeds');
-unlink 'wallet-db';
+END {
+ unlink 'wallet-db';
+}
diff --git a/perl/t/duo.t b/perl/t/duo.t
index 12fee3a..4229afe 100755
--- a/perl/t/duo.t
+++ b/perl/t/duo.t
@@ -149,9 +149,9 @@ TODO: {
# Clean up.
$admin->destroy;
-undef $admin;
-undef $object;
-unlink ('wallet-db');
+END {
+ unlink ('wallet-db');
+}
# Done testing.
done_testing ();
diff --git a/perl/t/file.t b/perl/t/file.t
index ac35c44..0aecd9d 100755
--- a/perl/t/file.t
+++ b/perl/t/file.t
@@ -3,7 +3,7 @@
# Tests for the file object implementation.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2008
+# Copyright 2008, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -145,4 +145,6 @@ is ($object->destroy (@trace), 1, ' but destroying the object succeeds');
# Clean up.
$admin->destroy;
-unlink ('wallet-db');
+END {
+ unlink ('wallet-db');
+}
diff --git a/perl/t/init.t b/perl/t/init.t
index 189a689..b8ec3c9 100755
--- a/perl/t/init.t
+++ b/perl/t/init.t
@@ -3,7 +3,7 @@
# Tests for database initialization.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2007, 2008
+# Copyright 2007, 2008, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -53,4 +53,6 @@ is ($admin->destroy, 1, 'Destroying the database works');
$acl = eval { Wallet::ACL->new ('ADMIN', $admin->schema) };
like ($@, qr/^cannot search for ACL ADMIN: /,
' and now the database is gone');
-unlink 'wallet-db';
+END {
+ unlink 'wallet-db';
+}
diff --git a/perl/t/keytab.t b/perl/t/keytab.t
index 467d1b3..127762a 100755
--- a/perl/t/keytab.t
+++ b/perl/t/keytab.t
@@ -766,4 +766,6 @@ EOO
# Clean up.
$admin->destroy;
-unlink ('wallet-db', 'krb5cc_temp', 'krb5cc_test', 'test-acl', 'test-pid');
+END {
+ unlink ('wallet-db', 'krb5cc_temp', 'krb5cc_test', 'test-acl', 'test-pid');
+}
diff --git a/perl/t/object.t b/perl/t/object.t
index 12443bc..0432a23 100755
--- a/perl/t/object.t
+++ b/perl/t/object.t
@@ -3,7 +3,7 @@
# Tests for the basic object implementation.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2007, 2008, 2011
+# Copyright 2007, 2008, 2011, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -348,4 +348,6 @@ is ($object->history, $output, ' and the history is correct');
# Clean up.
$admin->destroy;
-unlink 'wallet-db';
+END {
+ unlink 'wallet-db';
+}
diff --git a/perl/t/report.t b/perl/t/report.t
index 4ea9628..9563362 100755
--- a/perl/t/report.t
+++ b/perl/t/report.t
@@ -3,7 +3,7 @@
# Tests for the wallet reporting interface.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2008, 2009, 2010
+# Copyright 2008, 2009, 2010, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -324,5 +324,7 @@ is ($report->error, undef, ' and no error');
# Clean up.
$admin->destroy;
-unlink 'wallet-db';
system ('rm -r test-files') == 0 or die "cannot remove test-files\n";
+END {
+ unlink 'wallet-db';
+}
diff --git a/perl/t/server.t b/perl/t/server.t
index 0ebdacc..9026439 100755
--- a/perl/t/server.t
+++ b/perl/t/server.t
@@ -1020,7 +1020,9 @@ is ($server->acl_destroy ('test-naming'), 1, 'Destroying it succeeds');
# Clean up.
$setup->destroy;
-unlink 'wallet-db';
+END {
+ unlink 'wallet-db';
+}
# Now test handling of some configuration errors.
undef $Wallet::Config::DB_DRIVER;
diff --git a/perl/t/stanford-naming.t b/perl/t/stanford-naming.t
index c512ad0..555086c 100755
--- a/perl/t/stanford-naming.t
+++ b/perl/t/stanford-naming.t
@@ -7,7 +7,7 @@
# behavior at Stanford.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2013
+# Copyright 2013, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -255,4 +255,6 @@ for my $type (qw(htpasswd ssh-rsa ssh-dsa ssl-key tivoli-key)) {
# Clean up.
$setup->destroy;
-unlink 'wallet-db';
+END {
+ unlink 'wallet-db';
+}
diff --git a/perl/t/wa-keyring.t b/perl/t/wa-keyring.t
index eaae034..8d8e1fe 100755
--- a/perl/t/wa-keyring.t
+++ b/perl/t/wa-keyring.t
@@ -3,7 +3,7 @@
# Tests for the WebAuth keyring object implementation.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2013
+# Copyright 2013, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -179,4 +179,6 @@ is ($object->destroy (@trace), 1, ' but destroying the object succeeds');
# Clean up.
$admin->destroy;
-unlink ('wallet-db');
+END {
+ unlink ('wallet-db');
+}
diff --git a/tests/client/full-t.in b/tests/client/full-t.in
index 4db0dbd..b73a375 100644
--- a/tests/client/full-t.in
+++ b/tests/client/full-t.in
@@ -3,7 +3,7 @@
# End-to-end tests for the wallet client.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2008, 2010
+# Copyright 2008, 2010, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.
@@ -188,8 +188,12 @@ SKIP: {
# All done.
remctld_stop;
$admin->destroy;
- unlink ('wallet-db', 'krb5cc_test', 'test-pid');
if (-d 'test-files') {
system ('rm', '-r', 'test-files');
}
}
+
+# Clean up the database and other test files at the end of the test.
+END {
+ unlink ('wallet-db', 'krb5cc_test', 'test-pid');
+}