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

id3 id3
Tue May 12 00:18:51 PDT 2015


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.

>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.”

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>

-- 

Quentin “Sardem FF7” Glidic


More information about the wayland-devel mailing list