"Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote: > This patch adds more helper functions to the tests/testutils.c file which > make it trivial to verify OOM handling in our test suites. Very nice! ACK > diff -r 9f962ac84b09 tests/oomtrace.pl > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/tests/oomtrace.pl Wed May 21 22:22:48 2008 -0400 > @@ -0,0 +1,31 @@ > +#!/usr/bin/perl > +use strict; > +use warnings; If you run ...| perl oomtrace.pl > /dev/full, it succeeds in spite of the write error. Insert these 8 lines and it will report the disk-full error. If my File::Coda module were standard, I'd say "use it". In the mean time, I use this (commented version at the URL): (my $ME = $0) =~ s|.*/||; # use File::Coda; # http://meyering.net/code/Coda/ END { defined fileno STDOUT or return; close STDOUT and return; warn "$ME: failed to close standard output: $!\n"; $? ||= 1; } ... > diff -r 9f962ac84b09 tests/testutils.c > --- a/tests/testutils.c Wed May 21 19:42:55 2008 -0400 > +++ b/tests/testutils.c Wed May 21 22:22:48 2008 -0400 ... > +static int testOOM = 0; > +static int testDebug = 0; > +static int testCounter = 0; If these can be unsigned, using an unsigned type (like size_t or uintmax_t) would make their declarations more readable, in that the reviewer wouldn't have to wonder if/when they go negative. > +int virtTestMain(int argc, > + char **argv, > + int (*func)(int, char **)) > +{ > +#if TEST_OOM > + int ret; > + int approxAlloc = 0; > + int n; > + char *oomStr = NULL, *debugStr; > + int oomCount; > + > + if ((debugStr = getenv("VIR_TEST_DEBUG")) != NULL) { > + virStrToLong_i(debugStr, NULL, 10, &testDebug); > + > + if (testDebug < 0) > + testDebug = 0; > + } > + > + if ((oomStr = getenv("VIR_TEST_OOM")) != NULL) { > + virStrToLong_i(oomStr, NULL, 10, &oomCount); When virStrToLong_i returns < 0, oomCount is not initialized, so when the string is invalid, either diagnose it or default oomCount to 0. -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list