Commit Graph

16 Commits

Author SHA1 Message Date
Peter Krempa
f0fec72e3f qemuTestCapsCacheInsert*: Drop the file cache rather than poisoning it
Make callers use virFileCacheClear to clear the cache before populating
it rather than trying to overwrite what's in it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-03-06 20:55:50 +01:00
Andrea Bolognani
d3fe9cc0f0 tests: Set the QEMU driver as privileged in common code
Most test programs were already doing this, and moving it to
the common code ensures we see consistent behavior across all
QEMU tests.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-03-06 14:35:35 +01:00
Andrea Bolognani
87b30e6965 tests: Move fakerootdir handling to common logic
Instead of having each test manually initialize and cleanup
its own fakerootdir, do that as part of the common test
initialization logic in virTestMain().

In most cases we can simply drop the relevant code from the
test program, but scsihosttest uses the value of fakerootdir
as a starting point to build another path, so we need to do
things slightly differently. In order to keep things working,
we retrieve the value from the LIBVIRT_FAKE_ROOT_DIR
environment variable, same as all the mock libraries are
already doing.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-03 13:52:37 +01:00
Andrea Bolognani
457a0183d6 tests: Adopt fakerootdir helpers
Most replacements are completely straightforward but
vircgrouptest requires slightly different handling because,
instead of initializing a single fakerootdir at the start of
the test program and cleaning it up at the end, it creates
multiple different ones one after the other.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2023-03-03 13:52:37 +01:00
Jonathon Jongsma
62ca300530 util: remove virObjectUnref() adapters
These wrapper functions were used to adapt the virObjectUnref() function
signature for different callbacks. But in commit 0d184072, the
virObjectUnref() function was changed to return a void instead of a
bool, so these adapters are no longer necessary.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2022-07-15 16:44:39 -05:00
Michal Privoznik
9f28af4920 test: Drop unused @cfg from qemu*test
In qemumigrationcookiexmltest and qemustatusxml2xmltest there is
@cfg variable that is unused. It's set via virQEMUDriverGetConfig()
but then never used. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-08-26 09:16:44 +02:00
Ján Tomko
e431293d74 tests: qemuxml2*test: switch to virTestRunLog
This essentially reverts:
commit ca5c8e1dc7
    qemuxml2argvtest: Avoid conditions in test macro

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Peter Krempa
ca5c8e1dc7 qemuxml2argvtest: Avoid conditions in test macro
Pass a pointer to the 'ret' variable to the test executor itself and
update it there to improve compile times of the test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
68bb5f9fa6 testutilsqemu: Improve error propagation from 'testQemuInfoSetArgs'
Previously we've ran into problems when 'testQemuInfoSetArgs' failed as
calling the actual test executor could lead to a crash if the data
wasn't prepared but reporting an error doesn't play nicely with our test
output which is handled by 'virTestRun'.

To avoid the issue (and as a side effect improve compilation times of
the test files) split up testQemuInfoSetArgs into two functions.

The first is still called 'testQemuInfoSetArgs' and just blindly
populates arguments into a sub-struct of testQemuInfo. This function no
longer reports errors

A new function 'testQemuInfoInitArgs' which is meant to be called from
the test executor then checks errors and prepares the test data. This
one can fail and the test will be marked as failed appropriately.

A nice side effect is that this vastly improves compile times of
qemuxml2xmltest and qemuxml2argvtest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
92e0cd2620 testutilsqemu: Introduce struct to hold data valid for all test runs
We pass multiple caching objects to individual tests which don't change.
To prevent always having to pass them individually to
'testQemuInfoSetArgs' introduce 'struct testQemuConf' which will hold
all of them and just the struct will be passed to the tests.

Additionally this will make the conf available from inside the test run.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:49 +02:00
Peter Krempa
7eeb50fd33 qemustatusxml2xmltest: Remove hack for qemuCaps allocation
Since qemuCaps are now always allocated we don't need the hack.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-18 10:20:48 +02:00
Michal Privoznik
c8238579fb lib: Drop internal virXXXPtr typedefs
Historically, we declared pointer type to our types:

  typedef struct _virXXX virXXX;
  typedef virXXX *virXXXPtr;

But usefulness of such declaration is questionable, at best.
Unfortunately, we can't drop every such declaration - we have to
carry some over, because they are part of public API (e.g.
virDomainPtr). But for internal types - we can do drop them and
use what every other C project uses 'virXXX *'.

This change was generated by a very ugly shell script that
generated sed script which was then called over each file in the
repository. For the shell script refer to the cover letter:

https://listman.redhat.com/archives/libvir-list/2021-March/msg00537.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-13 17:00:38 +02:00
Peter Krempa
4865dd673d qemu*xml2*test: Cache capabilities between tests
Invoking the XML parser every time is quite expensive. Since we have a
deep copy function for 'virQEMUCapsPtr' object, we can cache the parsed
results lazily.

This brings significant speedup to qemuxml2argvtest:

real	0m2.234s
user	0m2.140s
sys	0m0.089s

vs.

real	0m1.161s
user	0m1.087s
sys	0m0.072s

qemuxml2xmltest benefits too:

real	0m0.879s
user	0m0.801s
sys	0m0.071s

vs.

real	0m0.466s
user	0m0.424s
sys	0m0.040s

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
2021-02-20 13:28:50 +01:00
Peter Krempa
add6ee37ee tests: qemustatusxml2xml: Add status XML from migration with bitmaps
The XML sample shows the status XML when migrating with bitmaps
including the <tempBlockDirtyBitmaps> element added in previous commit.

It will also be used for the migration cookie test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2021-02-20 13:21:21 +01:00
Peter Krempa
1841cfa49e qemustatusxml2xmltest: Remove 'virdeterministichash' mocking
Commit 89a3115bac was not updated after recent changes to
hash table usage and was still referencing the now removed deterministic
hash mock, which caused CI failure.

Fixes: 89a3115bac
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2020-11-09 13:23:25 +01:00
Peter Krempa
89a3115bac qemuxml2xmltest: Split out status XML testing to qemustatusxml2xmltest.c
Separate the test files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-11-09 12:25:49 +01:00