Fun and games with, er, test coverage
Mar. 11th, 2007 11:02 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Here's some gcov output:
34: 599: switch(pflags & (SSH_FXF_CREAT|SSH_FXF_TRUNC|SSH_FXF_EXCL)) { -: 600: case 0: 11: 601: flags |= SSH_FXF_OPEN_EXISTING; 11: 602: break; -: 603: case SSH_FXF_TRUNC: -: 604: /* The drafts demand that SSH_FXF_CREAT also be sent making this formally -: 605: * invalid, though there doesn't seem any good reason for them to do so: -: 606: * the client intent seems clear.*/ 2: 607: flags |= SSH_FXF_TRUNCATE_EXISTING; 2: 608: break; -: 609: case SSH_FXF_CREAT: 2: 610: flags |= SSH_FXF_OPEN_OR_CREATE; 2: 611: break; -: 612: case SSH_FXF_CREAT|SSH_FXF_TRUNC: 17: 613: flags |= SSH_FXF_CREATE_TRUNCATE; 17: 614: break; -: 615: case SSH_FXF_CREAT|SSH_FXF_EXCL: -: 616: case SSH_FXF_CREAT|SSH_FXF_TRUNC|SSH_FXF_EXCL: /* nonsensical */ #####: 617: flags |= SSH_FXF_CREATE_NEW; #####: 618: break; -: 619: default: #####: 620: return SSH_FX_BAD_MESSAGE; -: 621: }
Why are lines 617 and 618 never executed (that's what the hash signs mean)? (If you saw the answer on IRC then you're not eligible l-) Here's a couple of wrong answers:
- Because the tests don't exercise that case. They do, via SSH_FXF_CREAT|SSH_FXF_EXCL.
- Because you turned optimization on, despite the gcov manual telling you not to. Nope, -O0 and other options exactly as required.
(620 isn't executed because the tests don't go there. Apart from the code being obviously correct, no working client is going to send the server there anyway, so I don't really care.)
(no subject)
Date: 2007-03-12 12:19 am (UTC)