Correct src location for kernel ATF tests

Julio Merino julio at meroh.net
Tue Jan 14 20:26:33 UTC 2014


On Jan 14, 2014, at 20:22, Alan Somers <asomers at freebsd.org> wrote:

> On Tue, Jan 14, 2014 at 12:12 PM, Julio Merino <julio at meroh.net> wrote:
>> On Jan 13, 2014, at 22:25, Alan Somers <asomers at freebsd.org> wrote:
>> 
>>> Where is the correct location within the source tree for ATF tests
>>> that exercise kernel features?  For example, I'm currently trying to
>>> ATFify tools/regression/sockets/unix_seqpacket_exercise,
>> 
>> I think it's good practice to _not_ ATFify an existing test at the same time as it's moved.
>> 
>> I feel it's better to first move the test program "as is" into its new location, ensure it works, and only then change it to use the ATF libraries.  If done properly (e.g. by maintaining the same binary name pre/post conversion), this should cause minimum churn and will allow for easier tracking of code changes in the VCS history.
> 
> In this case, the test doesn't work to begin with.  I'm rewriting
> almost from scratch.

OK, then it makes sense to just do the "move" in one go.

>> Second, possibly trickier, is that any kernel tests that currently exist are integration tests by design: we have no unit-testing framework for the kernel (such as what rump provides for NetBSD), and as such any test will be quite "broad" in scope.  This may make it difficult to pinpoint the specific subdirectory in which the test belongs.  For your case above, I cannot tell if any of the src/sys/net*/ subdirectories are relevant and/or specific enough.  If they are, then I'd say put the test in one of them using src/sys/netgraph/tests/unix_seqpacket_exercise to pick an example at random.
> 
> Sounds good, but the most relevant directory is actually
> src/sys/kern/, not src/sys/netgraph.

SGTM.

Is the test specific to a single file within kern or is it not?

If it is, then name the test program after the source file.  For example, assuming this tested stuff from sys_socket.c, you'd then have a sys_socket_test test program and put a single test case inside it called unix_seqpacket_exercise.

If it is not, then make sure to use a generic-enough name for the test program that leaves room for future test cases in the same "area".

https://wiki.freebsd.org/TestSuite/Structure contains some more rationales for this.



More information about the freebsd-testing mailing list