On Mon, Jan 31, 2005 at 03:57:42AM -0800, Paul Jackson wrote: > How about just removing the self test, not "#if 0"'ing it out. > > Better to keep the kernel source code clean of development > scaffolding. > > Though your patch 1/8 hasn't arrived in my email inbox yet, > so I don't actually know what 'self test' code it is that > I am speaking of ;).
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. Here it is for purposes of discussion: +#if 1 +/* a simple boot-time regression test */ + +int cmpint(const void *a, const void *b) +{ + return *(int *)a - *(int *)b; +} + +static int sort_test(void) +{ + int *a, i, r = 0; + + a = kmalloc(1000 * sizeof(int), GFP_KERNEL); + BUG_ON(!a); + + printk("testing sort()\n"); + + for (i = 0; i < 1000; i++) { + r = (r * 725861) % 6599; + a[i] = r; + } + + sort(a, 1000, sizeof(int), cmpint, 0); + + for (i = 0; i < 999; i++) + if (a[i] > a[i+1]) { + printk("sort() failed!\n"); + break; + } + + kfree(a); + + return 0; +} + +module_init(sort_test); +#endif -- Mathematics is the supreme nostalgia of our time. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/