public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matt Mackall <mpm@selenic.com>
To: Paul Jackson <pj@sgi.com>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 9/8] lib/sort: turn off self-test
Date: Mon, 31 Jan 2005 09:03:44 -0800	[thread overview]
Message-ID: <20050131170344.GP2891@waste.org> (raw)
In-Reply-To: <20050131035742.1434944c.pj@sgi.com>

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.

  parent reply	other threads:[~2005-01-31 17:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-31  7:44 [PATCH 9/8] lib/sort: turn off self-test Matt Mackall
2005-01-31 11:57 ` Paul Jackson
2005-01-31 12:20   ` Andreas Gruenbacher
2005-01-31 17:03   ` Matt Mackall [this message]
2005-01-31 20:49     ` Paul Jackson
2005-02-10  3:28     ` Werner Almesberger
2005-02-10  7:04     ` Pekka Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050131170344.GP2891@waste.org \
    --to=mpm@selenic.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pj@sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox