[PATCH weston 03/10] tests: Add an xmalloc helper function

Pekka Paalanen ppaalanen at gmail.com
Tue May 12 00:26:08 PDT 2015


On Tue, 12 May 2015 09:08:41 +0200
Quentin Glidic <sardemff7 at sardemff7.net> wrote:

> On 2015-05-12 06:49, Bryce Harrington wrote:
> > On Mon, May 11, 2015 at 01:39:29PM +0300, Pekka Paalanen wrote:
> >> Hi,
> >>
> >> so the motivation for this patch is to make alloc failures just exit
> >> the process with EXIT_FAILURE than calling abort()? Or is to stop
> >> relying on assert()? Or to add the printf? Or just code consistency?
> >>
> >> Would be nice to know why... maybe I'll learn in the later patches.
> > 
> > Actually, the original motivation was that I needed an xmalloc.  I
> > noticed there was xzalloc already defined but it was done differently
> > from the one in clients/window.c.  So this patch is making the
> > definitions (and behavior) consistent across the codebase.
> > 
> > I considered moving the functions to the shared directory but felt like
> > they were not yet being used widely enough to justify that.  window.c
> > actually has a set of alloc routines that would be handy to make more
> > convenient for test writers.
> > 
> > The assert-vs-exit difference didn't seem like a big concern here.
> > Either way the test harness will count it as a failure.

Hi,

ok, so no complicated motivation behind it, just consistency. That's
good.

> From Automake manual[1]:
> “When no test protocol is in use, an exit status of 0 from a test script
> will denote a success, an exit status of 77 a skipped test, an exit
> status of 99 an hard error, and any other exit status will denote a
> failure.”

Sure, why not.

> I think these tests should use these values to make it clear what is
> happening. It also allows to have working XFAILS_TESTS to abort for real
> on a malloc failure, if in the future we want to have such tests.
> 
> [1]
> <http://www.gnu.org/savannah-checkouts/gnu/automake/manual/automake.html#Scripts_002dbased-Testsuites>
> 

Does XFAIL mean the test "should pass one day, but currently we expect
it to fail, because our code is known broken" or "this test is always
intended to fail/crash, because it checks a condition that must
fail/crash"?

I find the latter interpretation hard to use, because it is hard to
guarantee the particular expected failure is the only failure that can
occur.


Thanks,
pq


More information about the wayland-devel mailing list