From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/57 Path: news.gmane.org!not-for-mail From: Solar Designer Newsgroups: gmane.linux.lib.musl.general Subject: specification of cluts tests - code or/and data? (was: Weekly reports - B) Date: Mon, 13 Jun 2011 06:22:31 +0400 Message-ID: <20110613022231.GA21480@openwall.com> References: <4DF12B1D.7050106@gmail.com> <20110613021130.GA21268@openwall.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1307931760 10248 80.91.229.12 (13 Jun 2011 02:22:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 13 Jun 2011 02:22:40 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-141-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jun 13 04:22:36 2011 Return-path: Envelope-to: gllmg-musl@lo.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by lo.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1QVwnR-0006AS-Mq for gllmg-musl@lo.gmane.org; Mon, 13 Jun 2011 04:22:33 +0200 Original-Received: (qmail 13861 invoked by uid 550); 13 Jun 2011 02:22:33 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 13853 invoked from network); 13 Jun 2011 02:22:33 -0000 Content-Disposition: inline In-Reply-To: <20110613021130.GA21268@openwall.com> User-Agent: Mutt/1.4.2.3i Xref: news.gmane.org gmane.linux.lib.musl.general:57 Archived-At: Luka, Rich - On Mon, Jun 13, 2011 at 06:11:30AM +0400, Solar Designer wrote: > Overall, I think the code could be made prettier. I'll post an idea > (which you don't have to use, but you may) in another message. Here's what I meant: Rather than write a piece of code for testing every property of every function, we could consider implementing interpreters or wrapper functions for common tests, or tables (arrays of structs) listing similar tests. A problem here is that call to a string function via a function pointer might not invoke the same implementation that direct use would (there could be a macro or a C compiler builtin). On the other hand, this also means that whatever approach to program structure we choose, we could want to test both kinds of uses of string functions (direct and via function pointer), to test both implementations (which might be present). This is not directly relevant, but to illustrate the use of interpreter or data structure approach to a task where most people tend to write lots of code instead, see: http://openwall.info/wiki/people/solar/software/public-domain-source-code/intel-80186-disassembler This is a complete i80186 disassembler in only 164 bytes of code, plus some 2.5 KB of data (17 KB source). Other disassemblers I saw typically process the different instruction types, addressing modes, etc. in code, and are much larger (in terms of code+data, as well as their source code). Maybe this will give you some inspiration for coming up with suitable data structures to define some classes of tests. You do not have to take it to the same "extreme" level - very generic code, data structures that are tricky to specify in C. You'll need to find a balance that works well for cluts. And you do not have to use an approach like this at all. You may continue as you have started. I just thought I'd mention the option. Maybe this helps. Alexander