Local rwt Using test161

I know that the rwt code are left to us as practice, but if we run test161 locally, do we still need to implement the test first to get a result ?

Check the source. An easy method for searching for some code in an unknown spot is just to grep recursively through a directory.

cd /path/to/os161;
grep ‘rwt’ . -r ;

to find the file with the test you want. In this case it’s in rwtest.c (though we probably could have guessed that).

The tests just return false until you implement them. I don’t think these tests were graded (at least they weren’t for our year), so test161 might just ignore them or not assign points to them.

Implementing good tests is great exercise to see if you understand what really needs to be implemented for a function. Until you can confidently write tests for a function, you don’t really know what needs to be done. I’ve written bad tests before, which is a whole other problem. Peer review is a good hedge against this, if you can find someone who will actually read your test thoroughly.

There is a school of thought that you should be able to write your unit tests before you actually code your functions, the idea being that this would lead to less error-prone code. This is probably true, but I don’t think I know anyone who actually does this.

If anyone reading this writes their tests first, please let me know!

Just a few corrections to Matthew’s excellent post:

  • Yes, the RW lock tests are graded this year. We add them when you submit to the server but they are missing locally. You get to write them!

  • Despite what he said, Matt does know someone who (at least some of the time) writes unit tests before writing code :slight_smile: