summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Bolte <matthias.bolte@googlemail.com>2011-04-25 00:25:10 +0200
committerMatthias Bolte <matthias.bolte@googlemail.com>2011-04-30 19:59:52 +0200
commit9ba4eb3c081027846637acf20b17ec801dc66b72 (patch)
tree12eaeebaeeb298f17c8f009d1c08c43a590eda27 /tests/qemuhelptest.c
parenttests: Update valgrind suppressions file (diff)
downloadlibvirt-9ba4eb3c081027846637acf20b17ec801dc66b72.tar.gz
libvirt-9ba4eb3c081027846637acf20b17ec801dc66b72.tar.bz2
libvirt-9ba4eb3c081027846637acf20b17ec801dc66b72.zip
tests: Lower stack usage below 4096 bytes
Make virtTestLoadFile allocate the buffer to read the file into. Fix logic error in virtTestLoadFile, stop reading on the first empty line. Use virFileReadLimFD in virtTestCaptureProgramOutput to avoid manual buffer handling.
Diffstat (limited to 'tests/qemuhelptest.c')
-rw-r--r--tests/qemuhelptest.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 792b5ab7f..252239648 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -9,8 +9,6 @@
# include "qemu/qemu_capabilities.h"
# include "memory.h"
-# define MAX_HELP_OUTPUT_SIZE 1024*64
-
struct testInfo {
const char *name;
virBitmapPtr flags;
@@ -38,8 +36,7 @@ static int testHelpStrParsing(const void *data)
{
const struct testInfo *info = data;
char *path = NULL;
- char helpStr[MAX_HELP_OUTPUT_SIZE];
- char *help = &(helpStr[0]);
+ char *help = NULL;
unsigned int version, is_kvm, kvm_version;
virBitmapPtr flags = NULL;
int ret = -1;
@@ -49,7 +46,7 @@ static int testHelpStrParsing(const void *data)
if (virAsprintf(&path, "%s/qemuhelpdata/%s", abs_srcdir, info->name) < 0)
return -1;
- if (virtTestLoadFile(path, &help, MAX_HELP_OUTPUT_SIZE) < 0)
+ if (virtTestLoadFile(path, &help) < 0)
goto cleanup;
if (!(flags = qemuCapsNew()))
@@ -61,11 +58,12 @@ static int testHelpStrParsing(const void *data)
if (qemuCapsGet(info->flags, QEMU_CAPS_DEVICE)) {
VIR_FREE(path);
+ VIR_FREE(help);
if (virAsprintf(&path, "%s/qemuhelpdata/%s-device", abs_srcdir,
info->name) < 0)
goto cleanup;
- if (virtTestLoadFile(path, &help, MAX_HELP_OUTPUT_SIZE) < 0)
+ if (virtTestLoadFile(path, &help) < 0)
goto cleanup;
if (qemuCapsParseDeviceStr(help, flags) < 0)
@@ -111,6 +109,7 @@ static int testHelpStrParsing(const void *data)
ret = 0;
cleanup:
VIR_FREE(path);
+ VIR_FREE(help);
qemuCapsFree(flags);
VIR_FREE(got);
VIR_FREE(expected);