Perl: the Markov chain saw | |
PerlMonks |
Testing unexpected I/O failuresby kcott (Archbishop) |
on Nov 24, 2020 at 02:51 UTC ( [id://11124108]=perlquestion: print w/replies, xml ) | Need Help?? |
kcott has asked for the wisdom of the Perl Monks concerning the following question: I'm extending an application for $work and am seeking some advice on testing unexpected I/O failures. The application receives a lot of parameters and I perform sanity checks on these. There are three parameters of interest with respect to this SoPW, in brief:
The application works fine if good parameters are supplied. There's a total of nine (file-related) sanity checks; I've successfully tested all of these with bad parameters. The actual I/O is very straightforward; e.g.
The error messages on failure are similarly standard:
Given the sanity checks, I/O failure would be unexpected but still possible; for instance, between the sanity checks and an open call, a file could be deleted or renamed, it's permissions changed, a hardware failure could occur, and so on.
I managed to test the write failure by running normally; manually removing the write permissions of the output file;
and then running again with the same parameters.
So that just leaves me with testing the read failure; unfortunately, I can't think of a way to do that. Any ideas would be greatly appreciated. While I do like to test everything, if this last test can't be done it's not a huge problem. The code is very straightforward (I've probably written similar code thousands of times in the past); the syntax is fine (perl -c); and, I know it works with good parameters. — Ken
Back to
Seekers of Perl Wisdom
|
|