Commit Graph

531 Commits

Author SHA1 Message Date
Pino Toscano
a2b37a495c tests: switch away from xgetcwd
xgetcwd is used only in a test, so there is no need to pull a gnulib
module just for it.

Switch to use getcwd directly with a fixed buffer: the tests would have
failed with paths longer than 992 characters, as the libvirt_uri would
have been truncated.  Since there were no reports of issues, we can
assume that the current working directory will fit in 1024 characters;
adapt the size of libvirt_uri accordingly.
2019-11-28 13:09:21 +01:00
Richard W.M. Jones
38ff3354ea tests: luks: Test the --key options.
Previously untested, and as always happens they were quite buggy.
2019-11-28 10:13:57 +00:00
Richard W.M. Jones
85c99edec1 v2v: Remove virt-v2v.
It has moved to a new repository:
https://github.com/libguestfs/virt-v2v
2019-11-13 12:49:55 +00:00
Pino Toscano
d8d8c856a1 lib: introduce GUESTFS_NO_DEPRECATED
Add a simple way to do not even provide prototypes of deprecated
functions in the C library: this way, users (like our tools) can build
against the library making sure to not use any deprecated function, not
even when compiler deprecation warnings are disabled.

Add it to the majority of our tools/internal libraries, and make sure
that it is not defined when building the API bridges of our bindings.
2019-04-23 18:08:19 +02:00
Pino Toscano
9d1fc91cca build: stop using GUESTFS_WARN_DEPRECATED
This is no more used now, as compiler deprecation warnings are triggered
by default.
2019-04-23 18:08:19 +02:00
Pino Toscano
84d0f5aa9f lib: enable deprecation warnings by default
Right now, deprecated functions of the library do not trigger any
compiler deprecation warning by default; they do that only if
GUESTFS_WARN_DEPRECATED=1 is defined.  However, this is not something
that seems to be done often -- at least none of the projects using the
libguestfs C API does that.

Hence, do a small behaviour change to change this on the other way
round: now deprecated functions trigger compiler deprecation warnings by
default, using GUESTFS_NO_WARN_DEPRECATED to disable this (and revert
to the previous behaviour).  Even though deprecated functions will not
be removed, we really want users to migrate away from them, as they were
deprecated for good reasons.

Define GUESTFS_NO_WARN_DEPRECATED where needed:
- in all the bindings, as they bind all the functions including the
  deprecated ones
- in the guestfish actions, as it exposes almost all the APIs
- in the C API test, as it runs the automated tests of all the APIs that
  have them
- for two tests that explicitly test deprecated functions
2019-04-23 18:08:19 +02:00
Pino Toscano
7a54596aaf tests: switch last-errno away from deprecated APIs
This test only calls stat to check the failure on missing file, so
switch to statns to get the same behaviour with a non-deprecated API.
2019-04-23 18:06:31 +02:00
Denis Plotnikov
4cfc071a84 daemon: drop error message check in do_part_expand_gpt
part-expand-gpt takes extreme cautions and doesn't proceed to writing
to the disk if the preliminary dry run of sgdisk has generated any
warnings on stdout.

This blocks the use of part-expand-gpt on disk shrink (with disk
resize being the main usecase for part-expand-gpt), because sgdisk dry
run produces a warning in that case.

So remove the excessive safety check, and leave it up to the caller.

Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
2019-04-16 09:32:02 +01:00
Richard W.M. Jones
e047cc4da8 lib: qemu: rbd: Properly escape IPv6 addresses.
Each ':' character in the address must be escaped from qemu.

