Add test for deleted node accessed via ofd

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2014-10-17 13:16:09 -04:00
parent 570b40f9ca
commit 1a4be5e2fd
1 changed files with 27 additions and 0 deletions

View File

@ -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();
});
});
});
});
});
});