This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Using setrlimit in testsuite
- To: Zack Weinberg <zackw at panix dot com>
- Subject: Using setrlimit in testsuite
- From: Phil Edwards <pedwards at disaster dot jaj dot com>
- Date: Sun, 5 Aug 2001 21:52:30 -0400
- Cc: libstdc++ at gcc dot gnu dot org
[gcc@ list trimmed]
On Thu, Aug 02, 2001 at 07:40:10PM -0400, Zack Weinberg wrote:
> On Thu, Aug 02, 2001 at 07:21:30PM -0400, Phil Edwards wrote:
> > I'm familiar with ulimit at the shell level but not the underlying calls.
> > Do we need anything other than a simpleminded setrlimit() autoconf test,
> > i.e., is the function signature fairly well-standardized across platforms
> > which have it?
>
> To the best of my knowledge it's always int setrlimit(int, struct rlimit *);
> The tricky bit is that the appropriate RLIMIT_* constant varies with the
> operating system - RLIMIT_DATA, RLIMIT_RSS, RLIMIT_AS, etc. It may work
> to set all of the limits that are #defined.
Okay, I have an initial patch for this, and I've re-enabled the
pathological test in insert.cc and ctor_copy_dtor.cc. I'll wait to see
what the autobuilder comes up with overnight before posting a full patch.
Odd things seem to be happening for -static builds, but it may just be
the lack of air conditioning in this room.
Anyhow, good bits: the patch for, say, insert.cc is really simple:
Index: insert.cc
===================================================================
--- insert.cc 2001/05/12 16:51:41 1.3
+++ insert.cc 2001/08/06 00:54:50
@@ -23,6 +23,7 @@
#include <string>
#include <stdexcept>
#include <debug_assert.h>
+#include <memlimit.h>
int test01(void)
{
@@ -189,6 +190,7 @@
int main()
{
+ __set_testsuite_memlimit();
test01();
return 0;
}
Other good bits: Default memory limits can be overridden at various points.
All the memory-related limit macros (RLIMIT_DATA, etc) which autoconf
can find are used. For platforms which don't have <sys/resource.h> and
<unistd.h>, we do nothing at all.
Bad bits: There's no reason for autoconf's discoveries wrt testsuite-only
features like <sys/resources.h> and the presence of RLIMIT_<foo> to end up
in config.h -> c++config.h. So this memlimit.h is being generated from
a memlimit.h.in, and rather than #include'ing a file to tell us whether
the features are present, it comments and uncomments parts of the header,
as appropriate. That way all the configury is done via AC_SUBST, and is
completely contained within memlimit.h[.in].
The .h file is nice and readable (and can be easily edited to disable all
the limits everywhere, for those who want to /really/ test the pathological
cases), but the .h.in file looks a bit odd at first. Enh.
Phil
--
Would I had phrases that are not known, utterances that are strange, in
new language that has not been used, free from repetition, not an utterance
which has grown stale, which men of old have spoken.
- anonymous Egyptian scribe, c.1700 BC