YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← 01-28 Good Test Cases

01-28 Good Test Cases

Get Embed Code
1 Language

Showing Revision 2 created 07/16/2014 by Udacity Robot.

  1. In contrast with software libraries and software components
  2. where the domain is clearly defined
  3. and might be a subset of all the values that you can construct using the programming language,
  4. it's often the case that higher level software artifacts
  5. don't have the luxury of limiting their domains.
  6. And so one good example of this is an operating system.
  7. So here let's say we're testing a UNIX platform such as Linux or Mac OS X.
  8. I know we really haven't discussed this case yet,
  9. but I want to take a really quick quiz in order to start building up our intuition about testing.
  10. This example will be a very slightly simplified version of the UNIX read system call,
  11. and this is a system call supported by all UNIX platforms,
  12. so by Mac OS and Linux and others.
  13. All that read system call does is takes a file that's already open
  14. and reads some bytes out of it into the address space of the process that calls a read.
  15. And so the read call takes 3 parameters.
  16. It takes an integer called fd,
  17. which is just a small integer referencing a file that's already open.
  18. It takes a second current parameter called buf,
  19. which is a pointer to a memory region--
  20. that is to say, a valid memory region in the process's address space.
  21. And finally, it takes a number of bytes.
  22. And so the quiz that we're going to take is which of the following test cases
  23. constitutes a useful test case for the read system call?
  24. Our 4 test cases are first, reading from file descriptor number 1--
  25. this is always a valid file descriptor for a UNIX process--
  26. from the address of b, and let's assume that refers to a valid memory region,
  27. and we're going to read 10 bytes.
  28. The second test case is also reading into variable b, 10 bytes,
  29. but it's specifying file descriptor -99999.
  30. The third test case is reading into file descriptor 1 using a pointer to an address
  31. which is almost certainly a bad one--this is just a random hex constant I just made up--
  32. also reading 10 bytes into there.
  33. And the final test case reads into file descriptor 1 and to a valid address b
  34. but reads -33333 bytes.
  35. So go ahead and write your answer.
  36. Write all of the test cases--write the letters indicated--
  37. all of the test cases that you think are good ones for a UNIX kernel in the space provided.