To see if this idea worked in practice, we tested it in the context of the Wine project.
Wine is an open-source implementation of the Windows API; for each function defined by
the Windows API, Wine in principle provides an equivalent linux implementation. Ideally
each of these functions also has unit tests, although in actuality, many unit tests are yet
to be written. The unit tests are run periodically on Windows to verify that the test is
correct, and run periodically on Wine to verify that Wine is correct. (Wine calls these unit
tests ‘conformance tests’ to emphasize that they test conformance with the Windows API.)
System testing in Wine is done by running Windows applications on Wine and checking that
they behave properly. If an application doesn’t function properly on Wine, but works on
Windows, it must be a bug in Wine.
The first step was to gain experience with the Wine conformance test suite. Wine’s source
consists mainly of source code for several hundred dynamic link libraries; each such library
is supposed to have a conformance test. One such library which did not yet have a test was
LZExpand, which implements the Windows API functions LZInit, LZCopy, LZOpenFile,
LZSeek, LZRead, LZClose, and GetExpandedName. These functions are mostly used by
older installers and are needed in Wine for backwards compatibility. The functions of the
LZExpand DLL are documented by Microsoft at http://msdn.microsoft.com/library/
en-us/fileio/fs/file_management_functions.asp. We wrote a small set of tests that
exercise those APIs and aborts if anything unexpected happens. We ran the tests on Win-
dows, and adjusted them until they ran correctly. Then we ran them on Wine, and discovered
a small bug in Wine: the behavior when reading past the end of a file with LZRead is not
the same under Wine as it is under real Windows. Finally, we made sure the tests followed
the Wine programming style and used the Wine test suite harness properly. We submitted
the tests as a patch to the Wine maintainers, who promptly accepted it into the Wine source
tree.
The next step was to enhance Wine to support measurement of code coverage. We
chose to use the standard Unix/Linux tool ‘gcov’ to measure code coverage, since it’s free
and comes standard with Linux. Adding support and documentation for gcov to Wine was
straightforward, though we did have to rework our patch several times before coming up with