From: E. <jo...@wo...> - 2003-05-07 18:20:48
|
On Wed, 7 May 2003 10:55:52 -0700, Dan Kegel wrote: > How about this: when starting, the test should declare how > much RAM it needs. Then the framework could skip the test > if that wasn't available. Extending the idea, tests could > declare that they needed various other resources. > > I'd prefer it be a declarative statement embedded in the > code -- that way it could be used both by source-scanning > tools and by the runtime. No sense segregating it off in > a text file to rot... If you want to do this, how about the following code? char *buf; buf = malloc(AS_MUCH_AS_I_NEED); if (!buf) exit(what_do_you_prefer ? 0 : 1); memset(buf, 0x88, AS_MUCH_AS_I_NEED); free(buf); This should also catch the case of overcommitted memory, the only problem is to figure out a sane value for AS_MUCH_AS_I_NEED. Jörn -- Everything should be made as simple as possible, but not simpler. -- Albert Einstein |