2 * collectd - src/virt_test.c
3 * Copyright (C) 2016 Francesco Romani <fromani at redhat.com>
5 * collectd - src/ceph_test.c
6 * Copyright (C) 2015 Florian octo Forster
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; only version 2 of the License is applicable.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * Florian octo Forster <octo at collectd.org>
26 #include "virt.c" /* sic */
28 #ifdef HAVE_LIST_ALL_DOMAINS
30 virDomainPtr *domains;
32 static int setup(void)
34 if (virInitialize() != 0) {
35 printf("ERROR: virInitialize() != 0\n");
39 conn = virConnectOpen("test:///default");
41 printf("ERROR: virConnectOpen == NULL\n");
48 static int teardown(void)
52 virConnectClose(conn);
57 DEF_TEST(get_domain_state_notify) {
59 int n_domains = virConnectListAllDomains(conn, &domains, VIR_CONNECT_GET_ALL_DOMAINS_STATS_PERSISTENT);
61 printf("ERROR: virConnectListAllDomains: n_domains <= 0\n");
65 int ret = get_domain_state_notify(domains[0]);
66 EXPECT_EQ_INT(0, ret);
73 DEF_TEST(persistent_domains_state_notification) {
75 int ret = persistent_domains_state_notification();
76 EXPECT_EQ_INT(0, ret);
85 #ifdef HAVE_LIST_ALL_DOMAINS
86 RUN_TEST(get_domain_state_notify);
87 RUN_TEST(persistent_domains_state_notification);