Re: [libvirt-tck][PATCH] This testcase tests if the open_graphics_fd function works properly.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Zhe Peng wrote:
> Signed-off-by: Hao Liu <hliu@xxxxxxxxxx>
> ---
>  scripts/domain/275-open-graphics-fd.t | 76 +++++++++++++++++++++++++++++++++++
>  1 file changed, 76 insertions(+)
>  create mode 100644 scripts/domain/275-open-graphics-fd.t
>
> diff --git a/scripts/domain/275-open-graphics-fd.t b/scripts/domain/275-open-graphics-fd.t
> new file mode 100644
> index 0000000..9377f50
> --- /dev/null
> +++ b/scripts/domain/275-open-graphics-fd.t
> @@ -0,0 +1,76 @@
> +# -*- perl -*-
> +#
> +# Copyright (C) 2012-2014 Red Hat, Inc.
> +# Copyright (C) 2014 Hao Liu <hliu@xxxxxxxxxx>
> +#
> +# This program is free software; You can redistribute it and/or modify
> +# it under the GNU General Public License as published by the Free
> +# Software Foundation; either version 2, or (at your option) any
> +# later version
> +#
> +# The file "LICENSE" distributed along with this file provides full
> +# details of the terms and conditions
> +#
> +
> +=pod
> +
> +=head1 NAME
> +
> +domain/275-open-graphics-fd.t - Test open_graphics_fd function
> +
> +=head1 DESCRIPTION
> +
> +The test case validates that open_graphics_fd function works well
> +
> +=cut
> +
> +use strict;
> +use warnings;
> +
> +use Test::More tests => 9;
> +
> +use Sys::Virt::TCK;
> +use Test::Exception;
> +use IO::Handle;
> +
> +my $tck = Sys::Virt::TCK->new();
> +my $conn = eval { $tck->setup(); };
> +BAIL_OUT "failed to setup test harness: $@" if $@;
> +END {
> +    $tck->cleanup if $tck;
> +}
> +
> +
> +# looking up domain
> +my $dom_name ="tck";
> +my $xml = $tck->generic_domain(name => $dom_name)->as_xml;
> +diag "domain xml is $xml";
> +my $dom = $conn->define_domain($xml);
> +$dom->create;
> +ok($dom->get_id() > 0, "running domain has an ID > 0");
> +my $graphics_cnt = xpath($dom, "count(/domain/devices/graphics)")->value();
> +my $valid_idx = $graphics_cnt - 1;
> +my $invalid_idx = $graphics_cnt;
> +
> +my $fd = 0;
> +my $fh = IO::Handle->new();
> +
> +diag "open fd for valid graphics device";
> +lives_ok(sub {$fd = $dom->open_graphics_fd($valid_idx, 0)}, "open graphics fd");
> +ok($fd > 0, "graphic fd is $fd");
>   

It looks like the test fails when virDomainOpenGraphicsFD is not
supported by the hypervisor.  Can it be skipped if the error is "not
supported"?

Regards,
Jim

> +$fh->fdopen($fd, "r");
> +ok($fh->opened, "fd is accessible");
> +$fh->close();
> +
> +diag "open fd for valid graphics device skip auth";
> +$fd = 0;
> +lives_ok(sub {$fd = $dom->open_graphics_fd($valid_idx, Sys::Virt::Domain::OPEN_GRAPHICS_SKIPAUTH)}, "open graphics fd");
> +ok($fd > 0, "graphic fd is $fd");
> +$fh->fdopen($fd, "r");
> +ok($fh->opened, "fd is accessible");
> +$fh->close();
> +
> +diag "open fd for non-exist graphics device";
> +$fd = 0;
> +ok_error(sub {$fd = $dom->open_graphics_fd($invalid_idx, 0)}, "open graphics fd");
> +ok($fd eq 0, "graphic fd is not returned");
>   

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]