[libvirt] [PATCH v2 0/3] Implement mockup capabilities cache in QEMU tests

Pavel Fedin p.fedin at samsung.com
Wed Sep 9 14:03:13 UTC 2015

Since commit e8d55172544c1fafe31a9e09346bdebca4f0d6f9 qemu driver checks
emulator capabilities during domain XML post-parse. However, test suite
does not initialize it, therefore a condition to skip all checks if there
is no cache supplied was added. This is actually a hack, whose sole
purpose is to make existing test suite working. Additionally, it prevents
from writing new tests for this particular functionality.

This series solves this problem by implementing proper cache mockup in test
suite. The main idea is to create a cache in standard way and put there
pre-defined capabilities sets (which tests already have).

In this implementation we introduce "test capability sets", which are named
entities. virQEMUCapsCacheLookup() now has a test mode, which is enabled
by setting qemuTestCapsName variable to the name of capability set which
we want to use in current test. This is based on Martin Kletzander's idea
to implement test mode with assertions. Currently, since name of capability
set is different from /usr/bin/something, we will get errors if we try to
do something with the host filesystem. This is achieved by setting cacheDir
and libDir of our mockup cache to "/dev/null".

The concept of using named capability sets allows us to further improve the
test suite. Now it is possibe to get rid of hardcoded capability sets
and replace them with XML files, readable by virQEMUCapsInitCached().
This will allow us to better exercise our capabilities parser. Taking this
into account, qemuTestCapsCacheInsert() is actually temporary. It will not
be needed any more when capabilities are moved to XML files.

Additionally, some small refactoring is done, and common driver
initialization and cleanup sequence is put into two functions:
qemuTestDriverInit() and qemuTestDriverFree().

V1 => V2
- Fix also domainsnapshotxml2xmltest

RFC => v1
- Major rework, almost everything changed.

Pavel Fedin (3):
  Implement infrastracture for mocking up QEMU capabilities cache
  Use mockup cache
  Removed unneeded check

 src/qemu/qemu_capabilities.c      | 16 +++++-----
 src/qemu/qemu_capspriv.h          | 36 +++++++++++++++++++++++
 src/qemu/qemu_domain.c            |  5 +---
 tests/domainsnapshotxml2xmltest.c | 15 +++++-----
 tests/qemuagenttest.c             | 18 ++++++++----
 tests/qemuargv2xmltest.c          | 19 ++++++------
 tests/qemuhotplugtest.c           | 32 ++++++++++----------
 tests/qemuxml2argvtest.c          | 17 +++++------
 tests/qemuxml2xmltest.c           | 16 ++++++----
 tests/qemuxmlnstest.c             | 17 ++++++-----
 tests/testutilsqemu.c             | 62 +++++++++++++++++++++++++++++++++++++++
 tests/testutilsqemu.h             |  9 ++++++
 12 files changed, 190 insertions(+), 72 deletions(-)
 mode change 100644 => 100755 src/qemu/qemu_capabilities.c
 create mode 100644 src/qemu/qemu_capspriv.h
 mode change 100644 => 100755 tests/qemuagenttest.c
 mode change 100644 => 100755 tests/qemuargv2xmltest.c
 mode change 100644 => 100755 tests/qemuhotplugtest.c
 mode change 100644 => 100755 tests/qemuxml2argvtest.c
 mode change 100644 => 100755 tests/qemuxml2xmltest.c
 mode change 100644 => 100755 tests/qemuxmlnstest.c
 mode change 100644 => 100755 tests/testutilsqemu.c
 mode change 100644 => 100755 tests/testutilsqemu.h


More information about the libvir-list mailing list