Re: [PATCH 9/8] lib/sort: turn off self-test

From: Pekka Enberg
Date: Thu Feb 10 2005 - 02:06:27 EST


On Mon, 31 Jan 2005 09:03:44 -0800, Matt Mackall <mpm@xxxxxxxxxxx> wrote:
> It's a nice self-contained unit test. It's here because I ran into a
> strange regparm-related bug when developing the code in userspace and
> I wanted to be sure that it was easy to diagnose in the field if a
> similar bug appeared in the future. I actually think that more code
> ought to have such tests, so long as they don't obscure the code in
> question.

Unit tests are nice and your approach is wrong. The test does not
belong in the implementation for two reasons: it hurts readability of
the actual code and the _commented out_ test will not be maintained
(dead code never is).

I don't know if the maintainers are interested in unit tests but a
better solution would be to put your test in a separate file and make
sure it is always compiled and executed when CONFIG_UNIT_TEST is
enabled.

P.S. If the test fails, it probably should do BUG().

Pekka
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/