./qemuxml2xmltest
+If you are adding new test cases, or making changes that alter existing test
+output, you can use the environment variable VIR_TEST_REGENERATE_OUTPUT to
+quickly update the saved test data. Of course you still need to review the
+changes VERY CAREFULLY to ensure they are correct.
+
+ VIR_TEST_REGENERATE_OUTPUT=1 ./qemuxml2argvtest
+
There is also a "./run" script at the top level, to make it easier to run
programs that have not yet been installed, as well as to wrap invocations of
various tests under gdb or Valgrind.
<pre>
./qemuxml2xmltest
</pre>
+
+ <p>
+ If you are adding new test cases, or making changes that alter
+ existing test output, you can use the environment variable
+ VIR_TEST_REGENERATE_OUTPUT to quickly update the saved test data.
+ Of course you still need to review the changes VERY CAREFULLY to
+ ensure they are correct.
+ </p>
+<pre>
+ VIR_TEST_REGENERATE_OUTPUT=1 ./qemuxml2argvtest
+</pre>
+
<p>There is also a <code>./run</code> script at the top level,
to make it easier to run programs that have not yet been
installed, as well as to wrap invocations of various tests
return testOOMActive;
}
+static unsigned int
+virTestGetFlag(const char *name)
+{
+ char *flagStr;
+ unsigned int flag;
+
+ if ((flagStr = getenv(name)) == NULL)
+ return 0;
+
+ if (virStrToLong_ui(flagStr, NULL, 10, &flag) < 0)
+ return 0;
+
+ return flag;
+}
+
#ifdef TEST_OOM_TRACE
static void virTestAllocHook(int nalloc ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
int ret = -1;
char *filecontent = NULL;
char *fixedcontent = NULL;
+ bool regenerate = !!virTestGetFlag("VIR_TEST_REGENERATE_OUTPUT");
- if (virtTestLoadFile(filename, &filecontent) < 0)
+ if (virtTestLoadFile(filename, &filecontent) < 0 && !regenerate)
goto failure;
- if (filecontent[strlen(filecontent) - 1] == '\n' &&
+ if (filecontent &&
+ filecontent[strlen(filecontent) - 1] == '\n' &&
strcontent[strlen(strcontent) - 1] != '\n') {
if (virAsprintf(&fixedcontent, "%s\n", strcontent) < 0)
goto failure;
}
- if (STRNEQ(fixedcontent ? fixedcontent : strcontent, filecontent)) {
+ if (STRNEQ_NULLABLE(fixedcontent ? fixedcontent : strcontent,
+ filecontent)) {
+ if (regenerate) {
+ if (virFileWriteStr(filename, strcontent, 0666) < 0)
+ goto failure;
+ goto out;
+ }
virtTestDifference(stderr, strcontent, filecontent);
goto failure;
}
+ out:
ret = 0;
failure:
VIR_FREE(fixedcontent);
}
-static unsigned int
-virTestGetFlag(const char *name)
-{
- char *flagStr;
- unsigned int flag;
-
- if ((flagStr = getenv(name)) == NULL)
- return 0;
-
- if (virStrToLong_ui(flagStr, NULL, 10, &flag) < 0)
- return 0;
-
- return flag;
-}
-
unsigned int
virTestGetDebug(void)
{