Commit Graph

418 Commits

Author SHA1 Message Date
Martin Kletzander
ae885bb520 tests: Add virresctrltest
This test initializes capabilities from vircaps2xmldata (since it exists there
already) and then requests list of free bitmaps (all unallocated space) from
virresctrl.c

Desirable outputs are saved in virresctrldata.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-25 17:16:08 +01:00
Martin Kletzander
e399641561 tests: Remove pointless _CFLAGS variables
If _CFLAGS for a binary is not specified it uses AM_CFLAGS.  So doing

  $binary_CFLAGS = $(AM_CFLAGS)

or

  $binary_CFLAGS = $(AM_CFLAGS) $(something_that_is_already_in_AM_CFLAGS)

is pointless.  So remove it for cleaner Makefile.am

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
74a13be4a4 build: Use XDR_CFLAGS in more places
Since update to glibc-2.26 removed the /usr/include/rpc/rpc.h we used until now,
it showed us a problem with not using XDR_CFLAGS properly.  On linux that
variable has usually -I/usr/include/tirpc because we already probe for it
properly, we just don't use it everywhere we need.  It is needed by wireshark
dissector as well as testutilsqemu.c (through includes) so the build fails with:

wireshark/src/packet-libvirt.c:33:10: fatal error: rpc/xdr.h: No such file or directory
 #include <rpc/xdr.h>
          ^~~~~~~~~~~

and

In file included from ../src/logging/log_manager.h:29:0,
                 from ../src/qemu/qemu_domain.h:40,
                 from testutilsqemu.c:11:
../src/logging/log_protocol.h:9:10: fatal error: rpc/rpc.h: No such file or directory
 #include <rpc/rpc.h>
          ^~~~~~~~~~~

Since lot of tests use testutilsqemu.c it is easier to add XDR_CFLAGS to
AM_CFLAGS than adding it to all $binary_CFLAGS.  It's just for tests and we
already have bunch of CFLAGS there anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-11-18 10:45:10 +01:00
Peter Krempa
96be3e72e8 tests: Add testing of storage backend JSON props formatter
Add a new test program called 'qemublocktest' to test the block layer
related stuff and test storage source to JSON generator by comparing it
to the JSON parser.
2017-11-07 16:18:14 +01:00
Andrea Bolognani
3e7db8d3e8 Remove backslash alignment attempts
Right-aligning backslashes when defining macros or using complex
commands in Makefiles looks cute, but as soon as any changes is
required to the code you end up with either distractingly broken
alignment or unnecessarily big diffs where most of the changes
are just pushing all backslashes a few characters to one side.

Generated using

  $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
    grep -E '*\.([chx]|am|mk)$$' | \
    while read f; do \
      sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
    done

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-11-03 13:24:12 +01:00
Daniel P. Berrange
eae746b2d7 Stop linking tests/commandhelper to libvirt code
The commandhelper binary is a helper for commandtest that
validates what file handles were inherited. For this to
work reliably we must not have any libraries that leak
file descriptors into commandhelper. Unfortunately some
versions of gnutls will intentionally open file handles
at library load time via a constructor function.

We previously hacked around this in

  commit 4cbc15d037
  Author: Martin Kletzander <mkletzan@redhat.com>
  Date:   Fri May 2 09:55:52 2014 +0200

    tests: don't fail with newer gnutls

    gnutls-3.3.0 and newer leaves 2 FDs open in order to be backwards
    compatible when it comes to chrooted binaries [1].  Linking
    commandhelper with gnutls then leaves these two FDs open and
    commandtest fails thanks to that.  This patch does not link
    commandhelper with libvirt.la, but rather only the utilities making
    the test pass.

    Based on suggestion from Daniel [2].

    [1] http://lists.gnutls.org/pipermail/gnutls-help/2014-April/003429.html
    [2] https://www.redhat.com/archives/libvir-list/2014-April/msg01119.html

That fix relied on fact that while libvirt.so linked with
gnutls, libvirt_util.la did not link to it.  With the
introduction of the util/vircrypto.c file that assumption
is no longer valid. We must not link to libvirt_util.la
at all - only gnulib and libc can (hopefully) be relied
on not to open random file descriptors in constructors.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-09-20 14:32:12 +01:00
John Ferlan
407e6a3678 storage: Introduce virStoragePoolObjNew
Create/use a helper to perform object allocation.

Adjust storagevolxml2argvtest.c in order to use the allocator and
setting of the obj->def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-09-19 08:28:38 -04:00
Jim Fehlig
d8e8b63d30 libxl: Add a test suite for libxl_domain_config generator
The libxl library allows a libxl_domain_config object to be serialized
from/to a JSON string. Use this to allow testing of the XML to
libxl_domain_config conversion process. Test XML is converted to
libxl_domain_config, which is then serialized to json. A json template
corresponding to the test XML is converted to a libxl_domain_config
object using libxl_domain_config_from_json(), and then serialized
back to json using libxl_domain_config_to_json(). The two json
docs are then compared.

Using libxl to convert the json template to a libxl_domain_config
object and then back to json provides a simple way to account for
any changes or additions to the json representation across Xen
releases.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
[update to v3.5.0-rc1, improve error reporting, use /bin/true emulator]
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2017-08-04 10:17:55 -06:00
Peter Krempa
259a16d514 tests: Run virdrivermoduletest only when WITH_LIBVIRTD is defined
The test makes sense only when building the daemon, thus run it only in
such case.
2017-07-28 17:53:03 +02:00
Peter Krempa
d3f1930b54 tests: Run virt-aa-helper-test only when the helper was compiled
'virt-aa-helper' is compiled when both WITH_LIBVIRTD and
WITH_SECDRIVER_APPARMOR are defined. The test was run only when
WITH_SECDRIVER_APPARMOR was defined thus causing a build failure when
building without the daemon.
2017-07-28 17:53:03 +02:00
Pavel Hrdina
aceb74cbd7 Revert "build: distribute tests/virfilecachedata"
This reverts commit d3d422e00c.

Already fixed by commit 5a30b817ec.
2017-07-27 12:08:13 +02:00
Pavel Hrdina
d3d422e00c build: distribute tests/virfilecachedata
Missed by 478f0c5b85.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-07-27 12:04:46 +02:00
Peter Krempa
5aec02dc37 make: Drop building without driver modules
Driver modules proved to be reliable for a long time. Since support for
not building modules complicates the code and makefiles drop it.

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
2017-07-27 12:00:35 +02:00
Daniel P. Berrange
5a30b817ec tests: add virfilecachedata to EXTRA_DIST
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-07-27 10:56:20 +01:00
Peter Krempa
4983368367 tests: Extract mock library for making hash table deterministic
virHashNew calls virRandomBits to initialize seed for the hashing
function. If a test uses iteration through the hash table to produce
results they may/will be non-deterministic. Extract the mock library
which was used for mac address mapping to be universal.

Reviewed-by: Eric Blake <eblake@redhat.com>
2017-07-27 09:54:20 +02:00
Martin Kletzander
0ca4e369bb build: Distribute tests/{qemucpumock.c,testutilshostcpus.h}
Missed by 13554a9e7f.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-07-26 17:37:41 +02:00
Pavel Hrdina
478f0c5b85 tests: add virfilecachetest
Implements 3 test cases that covers how the cache is used.

We have to mock unlink() function because the caching code unlinks
files that are no longer valid and we don't want to do it in our tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2017-07-26 15:33:45 +02:00
Ján Tomko
255cd95aab test/Makefile.am: drop WARN_CFLAGS from LDFLAGS
Introduced by commit 0832c58, with the intention to link with
the stack protector library.

Another instance introduced by commit 4cbc15d which separated
commandhelper_LDADD from LDADDS.

Not needed because per commit 71b54636, automake should pass
all the CFLAGS to the linker.
2017-07-19 10:27:07 +02:00
Daniel P. Berrange
14c5673d61 tests: add virjsondata to EXTRA_DIST
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-07-13 10:46:38 +01:00
Peter Krempa
9f0b7e99c5 tests: Rename jsontest to virjsontest 2017-07-11 14:02:28 +02:00
Michal Privoznik
2a13a0a103 qemu: Query for vhostuser iface names at runtime
https://bugzilla.redhat.com/show_bug.cgi?id=1459091

Currently, we are querying for vhostuser interface name in post
parse callback. At that time interface might not yet exist.
However, it has to exist when starting domain. Therefore it makes
more sense to query its name at that point. This partially
reverts 57b5e27.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-06-08 15:02:22 +02:00
Daniel P. Berrange
4a1a4be37e Add missing deps on virfilewrapper.h
The test programs depend on virfilewrapper.h as well as the
virfilewrapper.c. Adding the dep ensures that virfilewrapper.h
gets included in the dist tarball.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-05-10 16:15:05 +01:00
Martin Kletzander
7008e10869 util: Remove virsysfs and instead enhance virFileReadValue* functions
It is no longer needed thanks to the great virfilewrapper.c.  And this
way we don't have to add a new set of functions for each prefixed
path.

While on that, add two functions that weren't there before, string and
scaled integer reading ones.  Also increase the length of the string
being read by one to accompany for the optional newline at the
end (i.e. change INT_STRLEN_BOUND to INT_BUFSIZE_BOUND).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00
Martin Kletzander
ae60ea48bc tests: Add virfilewrapper -- the new super "mock"
This mock (which is actually not mock at all, see later) can redirect
all accesses to a path into another path.  There is no need to
create mocks for particular directories, you just create a directory
with all the data a redirect the test there.

In the future, this should also be able to register callbacks for
calls/paths, e.g. when the test is going to write into anything under
"/sys/devices", call function fce();  Then in the open() call we would
add information about the fd into some structure and in write() we
would call fce() with parameters like @path to write to, @data to
be written and pointer to optional return value, so that fce() itself
could stop the call from happening or change its behaviour.  But
that's an idea for a latter day.

This is not a mock because it will not be preloaded, but compiled in
the test itself.  See future patches for usage.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00
Ján Tomko
e73889b631 Split out -Wframe-larger-than warning from WARN_CLFAGS
Introduce STRICT_FRAME_LIMIT_CFLAGS that will be used for
production code and RELAXED_FRAME_LIMIT_CFLAGS for tests.

Raising the limit for tests allows building them with clang
with optimizations disabled.
2017-04-06 12:29:35 +02:00
Peter Krempa
69cc498676 test: Introduce testing of virStorageUtilGlusterExtractPoolSources
Add a test program called virstorageutiltest and test the gluster pool
detection code.
2017-04-04 16:36:10 +02:00
Andrea Bolognani
8cfe7d977a tests: Introduce QEMU memory locking limit tests
These tests cover a number of scenarios where we care about
the memory locking limit being set correctly for the guest
to work properly.
2017-03-28 10:54:50 +02:00
Martin Kletzander
452f014abf Build vircaps2xmltest and requirements only on Linux
The mock, as well as the test, is only available on Linux.  So skip
building it everywhere else, especially when it fails on mingw.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 22:38:40 +02:00
Martin Kletzander
9368095bb8 tests: Add virnumamock
All mocked functions are related to numactl/virNuma and rely only on
virsysfs, so the paths they touch can be nicely controlled.  And
because it is so nicely self-contained NUMA mock, it is named
numamock (instead of naming it after the test that will use it first).

We need top level API mock because some APIs might call libnuma
directly, e.g. virNumaIsAvailable(), virNumaGetMaxNode().

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-03-27 13:13:29 +02:00
Roman Bogorodskiy
74cfb5bb85 domaincapstest: add bhyve caps test
* Extract filling bhyve capabilities from virBhyveDomainCapsBuild()
   into a new function virBhyveDomainCapsFill() to make testing
   easier by not having to mock firmware directory listing and
   hypervisor capabilities probing
 * Also, just presence of the firmware files is not sufficient
   to enable os.loader.supported, hypervisor should support UEFI
   boot too
 * Add tests to domaincapstest for the main caps possible flows:
    - when UEFI bootrom is supported
    - when video (fbus) is supported
    - neither of above is supported
2017-03-26 18:44:46 +04:00
Jiri Denemark
e958fb5b15 qemu: Report better host-model CPUs in domain caps
One of the main reasons for introducing host-model CPU definition in a
domain capabilities XML was the inability to express disabled features
in a host capabilities XML. That is, when a host CPU is, e.g., Haswell
without x2apic support, host capabilities XML will have to report it as
Westmere + a bunch of additional features., but we really want to use
Haswell - x2apic when creating a host-model CPU.

Unfortunately, I somehow forgot to do the last step and the code would
just copy the CPU definition found in the host capabilities XML. This
changed recently for new QEMU versions which allow us to query host CPU,
but any slightly older QEMU will not benefit from any change I did. This
patch makes sure the right CPU model is filled in the domain
capabilities even with old QEMU.

The issue was reported in
https://bugzilla.redhat.com/show_bug.cgi?id=1426456

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-03-13 23:49:57 +01:00
Peter Krempa
0a6d3e51b4 storage: Turn storage backends into dynamic modules
If driver modules are enabled turn storage driver backends into
dynamically loadable objects. This will allow greater modularity for
binary distributions, where heavyweight dependencies as rbd and gluster
can be avoided by selecting only a subset of drivers if the rest is not
necessary.

The storage modules are installed into 'LIBDIR/libvirt/storage-backend/'
and users can override the location by using
'LIBVIRT_STORAGE_BACKEND_DIR' environment variable.

rpm based distros will at this point install all the backends when
libvirt-daemon-driver-storage package is installed.
2017-02-22 09:31:33 +01:00
John Ferlan
e8a35271d4 tests: Link virusbmock with probes
Seeing similar error to commit id '997be5c27' with the inability
to find the libvirt_event_poll_purge_timeout_semaphore symbol
causing a virusbtest failure.
2017-02-10 10:55:26 -05:00
Michal Privoznik
eb58732c01 virusbmock: Link with libvirt_utils
We are using couple of functions from there (e.g. virStrdup) and
rely that the binary linking us has the libvirt_utils linked
already. Well, this makes valgrind sad.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-02-10 10:25:44 +01:00
Michal Privoznik
a9595814ed tests: Trace re-executing processes with valgrind
A lot of our tests re-execute themeselves after loading their
mock library. This, however, makes valgrind sad because currently
we do not tell it to trace the process after exec().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-02-10 10:25:44 +01:00
Michal Privoznik
57b5e27d3d qemu: set default vhost-user ifname
Based on work of Mehdi Abaakouk <sileht@sileht.net>.

When parsing vhost-user interface XML and no ifname is found we
can try to fill it in in post parse callback. The way this works
is we try to make up interface name from given socket path and
then ask openvswitch whether it knows the interface.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-01-20 15:42:12 +01:00
Jim Fehlig
b018ada330 tests: fix compilation of shunloadtest
While local builds succeed fine, a build worker building in a
chroot environment is encountering the following error with
libvirt 3.0.0 release candidates

[  162s] shunloadtest.o: In function `main':
[  162s] /home/abuild/rpmbuild/BUILD/libvirt-3.0.0/tests/shunloadtest.c:110: undefined reference to `dlopen'
[  162s] /home/abuild/rpmbuild/BUILD/libvirt-3.0.0/tests/shunloadtest.c:114: undefined reference to `dlsym'
[  162s] /home/abuild/rpmbuild/BUILD/libvirt-3.0.0/tests/shunloadtest.c:133: undefined reference to `dlclose'
[  162s] /home/abuild/rpmbuild/BUILD/libvirt-3.0.0/tests/shunloadtest.c:111: undefined reference to `dlerror'
[  162s] /home/abuild/rpmbuild/BUILD/libvirt-3.0.0/tests/shunloadtest.c:115: undefined reference to `dlerror'
[  162s] /home/abuild/rpmbuild/BUILD/libvirt-3.0.0/tests/shunloadtest.c:116: undefined reference to `dlclose'

Fix by appending DLOPEN_LIBS to shunloadtest_LDADD.
2017-01-18 15:59:00 -07:00
Michal Privoznik
1cbcbd3746 tests: Distribute qemuhotplugtestcpus
Starting from a245abce43 another set of tests for
qemuhotplugtest has been introduced. This time for vcpu hotplug.
However, the test data (which live in qemuhotplugtestcpus dir)
are not being distributed properly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-01-18 11:49:02 +01:00
Michal Privoznik
a94769ce27 tests: Run nss*test iff WITH_NSS
If the nss module is disabled we shouldn't run the tests that
include it either.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-01-02 13:25:42 +01:00
Michal Privoznik
9a3dd116a6 tests: Move test_libraries a bit higher
In the Makefile in tests/ we initialize couple of variables like
test_programs, test_libraries and test_helpers. These variables
contain all the targets that we need to build in order to run
the test suite. So we initialize test_programs and test_helpers
and then conditionally add targets to them depending on what we
are building with. Then we repeat the same process with
test_libraries. It makes no sense to have two separate if-endif
sequences.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-01-02 13:25:42 +01:00
Michal Privoznik
00c4970435 tests: Run virmacmaptest iff WITH_YAJL
Since the internal implementation relies on a json parser being
available, it make no sense to run this test if there's none
available.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-01-02 13:25:42 +01:00
Michal Privoznik
22f7ceb695 nss: Introduce libvirt-guest module
So far the NSS module looks up only hostnames as provided by
guests themselves. However, there are some cases where this is
not enough: e.g. when there's a fresh new guest being installed
(with some generic hostname) say from a live ISO image; or some
(older) systems don't advertise their hostname in DHCP
transactions at all.
In cases like that it would be helpful if we translate domain
name as seen by libvirt too so that users can:

  # virsh start $dom && ssh $dom

In order to achieve that new libvirt-guest module is introduced,
while older libvirt module maintains its current behaviour (that
is translating guest provided names into IP addresses).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-12-06 13:34:00 +01:00
Michal Privoznik
86980bc75c util: Introduce virMACMap module
This module will be used to track:

  <domain, mac address list>

pairs. It will be important to know these mappings without
libvirt connection (that is from a JSON file), because NSS
module will use those to provide better host name translation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-12-06 13:33:18 +01:00
Roman Bogorodskiy
0d1c147f60 tests: eventtest: fix LDADD
Don't explicitly LDADD -lrt, use $(LIB_CLOCK_GETTIME) because
not all platforms have clock_gettime(2) and librt available.
2016-11-24 18:10:13 +03:00
Michal Privoznik
4a457adda6 tests: Self test virt-admin
Just like we are running 'virsh self-test' from within our test
suite, we should run 'virt-admin self-test' too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-14 13:18:07 +02:00
Roman Bogorodskiy
da5dfd0e06 tests: fix domaincapstest linking for libxl
Commit 11567cf added some libxl tests into domaincapstest and
added libvirt_driver_libxl_impl.la to domaincapstest_LDADD.

This causes link fail on systems without GNU regex implementation:

gmake[2]: Entering directory '/usr/home/novel/code/libvirt/tests'
  CCLD     domaincapstest
  ../src/.libs/libvirt_driver_libxl_impl.a(libvirt_driver_libxl_impl_la-libxl_capabilities.o):
  In function `libxlMakeCapabilities':
  libxl/libxl_capabilities.c:(.text+0x6b2): undefined reference to
  `rpl_regcomp'
  libxl/libxl_capabilities.c:(.text+0x6d0): undefined reference to
  `rpl_regerror'
  libxl/libxl_capabilities.c:(.text+0x803): undefined reference to
  `rpl_regexec'
  libxl/libxl_capabilities.c:(.text+0xa58): undefined reference to
  `rpl_regfree'
  clang-3.8: error: linker command failed with exit code 1 (use -v to
  see invocation)

This happens because on these system it tries to use gnulib's builtin
regex implementation, but doesn't link to gnulib.

Fix by adding $(GNULIB_LIBS) along with libvirt_driver_libxl_impl.la to
domaincapstest_LDADD.
2016-08-16 03:12:05 +03:00
Luyao Huang
92560419e1 tests: add missing directories in EXTRA_DIST
In commit ec5dcf2a and b0b4a35c we have moved qemuhotplugtest's XMLs to
new directories but forgot to fix the Makefile. Add 2 directories in
EXTRA_DIST to fix broken VPATH build. Also remove now unused
qemuhotplugtestdata directory from the Makefile as well as from the
tree.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-07-12 11:52:10 +02:00
Daniel P. Berrange
54628f5434 libvirtd: convert to typesafe virConf accessors
The libvirtdconftest was previously used to test data type
handling of the libvirtd config file. Now we're using the
typedef APIs, this test case has little value, and is pretty
hard to fixup with deal with the new APIs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:57:01 +01:00
Daniel P. Berrange
776925096d tests: remove pointless virconftest.sh wrapper
The virconftest is different from all our other tests in that
the C program only tests a single in/out config file pair. It
relies on a shell wrapper to invoke it once for each test
file.

This gets rid of the shell wrapper and makes the C program
actually run over each test file using the normal test pattern.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-07-12 09:57:00 +01:00
Fabian Freyer
dd23c3822b bhyve: add tests for bhyveParseCommandLineString 2016-07-10 15:40:11 -04:00