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