Thanks: Jonathan Wright
2019-04-01 17:31:25 +01:00
Pino Toscano
89b5dabf8d tests: skip test-relabel.pl when selinuxrelabel is not available
test-relabel.pl performs a full SELinux relabelling of the phony guest,
and the selinux_relabel API does not work if the "selinuxrelabel"
feature is not available.
2019-02-11 16:43:53 +01:00
Pino Toscano
27cd2888c3 automake2junit.ml: string -> bytes
Make it usable OOTB with OCaml >= 4.02.0.
2019-01-14 15:19:32 +01:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Richard W.M. Jones
e62a443165 tests: Provide a way for skipping tests/bigdirs/test-big-dirs.pl.
This test is currently broken because of a kernel bug
(https://bugzilla.redhat.com/show_bug.cgi?id=1657200).
2018-12-11 17:53:29 +00:00
Richard W.M. Jones
b0c11adee7 tests: md: Increase size of MD partitions in test.
Commit c11a92751e chose some strangely
sized partitions for testing Linux MD devices.  The disks were 100M
however the four partitions only covered the first 10M of disk space
(with the rest being unallocated and unused in the test).

This worked until Linux 4.20 where the ~2M-sized partitions become too
small for a Linux MD device.

This commit changes the test to use four 20M-sized partitions which is
sufficient space to create the MD device with recent kernels.  I also
modified the partition allocation code to use explicit calculations
and variables, making it considerably clearer.
2018-11-30 14:59:32 +00:00
Richard W.M. Jones
da48f4e5ff sparsify: Fix test-virt-sparsify-in-place-fstrim-unsupported.sh
Since Linux commit f663b5b38fff trimming vfat is now supported by
Linux.  This broke the test which assumed it was not supported.  Use
another filesystem (minix) which does not support trimming instead.

Thanks: Daniel P. Berrangé and Pino Toscano.
2018-09-21 13:32:58 +01:00
Mykola Ivanets
b699111e04 daemon: list-filesystems: Filter out MBR extended partitions.
Extended MBR partitions cannot hold filesystems - filter them out.

RWMJ:

* Simplify is_mbr_extended function.

* Fix regression test rhbz1285847:

  The test assumed that list-filesystems would return an extended MBR
  partition (as "unknown").  However such partitions only contain
  logical partitions inside them, not filesystems.

* Some minor whitespace changes.
2018-06-01 15:09:34 +01:00
Mykola Ivanets
af63e6e491 tests: list-filesystems command ignores partitioned MD devices.
Test guestfish list-filesystems command finds file system on partitioned md device and doesn't take into account md device itself (similar to as physical devices are filtered out if they are partitioned).
2018-06-01 15:09:34 +01:00
Pino Toscano
2bf88b102c tests: regressions: make test-big-heap use a temporary empty file
Newer versions of qemu use file locking for the images by default, and
apparently that does not work with /dev/null.  Since this test just
calls qemu-img to get the format of an empty image, create a temporary
one instead.
2018-03-21 13:40:59 +01:00
Pino Toscano
ba53251ab9 automake2junit.ml: use LargeFile to stat'ing files
While scanning the sources, some of the files (i.e. the cached
appliance) may be larger than 4G, and thus raise EOVERFLOW on 32bit
architectures.

Fixes commit b4e119d8b7.
2018-03-01 10:14:32 +01:00
Pino Toscano
b4e119d8b7 automake2junit.ml: ignore symlinks when searching for .trs files
One gnulib test creates a symlink to the same directory, causing our
iteration to read the same test directory over and over, every time
considering it as new level of subdirectory.

As solution (or workaround), when iterating through a directory consider
only regular files, and directories, ignoring any other file type
(symlinks included).
2018-02-23 14:38:26 +01:00
Mykola Ivanets
079681058e tests: md: test guestfish finds md and LV devices in different combinations
Test guestfish finds:
1. md device created from physical block device and LV,
2. md device created from LVs
3. LV created on md device

raid0 is used for md device because it is inoperable if one of its components is inaccessible so it is easy observable that md device is missing (raid1 in this case will be operable but in degraded state).
2018-01-16 09:49:21 +00:00
Mykola Ivanets
c71e9e9acd tests: md: test guestfish finds logical volume on md device
Test guestfish finds logical volume (LV) created on md device
2018-01-16 09:49:21 +00:00
Richard W.M. Jones
04031269f6 tests: Further instances of $(RPC_CFLAGS). 2018-01-09 12:17:53 +00:00
Richard W.M. Jones
212762c593 Update copyright dates for 2018.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2017/$1-2018/g' `git ls-files`
2018-01-04 15:30:10 +00:00
Richard W.M. Jones
6407f23e3d tests: Make filtering code in rhbz557655.sh test more liberal.
Because of vagaries in how the debug messages get printed they can get
split over lines:

  gulibguestfs: trace: truncate_size = 0
  estfsd: => truncate_size (0xc8) took 0.00 secs

and the code which filtered out those messages before comparison was
failing.  This makes the code more liberal on how it matches and
filters out these messages.
2017-11-16 22:43:53 +00:00
Richard W.M. Jones
8295e44004 tests: disks: Enhance the test output by naming the test failures.
Makes it easier to find which test is failing.
2017-10-18 14:54:22 +01:00
Richard W.M. Jones
b7f5919aa7 tests: disks: Small adjustment for new libvirt iscsi qemu parameter.
Latest libvirt (3.8, I think) made a very small adjustment to the
format of the generated -drive parameter when using iscsi, from:

  file=iscsi://1.2.3.4:1234/iqn.2003-01.org.linux-iscsi.fedora,

to:

  file=iscsi://1.2.3.4:1234/iqn.2003-01.org.linux-iscsi.fedora/0,

This makes a corresponding change to the test so that both patterns
can be recognized.
2017-10-18 14:54:22 +01:00
Richard W.M. Jones
f397049191 tests: Fix regression test to work with new debug messages from guestfsd.
Commit 0b631d739b changed the debug
message format from the main loop in guestfsd.  This test tried to
filter out these messages when comparing output, but that stopped
working.  The problem was only evident when enabling debugging while
running the tests.
2017-10-17 23:31:36 +01:00
Richard W.M. Jones
9ac5d9859c threads: Add a test. 2017-09-16 23:06:25 +01:00
Richard W.M. Jones
4662c95266 tests: md: Temporarily disable test which requires device name hints.
These are broken after inspection was rewritten, but we should
fix them before 1.38 is released.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
4c474aba91 tests/qemu: Make the isolation tests more read and write heavy.
Do more reading of the backing file data, and more writes to the
overlay.
2017-09-14 16:58:17 +01:00
Richard W.M. Jones
52be0a6c50 tests/qemu: Split qemu snapshot isolation into 3 tests.
It contained 3 tests before.  It's better to run them in parallel.

Just a simple refactoring, no change.
2017-09-14 16:58:17 +01:00
Richard W.M. Jones
b237418678 tests: Add a regression test for RHBZ#1477623. 2017-08-08 17:50:23 +01:00
Richard W.M. Jones
58ecca0432 tests: discard: Remove dubious use of "/dev/urandom" as a Device parameter.
This API docs don't state that this is permitted.
2017-08-08 17:50:23 +01:00
Richard W.M. Jones
a20859f563 tests: lvm: Make the lvm_set_filter test easier to understand.
No functional change.
2017-07-27 14:39:46 +01:00
Richard W.M. Jones
2cb0413049 gobject: Use TEST_FUNCTIONS framework in tests. 2017-07-10 17:03:19 +01:00
Richard W.M. Jones
e6c89f9631 utils: Rename ‘guestfs-internal-frontend.h’ to ‘guestfs-utils.h’.
The reason it's not just ‘utils.h’ is because Pino is worried that we
might pick up /usr/include/utils.h from a rogue library.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
5efebd8c7e utils: Split out structs cleanups and printing into common/structs.
These won't be used by the daemon, so interferes with us using
common/utils in the daemon, so they are moved to a different library.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
c77837e6f2 s390x: tests: 9p: Use virtio-9p-ccw as the 9p device in this test. 2017-05-18 19:02:01 +01:00
Richard W.M. Jones
93af83de85 s390x: tests: regressions: Skip IDE tests on S/390.
IDE interface is not supported.
2017-05-18 19:02:01 +01:00
Matteo Cafasso
f3d3136a17 yara_scan: added API tests
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-02 13:42:29 +01:00
Richard W.M. Jones
99ac577a5b tests: Replace test-max-disks with several tests.
Replace the monolithic 'test-max-disks.pl' script with a test program
written in C.  The program is completely equivalent to the old script,
except for the enhancement that it is able to detect if disks are
added to the appliance in the wrong order.

The tests themselves are split out into some shell scripts:

 - test-27-disks: Fully tests 27 disks.
   This is the minimum supported configuration for all backends.

 - test-255-disks: Fully tests 255 disks.
   This is the most disks that libguestfs up to 1.36 supported.

 - test-add-lots-of-disks: Add ‘a lot’ of disks and exit (without
   any further testing).  This is meant to try to exercise > 255
   disk case but without being as slow as a test of the max number
   of disks (which takes ages, even for as few as 4000 disks).

 - test-max-disks: Test the maximum possible number of disks.
   The maximum depends on several factors, notably which backend
   is in use, and the limit on the number of open files.

   ‘test-max-disks’ is a slow test.
2017-04-21 15:20:16 +01:00
Richard W.M. Jones
ee206d7ba8 Use Unicode single quotes ‘’ in place of short single quoted strings throughout.
Only in end-user messages and documentation.  This change was done
mostly mechanically using the Perl script attached below.

I also changed don't -> don’t etc and made some other simple fixes.

See also: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

----------
 #!/usr/bin/perl -w

use strict;
use Locale::PO;

my $re = qr{'([-\w%.,=?*/]+)'};

my %files = ();

foreach my $filename ("po/libguestfs.pot", "po-docs/libguestfs-docs.pot") {
    my $poref = Locale::PO->load_file_asarray($filename);

    foreach my $po (@$poref) {
        if ($po->msgid =~ $re) {
            my @refs = split /\s+/, $po->reference;
            foreach my $ref (@refs) {
                my ($file, $lineno) = split /:/, $ref, 2;
                $file =~ s{^\.\./}{};
                if (exists $files{$file}) {
                    push @{$files{$file}}, $lineno;
                } else {
                    $files{$file} = [$lineno];
                }
            }
        }
    }
}

foreach my $file (sort keys %files) {
    unless (-w $file) {
        warn "warning: $file is probably generated\n"; # have to edit generator
        next;
    }
    my @lines = sort { $a <=> $b } @{$files{$file}};

    #print "editing $file at lines ", join (", ", @lines), " ...\n";
    open FILE, "<$file" or die "$file: $!";
    my @all = ();
    push @all, $_ while <FILE>;
    close FILE;

    my $ext = $file;
    $ext =~ s/^.*\.//;

    foreach (@lines) {
        # Don't mess with verbatim sections in POD files.
        next if $ext eq "pod" && $all[$_-1] =~ m/^ /;

        unless ($all[$_-1] =~ $re) {
            # this can happen for multi-line strings, have to edit it
            # by hand
            warn "warning: $file:$_ does not contain expected content\n";
            next;
        }
        $all[$_-1] =~ s/$re/‘$1’/g;
    }

    rename "$file", "$file.bak";
    open FILE, ">$file" or die "$file: $!";
    print FILE $_ for @all;
    close FILE;
    my $mode = (stat ("$file.bak"))[2];
    chmod ($mode & 0777, "$file");
}
2017-04-04 18:47:37 +01:00
Richard W.M. Jones
8c58b62f9d Replace possessive ASCII apostrophe ('s) with Unicode apostrophe (’s).
Only replaced in end-user messages and documentation, not in code,
comments, or anything else that's not end-user visible.

See: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
2017-03-31 10:38:04 +01:00
Pino Toscano
12c4cc7a6b automake2junit.ml: escape text in message of <skipped>
Escape XML characters in the logs to use as message for <skipped>, so
special characters such as &, ", and < do not make the whole XML
invalid.
2017-03-29 15:57:40 +02:00
Richard W.M. Jones
327caa1f08 test-data: Use another name for boot and root MD devices.
mdadm 4.0 no longer lets you create devices called literally "boot" or
"root", giving a very obscure error message:

https://bugzilla.redhat.com/show_bug.cgi?id=1433575

Work around this by calling them something else.
2017-03-18 10:24:12 +00:00
Richard W.M. Jones
80d3e05483 tests: Add infrastructure for running certain tests as root.
'[sudo] make check-root' is analogous to 'make check-slow'.
2017-03-13 15:01:12 +00:00
Richard W.M. Jones
e5474df1ac Use gnulib set_cloexec_flag in a few places. 2017-03-06 10:52:35 +00:00
Richard W.M. Jones
50f544d971 tests: regressions: Move another test to use $TEST_FUNCTIONS.
Omitted from commit a1b3d8d04b.
2017-02-25 17:12:29 +00:00
Richard W.M. Jones
45e046dac9 tests: Disable some tests so they don't break when ./configure --without-libvirt 2017-02-23 13:59:38 +00:00