Re: Forcing File Open and File Read Errors
- From: Eric Sosman <esosman@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 09 Sep 2009 23:23:00 -0400
Peter Olcott wrote:
I need to be able to force file open and file read errors to verify that exception processing is working correctly. What are all the ways that these two errors can be synthesized?
Forcing file open to fail is easy: Just make sure there's
no file of the desired name, or that your process doesn't have
permission to open it in the desired mode, or that your process
doesn't have 'x' permission on some directory in its path.
Forcing a read error on a file that's been opened successfully
is harder. You could take an axe to the disk containing the file,
but your eye-hand coordination would need to be pretty good: if
the file's content has already been cached, the disk might not
be needed (for a while, anyhow). Best bet (and this applies to
other system calls too, including open) is to use an interposition
library that catches all calls to open, read, whatever, forwards
most of them to the actual system calls, but occasionally decides
to burp back an error for no good reason whatsoever. See also
"fault injection."
--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxxx
.
- References:
- Forcing File Open and File Read Errors
- From: Peter Olcott
- Forcing File Open and File Read Errors
- Prev by Date: Forcing File Open and File Read Errors
- Next by Date: Re: Unix2Dos - Is this wise to use here?
- Previous by thread: Forcing File Open and File Read Errors
- Next by thread: Re: Forcing File Open and File Read Errors
- Index(es):
Relevant Pages
|