diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-05-11 22:41:06 +0000 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-05-11 22:41:06 +0000 |
commit | c13edd93d68415fd4dce8af5c1258001b1d6194c (patch) | |
tree | aa9e9e62b8fae70911eb811a0b249aa4d61b8b26 /SBO-Lib/lib | |
parent | 15510c6735f851fe337e83e8318e689e561d12b8 (diff) | |
download | sbotools2-c13edd93d68415fd4dce8af5c1258001b1d6194c.tar.xz |
SBO::Lib: add _race::cond subroutine
for identifying, documenting, and testing race conditions
Diffstat (limited to 'SBO-Lib/lib')
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 5 |
1 files changed, 5 insertions, 0 deletions
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; |