Add test for deleted node accessed via ofd
This commit is contained in:
parent
570b40f9ca
commit
1a4be5e2fd
|
@ -106,4 +106,31 @@ describe('fs.open', function() {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should error if an ofd\'s node goes away while open', function(done) {
|
||||
var fs = util.fs();
|
||||
|
||||
fs.writeFile('/myfile', 'data', function(error) {
|
||||
if(error) throw error;
|
||||
|
||||
fs.open('/myfile', 'r', function(error, fd) {
|
||||
if(error) throw error;
|
||||
|
||||
// Delete the file while it's still open
|
||||
fs.unlink('/myfile', function(error) {
|
||||
if(error) throw error;
|
||||
|
||||
// This should fail now, since fd points to a bad node
|
||||
fs.fstat(fd, function(error, result) {
|
||||
expect(error).to.exist;
|
||||
expect(error.code).to.equal('EBADF');
|
||||
expect(result).not.to.exist;
|
||||
|
||||
fs.close(fd);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue