From: Mark Mielke <mark@mark.mielke.cc>
To: Simon Riggs <simon@2ndQuadrant.com>
To: Robert Haas <robertmhaas@gmail.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Hot Standby on git
Date: Sat, 26 Sep 2009 17:31:17 -0400
Message-ID: <4ABE8825.70406@mark.mielke.cc> (raw)
In-Reply-To: <20090926182859.GA9544@funkstrom.spiretech.com>
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>
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<mark@mielke.cc>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: mark@mark.mielke.cc, simon@2ndQuadrant.com, robertmhaas@gmail.com
Subject: Re: Hot Standby on git
In-Reply-To: <4ABE8825.70406@mark.mielke.cc>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox