Commit Graph

178 Commits

Author SHA1 Message Date
Erik Skultety
c9279169a1 daemon: Split output parsing and output defining
Since virLogParseAndDefineOutputs is going to be stripped from 'output defining'
logic, replace all relevant occurrences with virLogSetOutputs call to make the
change transparent to all original callers (daemons mostly).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Michal Privoznik
c41b989112 virDomainDefParse{File,String}: Introduce @parseOpaque argument
We want to pass the proper opaque pointer instead of NULL to
virDomainDefParse and subsequently virDomainDefParseNode too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-26 16:50:12 +02:00
Laine Stump
4e2d642afb tests: fix use of fixedcontent variable
Commit 8563560026 switched from
hardcoded use of strcontent to hardcoded use of fixedcontent
(fixedcontent is *sometimes* a copy of strcontent with a \n
appended). This was a problem because sometimes fixedcontent is *not*
a copy of strcontent, but is instead NULL, leading to the regenerated
test case output being a 0 length file.

This patch creates a new const char *cmpcontent initialized to
strcontent, but changed to fixedcontent if/when fixedcontent is
created, then always uses cmpcontent instead of (str|fixed)content.
2016-09-19 17:22:26 -04:00
Martin Kletzander
8563560026 tests: Use fixedcontent variable
Commit ca32929908 added function
virTestCompareToFile(), but forgot to use a fixedcontent value for the
actual comparison.  That lead to VIR_TEST_DEBUG=1 showing (for some
tests) all the actual output from the first error to the end of the
string due to the difference being an endline in the end.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-15 11:24:32 +02:00
Peter Krempa
5847bc5c64 conf: Add XML for individual vCPU hotplug
Individual vCPU hotplug requires us to track the state of any vCPU. To
allow this add the following XML:

<domain>
  ...
  <vcpu current='2'>3</vcpu>
  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='yes' hotpluggable='yes' order='2'/>
    <vcpu id='1' enabled='no' hotpluggable='yes'/>
  </vcpus>
  ...

The 'enabled' attribute allows to control the state of the vcpu.
'hotpluggable' controls whether given vcpu can be hotplugged and 'order'
allows to specify the order to add the vcpus.
2016-08-24 15:44:47 -04:00
Ján Tomko
cc04181a7c testutils: only rewrap args files
test-wrap-argv.pl does not know how to rewrap other files.
2016-07-12 12:15:50 +02:00
Ján Tomko
bd6708a862 testutils: find perl early
Commit 843a70a changed test-wrap-argv.pl to use
/usr/bin/env perl
instead of
/usr/bin/perl

However when called from qemuxml2argvtest with
VIR_TEST_REGENERATE_OUTPUT, PATH is set to '/bin'.

Find the path to perl early in virTestMain, in case we
are going to need it later after we've overridden PATH.
2016-07-12 12:15:50 +02:00
Peter Krempa
cb049b9ad4 tests: utils: Fail XML file comparison if input file doesn't exist
In cases where we expect parse failure of the test input file the
testsuite can't differentiate if the parser failed when parsing or when
opening the file. Add a call to virFileExists and error out on missing
input files.

Missing output files are partially expected when regenerating test
output.
2016-06-23 21:11:32 +02:00
Ján Tomko
f46fb819a9 test-wrap-argv: add --in-place parameter
If --in-place is supplied as the first argument to the script,
replace the file in-place instead of printing to stdout.
2016-06-21 18:13:07 +02:00
Ján Tomko
0cd5a726e3 Allow disjunct ranges in VIR_TEST_RANGE
Use virBitmapParseUnlimited to parse the env variable.
2016-06-20 12:09:52 +02:00
Jim Fehlig
53d98ccea7 xenconfig: support bios=ovmf xl.cfg
Add support to xenconfig for conversion of xl.cfg(5) bios config
to/from libvirt domXml <loader> config. SeaBIOS is the default
for HVM guests using upstream QEMU. ROMBIOS is the default when
using the old qemu-dm. This patch allows specifying OVMF as an
alternate firmware.

Example xl.cfg:
  bios = "ovmf"

Example domXML:
  <os>
    ...
    <loader readonly='yes' type='pflash'>/usr/lib/xen/boot/ovmf.bin</loader>
  </os>

