Testing
When working on a big project, it's a bad idea to write 1000 LOC blindly and then start to compile, hoping your code will pass all the tests magically (If you really make it, please let us know, you definitely should be the next Linus Torvalds!). Instead, test-driven development should be your choice. We will elaborate on this during the TA tutorial section.
File structure
Under src/tests
, each lab (except for lab 0) has its corresponding test directory:
"src/tests/threads"
"src/tests/userprog"
"src/tests/vm"
"src/tests/filesys"
Under each lab's test directory, the files can be classified as follows:
"foo.c"
C source code for
foo
test case
"foo.ck"
Perl script for checking your output with the reference, you can find the desired output for
foo
test case in it.
"Rubric.bar"
bar
is the name of the testing set, and the Rubric file defines which tests this set includes and their assigned scores.For example,
src/tests/threads/Rubric.alam
defines thealarm
testing set which contains all the tests for "Functionality and robustness of alarm clock" :
"Grading"
Defines the proportion of testing points of each testing set. For example,
src/tests/threads/Grading
:
Run all tests
Each project has several tests. To completely test your implementation, invoke make check
from the project build directory.
This will build and run each test and print a "pass" or "fail" message for each one.
When a test fails,
make check
also prints some details of the reason for failure.After running all the tests,
make check
also prints a summary of the test results.
Run an individual test
You can also run an individual test at a time.
A given test foo writes its output to
foo.output
, then a script scores the output as "pass" or "fail" and writes the result tofoo.result
.
To run and grade a single test, make
the .result
file explicitly from the build directory.
e.g. Type
make tests/threads/alarm-multiple.result
in the build directory to test thealarm-multiple
case.If
make
says that the test result is up-to-date, but you want to re-run it anywayeither delete the
.output
file by hand, e.g.rm tests/threads/alarm-multiple.output
or run
make clean
to delete all build and test output files.
Special options
By default, each test provides feedback only at completion, not during its run. **** If you prefer, you can observe the progress of each test by specifying
VERBOSE=1
on themake
command line, as inmake check VERBOSE=1
.You can also provide arbitrary options to the
pintos
run by the tests withPINTOSOPTS='...'
Please don't try to take advantage of our generosity in giving out the whole test suite.
Your code has to work properly in the general case, not just for the test cases we supply. For example, it would be unacceptable to explicitly base the kernel's behavior on the name of the running test case. Such attempts to sidestep the test cases will receive no credit. If you think your solution may be in a gray area here, please ask us about it.
Last updated