From c13edd93d68415fd4dce8af5c1258001b1d6194c Mon Sep 17 00:00:00 2001 From: Andreas Guldstrand Date: Wed, 11 May 2016 22:41:06 +0000 Subject: SBO::Lib: add _race::cond subroutine for identifying, documenting, and testing race conditions --- SBO-Lib/lib/SBO/Lib.pm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'SBO-Lib/lib/SBO/Lib.pm') diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 8873bb5..490b278 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -115,6 +115,10 @@ our $tempdir = tempdir(CLEANUP => 1, DIR => $tmpd); # t/01-test.t our $pkg_db = '/var/log/packages'; +# _race::cond will allow both documenting and testing race conditions +# by overriding its implementation for tests +sub _race::cond { return } + # subroutine for throwing internal script errors sub script_error { if (@_) { @@ -139,6 +143,7 @@ sub open_fh { } my ($file, $op) = @_; my $fh; + _race::cond 'possibly $file has been deleted between -f test and now'; unless (open $fh, $op, $file) { my $warn = "Unable to open $file.\n"; my $exit = _ERR_OPENFH; -- cgit v1.2.3