Note that currently Xen does not support a separate nvram for
non-volatile variables.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-06-13 14:13:17 -06:00
Tomáš Ryšavý
1a41ed5af5 tests: Rename virtTestMain to virTestMain.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:13 -04:00
Tomáš Ryšavý
6151dc2f55 tests: Rename virtTestErrorFuncQuiet to virTestErrorFuncQuiet.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:13 -04:00
Tomáš Ryšavý
f5444742b0 tests: Rename virtTestCounterNext to virTestCounterNext.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:13 -04:00
Tomáš Ryšavý
75f7309468 tests: Rename virtTestCaptureProgramOutput to virTestCaptureProgramOutput.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:13 -04:00
Tomáš Ryšavý
65979e5b62 tests: Rename virtTestDifferenceBin to virTestDifferenceBin.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
b468e8ba0b tests: Rename virtTestCaptureProgramExecChild to virTestCaptureProgramExecChild.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
5d36423993 tests: Rename virtTestDifferenceFullInternal to virTestDifferenceFullInternal.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
9b8ff67fc0 tests: Rename virtTestDifferenceFullNoRegenerate.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
1ff86b408a tests: Rename virtTestQuiesceLibvirtErrors to virTestQuiesceLibvirtErrors.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
c2f36506b7 tests: Rename virtTestUseTerminalColors to virTestUseTerminalColors.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
d77e453a01 tests: Rename virtTestLogContentAndReset to virTestLogContentAndReset.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
327b844341 tests: Rename virtTestCounterReset to virTestCounterReset.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
8a48cf6efa tests: Rename virtTest00MActive to virTest00MActive.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
8a9bd034c2 tests: Rename virtTestClearCommandPath to virTestClearCommandPath.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
753edcb3a4 Rename virtTestDifferenceFull to virTestDifferenceFull.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
239caffb1d tests: Rename virtTestCompareToFile to virTestCompareToFile.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
401bb813bd Rename virtTestLoadFile to virTestLoadFile.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
062ea148a0 Rename virtTestDifference to virTestDifference.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Tomáš Ryšavý
cd7dd1508d tests: Rename virtTestRun to virTestRun.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Peter Krempa
f0469c61e3 tests: Allow multiple mock libraries
Make virtTestMain take variable number of libraries to mock.
2016-05-20 11:09:05 -04:00
Michal Privoznik
6326865e6b virtestmock: Print invalid file accesses into a file
All the accesses to files outside our build or source directories
are now identified and appended into a file for later processing.
The location of the file that contains all the records can be
controlled via VIR_TEST_FILE_ACCESS env variable and defaults to
abs_builddir "/test_file_access.txt".

The script that will process the access file is to be added in
next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-14 09:46:23 +02:00
Cole Robinson
c493d21642 tests: Enable failure testing with CompareDomXML2XML
This allows tests to check for specific failure scenarios
2016-04-14 12:25:57 -04:00
Michal Privoznik
ee70fe7e14 virTestSetEnvPath: Avoid clearing out PATH
If the abs_builddir path already is in PATH and it's in the first
position, due to a bug in our code PATH would be cleared out.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-25 10:20:28 +01:00
Michal Privoznik
98354e362c testutils: Adapt to highly unlikely case
Coverity pointed out that getenv("PATH") may return NULL. Well,
we check for that in virFindFileInPath() too. If this happens, we
will pass NULL into strstr(). Ouch.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-24 17:35:14 +01:00
Michal Privoznik
363b401f94 tests: Set PATH in each test
Currently we spawn couple of binaries in our test suite.
Moreover, we provide some spoofed versions of system binaries
hoping that those will be executed instead of the system ones.
For instance, for testing SSH socket we have written our own ssh
binary for producing predictable results. We certainly don't want
to execute the system ssh binary.
However, in order to prefer our binaries over system ones, we
need to set PATH environment variable. But this is done only at
the Makefile level. So if anybody runs a test by hand that
expects our spoofed binary, the test ends up executing real
system binaries. This is not good. In fact, it's terribly wrong.
The fix lies in a small trick - putting our build directory at
the beginning of the PATH environment variable in each test.
Hopefully, since every test has this VIRT_TEST_MAIN* wrapper, we
can fix this at a single place.
Moreover, while this removes setting PATH for our tests written
in bash, it's safe as we are not calling anything ours that would
require PATH change there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 11:38:37 +01:00
Michal Privoznik
865764de06 Drop paths.h include
We include the file in plenty of places. This is mostly due to
historical reasons. The only place that needs something from the
header file is storage_backend_fs which opens _PATH_MOUNTED. But
it gets the file included indirectly via mntent.h. At no other
place in our code we need _PATH_.*. Drop the include and
configure check then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 09:43:45 +01:00
Ján Tomko
1d6dcec080 testCompareDomXML2XMLFiles: add parseFlags parameter
Allow testing XML parsing with different flags.
2016-02-26 09:47:45 +01:00
Cole Robinson
ad8590905e tests: Remove unused virtTestClearLineRegex
This was only used for test 'xml blanking', which has now all
been removed, and isn't an ideal paradigm anyways since it
inhibits easy XML regeneration.
2016-02-17 11:07:21 -05:00
Cole Robinson
8e0fd243f8 tests: utils: Add PreFormat callback for CompareXML2XML helper
This allows individual driver tests to hook in their own code before
the def is formatted and compared.

