[libvirt-tck][PATCH] Add two APIs testing for metadata

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

 



$dom->set_metadata
$dom->get_metadata
only have title and destription
element not support in libvirt now

Signed-off-by: Zhe Peng <zpeng@xxxxxxxxxx>
---
 scripts/domain/500-metadata.t | 72 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 scripts/domain/500-metadata.t

diff --git a/scripts/domain/500-metadata.t b/scripts/domain/500-metadata.t
new file mode 100644
index 0000000..11f2f6d
--- /dev/null
+++ b/scripts/domain/500-metadata.t
@@ -0,0 +1,72 @@
+# -*- perl -*-
+#
+# Copyright (C) 2014 Red Hat, Inc.
+# Copyright (C) 2014 Zhe Peng
+#
+# 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/500-metadata.t -- set/get metadata from guest.
+
+=head1 DESCRIPTION
+
+The test case validates that libvirt can set/get guest metadata
+Sys::Virt::Domain::METADATA_TITLE
+Sys::Virt::Domain::METADATA_DESCRIPTION
+not support Sys::Virt::Domain::METADATA_ELEMENT
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 8;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END {
+    $tck->cleanup if $tck;
+}
+
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
+
+diag "Creating a new transient domain";
+my $dom;
+ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain object");
+
+my $title = "libvirt tck testing title";
+my $des = "perl-Sys-Virt description";
+
+lives_ok(sub {$dom->set_metadata(Sys::Virt::Domain::METADATA_TITLE, $title, undef, undef, 0)}, "Set title to $title" );
+lives_ok(sub {$dom->set_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION, $des, undef, undef, 0)}, "Set description to $des" );
+
+my $hasMetadata = $dom->get_xml_description;
+
+ok($hasMetadata =~ m|$title|, "title has added in guest");
+ok($hasMetadata =~ m|$des|, "description has added in guest");
+
+my $mTitle = $dom->get_metadata(Sys::Virt::Domain::METADATA_TITLE,undef,0);
+my $mDes = $dom->get_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION,undef,0);
+
+is($mTitle, $title, "Get title from guest");
+is($mDes, $des, "Get description from guest");
+
+diag "Destroy domain";
+$dom->destroy;
+
+ok_error(sub { $conn->get_domain_by_name("tck") }, "NO_DOMAIN error raised from missing domain", 42);
+
-- 
1.9.0

--
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]