Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id A120B632EEB for ; Sat, 26 Sep 2009 18:31:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 25670-02 for ; Sat, 26 Sep 2009 21:31:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-09.primus.ca (smtp-noauth7.primus.ca [216.254.180.38]) by mail.postgresql.org (Postfix) with ESMTP id 8F47063319F for ; Sat, 26 Sep 2009 18:31:20 -0300 (ADT) Received: from [206.191.44.11] (helo=bambi.pccyber.com) by mail-09.primus.ca with esmtp (Exim 4.69) (envelope-from ) id 1MrerO-0003WR-1u; Sat, 26 Sep 2009 17:31:18 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by bambi.pccyber.com (Postfix) with ESMTP id 31A731B49CF; Sat, 26 Sep 2009 17:31:18 -0400 (EDT) X-Virus-Scanned: amavisd-new at pccyber.com Received: from bambi.pccyber.com ([127.0.0.1]) by localhost (bambi.pccyber.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2HMz0jA+XXPf; Sat, 26 Sep 2009 17:31:17 -0400 (EDT) Received: from [173.35.103.0] (CPE0050fca9b0e1-CM0018c0d3a5ba.cpe.net.cable.rogers.com [173.35.103.0]) (Authenticated sender: mark@pccyber.com) by bambi.pccyber.com (Postfix) with ESMTPA id 6D7F51B49CE; Sat, 26 Sep 2009 17:31:17 -0400 (EDT) Message-ID: <4ABE8825.70406@mark.mielke.cc> Date: Sat, 26 Sep 2009 17:31:17 -0400 From: Mark Mielke User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3 MIME-Version: 1.0 To: Simon Riggs , Robert Haas , pgsql-hackers Subject: Re: Hot Standby on git References: <1253958559.4449.833.camel@ebony.2ndQuadrant> <603c8f070909260629s1f070a8bl8aa6dc97fa87ce43@mail.gmail.com> <1253973877.4449.899.camel@ebony.2ndQuadrant> <4ABE28FD.7060404@mark.mielke.cc> <20090926182859.GA9544@funkstrom.spiretech.com> In-Reply-To: <20090926182859.GA9544@funkstrom.spiretech.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.439 tagged_above=-10 required=5 tests=AWL=0.160, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/1702 X-Sequence-Number: 146508 On 09/26/2009 02:28 PM, Dan Colish wrote: > There are a variety of projects dedicated to creating C unit test > frameworks. I don't have a lot of experience with them, but I have heard > good things about check and cunit. Here's a link I found with a longer > list of frameworks. http://www.opensourcetesting.org/unit_c.php > Looking at check and cunit - I don't see what sort of mock function facility they would provide? One part of unit testing is arranging for functions to be called, tested, and results reported on. This can take you a certain amount of the way. "Pure" functions, for example, that always generate the same output for the same input parameters, are perfect for this situation. Perhaps test how a qsort() or bsearch() method works under various scenarios? Most real life code gets a little more complicated. For example, what if we want to simulate a network failure or "out of disk space" condition? What if we want to test out what happens when the Y2038 date is reached? This requires either complex test case setup that is difficult to run reproducibly, or another approach - "mock". It means doing things like overriding the write() method, and making it return successful N times, and then failing on the (N+1)th time with ENOSPC. It means overriding the gettimeofday() method to return a time in the future. A major benefit of this sort of testing is that it should not require source changes in order to perform the test. This sort of stuff is a LOT easier to do in OO languages. I see it done in Java a lot. I can't remember ever having seen it done in C. I think it's just too hard compared to the value obtained from the effort. In your list above, it does show a few attempts - CMock sticks out as a for example. It looks more complicated, though. It takes a .h file and generates stubs for you to fill in? That could be difficult to manage for a large project with thousands or many times more unit tests. OO is easier because you can override *only* particular methods, and you can safely call the super method that it overrides to provide the underlying behaviour in the success cases. Cheers, mark -- Mark Mielke