We will eventually use this in the qemuxml2xml
2016-02-09 16:09:01 -05:00
Cole Robinson
3e9033f78a tests: Run test-wrap-argv with REGENERATE_OUTPUT
To get properly wrapped output
2016-02-05 15:07:07 -05:00
Joao Martins
d239a5427f conf: add caps to virDomainDefFormat*
And use the newly added caps->host.netprefix (if it exists) for
interface names that match the autogenerated target names.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-02-04 12:38:26 +00:00
Cole Robinson
ebfd6f45c3 testutils: Fix coverity warning with REGENERATE_OUTPUT
- Don't double check for expectName
- actual is always non-NULL by this point, so don't check it either
2016-01-12 11:30:19 -05:00
Cole Robinson
5770c17074 tests: Share domain XML2XML compare helper
This creates a shared function in testutils.c that consolidates all
the slightly different implementations.
2016-01-08 21:21:34 -05:00
Cole Robinson
825d357a46 tests: Add newlines with VIR_TEST_REGENERATE_OUTPUT
Since test files are formatted predictably nowadays, we can make
VIR_TEST_REGENERATE_OUTPUT handle most cases for us with a simple
replacement. test-wrap-argv.pl is still canon, but this bit makes
it easier to confirm test output changes during active development.
2016-01-08 21:21:34 -05:00
Pavel Hrdina
c060f44c16 tests.testutils: use virTestDifferenceFull in virtTestCompareToFile
Let's use the new virTestDifferenceFull function that will regenerate
the expected output and fail the test to let developer know that there
something was updated.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-01-08 16:08:15 +01:00
Pavel Hrdina
781d70c027 tests.testutils: use VIR_TEST_REGENERATE_OUTPUT for virTestDifferenceFull
This patch enable regeneration of expected output file for
virTestDifferenceFull.  It also introduces new
virTestDifferenceFullNoRegenerate function for special cases, where we
don't want to regenerate output.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-01-08 16:08:15 +01:00
Pavel Hrdina
0104c43195 tests: add helper for VIR_TEST_REGENERATE_OUTPUT flag
When this flag is specified, some of the expected output files will be
regenerated with the actual output data.  Use helper function like for
other flags.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-01-08 16:05:26 +01:00
Cole Robinson
bb5fc5c778 testutils: Drop virtTestResult
virtTestResult is suboptimal for a few reasons:

- It poorly duplicates virtTestRun pass/fail reporting logic
- It doesn't have virtTestRun's alloc testing support
- It only reports the test name _after_ the test has run.
- It doesn't follow the standard virtTestRun pattern that most other
  tests use.

There's no users left, so drop it. If any other async tests like eventtest
spring up that don't cleanly fit the virtTestRun pattern, I suggest they
just open code the support for it around virtTestRun
2015-10-05 14:34:04 -04:00
Cole Robinson
3de074efa5 testutils: Add coloring to verbose PASS/FAILED output
Helps to visually track down test failures if debugging the test suite.

The colors match what 'make check' does for pass/fail/skip
2015-10-05 14:34:04 -04:00