[libvirt] RFC: Move tests into same directory as the sources

Daniel P. Berrange berrange at redhat.com
Tue Jan 21 11:26:55 UTC 2014


Currently we have a split with all the "source" code under various
subdirectories of src/, while the test cases are (mostly) all under
the tests/ directory. I think there could be some benefits to moving
the test files to be alongside the source files being tested.
eg instead of tests/virhashtest.c  have src/util/virhashtest.c

The tests/ directory is getting reasonably large, and is likely to
grow even more as we push for greater unit tests. We could split it
up into various sub-directories mirroring the split of dirs under
src/, but it seems easier to put have them directory under src/ and
remove the arbitrary split of source and tests.

Having the test files alongside the source files makes it obvious
to anyone looking in a directory that tests exist for a file. This
might encourage people to think about adding tests when changing
a source file. It also makes it more slightly obvious which files
lack proper tests.

In essence I'm suggesting that our code file naming should be thus

   virfoo.h  - exports of module foo for general internal usage
   virfoo.c  - implementation of module foo
   virfoopriv.h - exports of module foo for test suite usage only
   virfootest.c - implementation of tests for module foo
   virfoomock.c - implementation of LD_PRELOAD hack for module foo tests

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list