new script for testing get/set metadata include API: dom->get_metadata dom->set_metadata --- scripts/domain/310-set-get-metadata.t | 68 +++++++++++++++++++++++++++++++++ 1 files changed, 68 insertions(+), 0 deletions(-) create mode 100644 scripts/domain/310-set-get-metadata.t diff --git a/scripts/domain/310-set-get-metadata.t b/scripts/domain/310-set-get-metadata.t new file mode 100644 index 0000000..d1e67a4 --- /dev/null +++ b/scripts/domain/310-set-get-metadata.t @@ -0,0 +1,68 @@ +# -*- perl -*- +# +# Copyright (C) 2009-2013 Red Hat, Inc. +# Copyright (C) 2013 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/310-set-get-metadata.t - Domain set_metadata/set_metadata + +=head1 DESCRIPTION + +The test case validates that set_metadata and get_metadata all can worked. + +=cut + +use strict; +use warnings; + +use Test::More tests => 6; + +use Sys::Virt::TCK; +use Test::Exception; + +my $tck = Sys::Virt::TCK->new(); +my $conn = eval { $tck->setup(); }; +my $description = "Test description"; +my $title = "Test Title"; +BAIL_OUT "failed to setup test harness: $@" if $@; +END { $tck->cleanup if $tck; } + + +my $xml = $tck->generic_domain("tck")->as_xml; + +diag "Creating a new transient domain"; +my $dom; +ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain object"); + +#set & get metadata for description +lives_ok(sub {$dom->set_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION,$description,undef,undef,0)},"set metadata for Description"); + +is($dom->get_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION,undef,0), $description, "get metadata for Description"); + +#set & get metadata for title +lives_ok(sub {$dom->set_metadata(Sys::Virt::Domain::METADATA_TITLE,$title,undef,undef,0)},"set metadata for Title"); + +is($dom->get_metadata(Sys::Virt::Domain::METADATA_TITLE,undef,0), $title, "get metadata for Title"); + +#clean +diag "Destroying the transient domain"; +$dom->destroy; + +diag "Checking that transient domain has gone away"; +ok_error(sub { $conn->get_domain_by_name("tck") }, "NO_DOMAIN error raised from missing domain", + Sys::Virt::Error::ERR_NO_DOMAIN); + +# end + -- 1.7.7.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list