This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Consensus on unit tests?
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Carlos O'Donell <carlos at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>, Florian Weimer <fweimer at redhat dot com>
- Date: Fri, 2 Sep 2016 17:32:46 -0700 (PDT)
- Subject: Re: Consensus on unit tests?
- Authentication-results: sourceware.org; auth=none
- References: <92609f90-7a53-a455-ca72-b9baae224a38@redhat.com>
You asked about the general concept of unit tests, and the following
discussion was only about the technical issues with the specific code in
your example.
I think the general notion of unit tests is a very good one. I don't
see any obvious problems in the approach you've taken to building a unit
test. Of course, any particular refactoring change to enable unit
testing might have issues and "It's for a unit test!" is not any kind of
trump over usual review concerns.
The likely pitfall I would look out for is when breaking some function
out into its own file to make it unit-testable might perturb the
optimization opportunities for the function in the actual build. We
should be careful about that. In your first example, the function was
already global, so there is no particular reason to worry about that
issue.
Thanks,
Roland