This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 01/15] Selftest framework (unittests v4)
- From: Bernd Schmidt <bschmidt at redhat dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Jeff Law <law at redhat dot com>
- Date: Thu, 26 Nov 2015 13:37:38 +0100
- Subject: Re: [PATCH 01/15] Selftest framework (unittests v4)
- Authentication-results: sourceware.org; auth=none
- References: <564A1DAB dot 1030700 at redhat dot com> <1447952699-40820-1-git-send-email-dmalcolm at redhat dot com> <1447952699-40820-2-git-send-email-dmalcolm at redhat dot com> <564E084A dot 20006 at redhat dot com> <1447956495 dot 19594 dot 140 dot camel at surprise> <564E1881 dot 3030306 at redhat dot com> <1448491656 dot 19594 dot 253 dot camel at surprise>
On 11/25/2015 11:47 PM, David Malcolm wrote:
FWIW, the reason I special-cased the linked list was to avoid any
dynamic memory allocation: the ctors run before main, so I wanted to
keep them as simple as possible.
Is there any particular reason for this? C++ doesn't disallow memory
allocation in global constructors, does it?
Putting the linked list directly into
those objects means that running the ctors is a simple case of wiring up
some pointers: the memory is already statically allocated. (also, one
thing I want to test is vec<> itself [1]).
Ok so use a C++ list instead of a vec. My days of using C++ for personal
projects are 15 years in the past so maybe I'm not an authority, but
that's how I feel the language is supposed to be used - use provided
data structures rather than coding them up over and over.
I do want some level of determinism over test ordering, for the sake of
everyone's sanity. It's probably simplest to either hardcode the order,
or have priority levels. I favor the former (and right now am leaning
towards a very explicit no-magic approach with no auto-registration,
given the linker issues I've been seeing with auto-registration).
I guess that works too. Certainly explicit function calls are
preferrable over #including other C files as a workaround for such a
problem.
I still wish others would chime in on the rest of the issues we've
discussed (run to first failure vs. providing elaborate test summaries),
I want to make my preference clear but I don't want to dictate it.
Bernd