render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
43fe83
From 79ca3c66fb28886ecaaf38220023d02efdddf66f Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <79ca3c66fb28886ecaaf38220023d02efdddf66f.1375465853.git.jdenemar@redhat.com>
43fe83
From: "Daniel P. Berrange" <berrange@redhat.com>
43fe83
Date: Tue, 30 Jul 2013 11:24:22 +0100
43fe83
Subject: [PATCH] Delete obsolete / unused python test files
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=884103
43fe83
43fe83
The python/tests directory contains a number of so called
43fe83
"tests" for the python API. These are all hardcoded to
43fe83
look for Xen and cannot be run in any automated fashion,
43fe83
and no one is ever manually running them. Given that they
43fe83
don't meaningully contribute to the test coverage, delete
43fe83
them.
43fe83
43fe83
For some reason these tests were also copied into the
43fe83
filesystem as part of 'make install'. The change to the
43fe83
RPM in commit 3347a4203278ec93d7b0ceb88b5ed10e4f14765c
43fe83
caused a build failure, since it removed the code which
43fe83
deleted these installed tests.
43fe83
43fe83
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
43fe83
(cherry picked from commit 5bb2a245abbde4c0a407f631660e2f2c81bc4c02)
43fe83
---
43fe83
 configure.ac             |   2 +-
43fe83
 python/Makefile.am       |   2 -
43fe83
 python/tests/Makefile.am |  52 -----------------
43fe83
 python/tests/basic.py    |  31 ----------
43fe83
 python/tests/create.py   | 146 -----------------------------------------------
43fe83
 python/tests/error.py    |  42 --------------
43fe83
 python/tests/node.py     |  34 -----------
43fe83
 python/tests/uuid.py     |  41 -------------
43fe83
 8 files changed, 1 insertion(+), 349 deletions(-)
43fe83
 delete mode 100644 python/tests/Makefile.am
43fe83
 delete mode 100755 python/tests/basic.py
43fe83
 delete mode 100755 python/tests/create.py
43fe83
 delete mode 100755 python/tests/error.py
43fe83
 delete mode 100755 python/tests/node.py
43fe83
 delete mode 100755 python/tests/uuid.py
43fe83
43fe83
diff --git a/configure.ac b/configure.ac
43fe83
index 35a5d76..084d864 100644
43fe83
--- a/configure.ac
43fe83
+++ b/configure.ac
43fe83
@@ -2447,7 +2447,7 @@ AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
43fe83
           libvirt.pc libvirt.spec mingw-libvirt.spec \
43fe83
           po/Makefile.in \
43fe83
 	  include/libvirt/Makefile include/libvirt/libvirt.h \
43fe83
-	  python/Makefile python/tests/Makefile \
43fe83
+	  python/Makefile \
43fe83
           daemon/Makefile \
43fe83
           tools/Makefile \
43fe83
           tests/Makefile \
43fe83
diff --git a/python/Makefile.am b/python/Makefile.am
43fe83
index 7eb42c6..925e1f4 100644
43fe83
--- a/python/Makefile.am
43fe83
+++ b/python/Makefile.am
43fe83
@@ -16,8 +16,6 @@
43fe83
 ## License along with this library.  If not, see
43fe83
 ## <http://www.gnu.org/licenses/>.
43fe83
 
43fe83
-SUBDIRS= . tests
43fe83
-
43fe83
 INCLUDES = \
43fe83
 	$(PYTHON_INCLUDES) \
43fe83
 	-I$(top_builddir)/gnulib/lib \
43fe83
diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am
43fe83
deleted file mode 100644
43fe83
index 0fd3c78..0000000
43fe83
--- a/python/tests/Makefile.am
43fe83
+++ /dev/null
43fe83
@@ -1,52 +0,0 @@
43fe83
-## Copyright (C) 2005-2011, 2013 Red Hat, Inc.
43fe83
-##
43fe83
-## This library is free software; you can redistribute it and/or
43fe83
-## modify it under the terms of the GNU Lesser General Public
43fe83
-## License as published by the Free Software Foundation; either
43fe83
-## version 2.1 of the License, or (at your option) any later version.
43fe83
-##
43fe83
-## This library is distributed in the hope that it will be useful,
43fe83
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
43fe83
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
43fe83
-## Lesser General Public License for more details.
43fe83
-##
43fe83
-## You should have received a copy of the GNU Lesser General Public
43fe83
-## License along with this library.  If not, see
43fe83
-## <http://www.gnu.org/licenses/>.
43fe83
-
43fe83
-EXAMPLE_DIR = $(datadir)/doc/libvirt-python-$(VERSION)/examples
43fe83
-
43fe83
-PYTESTS=		\
43fe83
-	basic.py	\
43fe83
-	create.py	\
43fe83
-	uuid.py		\
43fe83
-	error.py	\
43fe83
-	node.py
43fe83
-
43fe83
-EXTRA_DIST = $(PYTESTS)
43fe83
-
43fe83
-if WITH_PYTHON
43fe83
-tests: $(PYTESTS)
43fe83
-	@echo "## running Python regression tests"
43fe83
-	-@(PYTHONPATH="..:../.libs:../src/.libs:$(srcdir)/../src:$$PYTHONPATH";\
43fe83
-	   export PYTHONPATH; \
43fe83
-	   LD_LIBRARY_PATH="$(top_builddir)/src/.libs:$$LD_LIBRARY_PATH" ; \
43fe83
-	   export LD_LIBRARY_PATH; \
43fe83
-	   for test in $(PYTESTS) ; \
43fe83
-	   do log=`$(PYTHON) $(srcdir)/$$test` ; \
43fe83
-	   if [ "`echo $$log | grep OK`" = "" ] ; then \
43fe83
-	   echo "-- $$test" ; echo "$$log" ; fi ; done)
43fe83
-else
43fe83
-tests:
43fe83
-endif
43fe83
-
43fe83
-clean:
43fe83
-	rm -f *.pyc core
43fe83
-
43fe83
-install-data-local:
43fe83
-	$(mkinstalldirs) $(DESTDIR)$(EXAMPLE_DIR)
43fe83
-	-(for test in $(PYTESTS); \
43fe83
-	  do $(INSTALL) -m 0644 $(srcdir)/$$test $(DESTDIR)$(EXAMPLE_DIR) ; done)
43fe83
-
43fe83
-uninstall-local:
43fe83
-	for test in $(PYTESTS); do rm -f $(DESTDIR)$(EXAMPLE_DIR)/$$test; done
43fe83
diff --git a/python/tests/basic.py b/python/tests/basic.py
43fe83
deleted file mode 100755
43fe83
index c6dec81..0000000
43fe83
--- a/python/tests/basic.py
43fe83
+++ /dev/null
43fe83
@@ -1,31 +0,0 @@
43fe83
-#!/usr/bin/python -u
43fe83
-import libvirt
43fe83
-import sys
43fe83
-import os
43fe83
-
43fe83
-if not os.access("/proc/xen", os.R_OK):
43fe83
-    print 'System is not running a Xen kernel'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-conn = libvirt.openReadOnly(None)
43fe83
-if conn == None:
43fe83
-    print 'Failed to open connection to the hypervisor'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-# print conn
43fe83
-
43fe83
-try:
43fe83
-    dom0 = conn.lookupByName("Domain-0")
43fe83
-except:
43fe83
-    print 'Failed to find the main domain'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-# print dom0
43fe83
-
43fe83
-print "Domain 0: id %d running %s" % (dom0.ID(), dom0.OSType())
43fe83
-print dom0.info()
43fe83
-del dom0
43fe83
-del conn
43fe83
-print "OK"
43fe83
-
43fe83
-sys.exit(0)
43fe83
diff --git a/python/tests/create.py b/python/tests/create.py
43fe83
deleted file mode 100755
43fe83
index 815ccc4..0000000
43fe83
--- a/python/tests/create.py
43fe83
+++ /dev/null
43fe83
@@ -1,146 +0,0 @@
43fe83
-#!/usr/bin/python -u
43fe83
-import libvirt
43fe83
-import sys
43fe83
-import os
43fe83
-import time
43fe83
-
43fe83
-if not os.access("/proc/xen", os.R_OK):
43fe83
-    print 'System is not running a Xen kernel'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-#
43fe83
-# Try to provide default OS images paths here, of course non standard
43fe83
-#
43fe83
-osroots = [
43fe83
-  "/u/fc4-2.img",
43fe83
-  "/u/fc4.img",
43fe83
-  "/xen/fc4.img",
43fe83
-]
43fe83
-
43fe83
-okay = 1
43fe83
-
43fe83
-osroot = None
43fe83
-for root in osroots:
43fe83
-    if os.access(root, os.R_OK):
43fe83
-        osroot = root
43fe83
-        break
43fe83
-
43fe83
-if osroot == None:
43fe83
-    print "Could not find a guest OS root, edit to add the path in osroots"
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-kernel=open("/proc/version").read().split()
43fe83
-kernelOv = kernel[2]
43fe83
-
43fe83
-if kernelOv.find('hypervisor'):
43fe83
-    kernelU = "/boot/vmlinuz-" + kernelOv.replace('hypervisor', 'guest')
43fe83
-    initrdU = "/boot/initrd-" + kernelOv.replace('hypervisor', 'guest') + ".img"
43fe83
-elif kernelOv.find('xen0'):
43fe83
-    kernelU = "/boot/vmlinuz-" + kernelOv.replace('xen0', 'xenU')
43fe83
-    initrdU = "/boot/initrd-" + kernelOv.replace('xen0', 'xenU') + ".img"
43fe83
-
43fe83
-if not os.access(kernelU, os.R_OK):
43fe83
-    print "Did not find the guest kernel %s" % (kernelU)
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-kernelU = "<kernel>" + kernelU + "</kernel>"
43fe83
-
43fe83
-if not os.access(initrdU, os.R_OK):
43fe83
-    print "Did not find the guest initrd %s" % (initrdU)
43fe83
-    initrdU = ""
43fe83
-else:
43fe83
-    initrdU = "<initrd>" + initrdU + "</initrd>"
43fe83
-
43fe83
-
43fe83
-conn = libvirt.open(None)
43fe83
-if conn == None:
43fe83
-    print 'Failed to open connection to the hypervisor'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-xmldesc="""<domain type='xen'>
43fe83
-  <name>test</name>
43fe83
-  <os>
43fe83
-    <type>linux</type>
43fe83
-""" + kernelU + initrdU + """
43fe83
-    <cmdline> root=/dev/sda1 ro selinux=0 3</cmdline>
43fe83
-  </os>
43fe83
-  <memory>131072</memory>
43fe83
-  <vcpu>1</vcpu>
43fe83
-  <devices>
43fe83
-    <disk type='file'>
43fe83
-      <source file='%s'/>
43fe83
-      <target dev='sda1'/>
43fe83
-    </disk>
43fe83
-    <interface type='bridge'>
43fe83
-      <source bridge='xenbr0'/>
43fe83
-      <mac address='aa:00:00:00:00:12'/>
43fe83
-      <script path='/etc/xen/scripts/vif-bridge'/>
43fe83
-    </interface>
43fe83
-  </devices>
43fe83
-</domain>
43fe83
-""" % (osroot)
43fe83
-
43fe83
-dom = conn.createLinux(xmldesc, 0)
43fe83
-if dom == None:
43fe83
-    print 'Failed to create a test domain'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-# print dom
43fe83
-
43fe83
-print "Domain: id %d running %s" % (dom.ID(), dom.OSType())
43fe83
-
43fe83
-print "Suspending test domain for 5 seconds"
43fe83
-if dom.suspend() != 0:
43fe83
-    print 'Failed to suspend domain test'
43fe83
-    dom.destroy()
43fe83
-    del dom
43fe83
-    del conn
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-infos = dom.info()
43fe83
-time.sleep(5)
43fe83
-infos2 = dom.info()
43fe83
-if infos[4] != infos2[4]:
43fe83
-    print 'Suspended domain test got CPU cycles'
43fe83
-    okay = 0
43fe83
-
43fe83
-print "resuming test domain for 10 seconds"
43fe83
-if dom.resume() != 0:
43fe83
-    print 'Failed to resume domain test'
43fe83
-    dom.destroy()
43fe83
-    del dom
43fe83
-    del conn
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-time.sleep(10)
43fe83
-print "shutdown of test domain"
43fe83
-
43fe83
-if dom.shutdown() != 0:
43fe83
-    okay = 0
43fe83
-    print 'Failed to shutdown domain test'
43fe83
-
43fe83
-i = 0
43fe83
-while i < 30:
43fe83
-    time.sleep(1)
43fe83
-    i = i + 1
43fe83
-    try:
43fe83
-        t = dom.info()[4]
43fe83
-    except:
43fe83
-        okay = 0
43fe83
-        t = -1
43fe83
-        break
43fe83
-
43fe83
-    if t == 0:
43fe83
-        break
43fe83
-
43fe83
-if t != 0:
43fe83
-    print 'Shutdown failed destroying domain test'
43fe83
-    okay = 0
43fe83
-    dom.destroy()
43fe83
-
43fe83
-del dom
43fe83
-del conn
43fe83
-if okay == 1:
43fe83
-    print "OK"
43fe83
-
43fe83
-sys.exit(0)
43fe83
diff --git a/python/tests/error.py b/python/tests/error.py
43fe83
deleted file mode 100755
43fe83
index 295f9a7..0000000
43fe83
--- a/python/tests/error.py
43fe83
+++ /dev/null
43fe83
@@ -1,42 +0,0 @@
43fe83
-#!/usr/bin/python -u
43fe83
-#
43fe83
-# Tests global error handlers at the python level.
43fe83
-#
43fe83
-import libvirt
43fe83
-import sys
43fe83
-import os
43fe83
-
43fe83
-errno = None
43fe83
-
43fe83
-def handler(ctxt, err):
43fe83
-    global errno
43fe83
-
43fe83
-    #print "handler(%s, %s)" % (ctxt, err)
43fe83
-    errno = err
43fe83
-
43fe83
-libvirt.registerErrorHandler(handler, 'context')
43fe83
-
43fe83
-conn = libvirt.openReadOnly(None)
43fe83
-if conn == None:
43fe83
-    print 'Failed to open connection to the hypervisor'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-try:
43fe83
-    dom0 = conn.lookupByName("Does_not_exist")
43fe83
-    print 'strange found a Does_not_exist domain'
43fe83
-    sys.exit(1)
43fe83
-except:
43fe83
-    pass
43fe83
-
43fe83
-del conn
43fe83
-
43fe83
-if errno == None:
43fe83
-    print 'failed to get an error'
43fe83
-elif errno[0] == libvirt.VIR_ERR_NO_CONNECT or \
43fe83
-     errno[0] == libvirt.VIR_ERR_INVALID_DOMAIN or \
43fe83
-     errno[0] == libvirt.VIR_ERR_GET_FAILED:
43fe83
-    print "OK"
43fe83
-else:
43fe83
-    print 'got unexpected error:', errno
43fe83
-
43fe83
-sys.exit(0)
43fe83
diff --git a/python/tests/node.py b/python/tests/node.py
43fe83
deleted file mode 100755
43fe83
index f199fc3..0000000
43fe83
--- a/python/tests/node.py
43fe83
+++ /dev/null
43fe83
@@ -1,34 +0,0 @@
43fe83
-#!/usr/bin/python -u
43fe83
-import libvirt
43fe83
-import sys
43fe83
-import os
43fe83
-
43fe83
-if not os.access("/proc/xen", os.R_OK):
43fe83
-    print 'System is not running a Xen kernel'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-conn = libvirt.openReadOnly(None)
43fe83
-if conn == None:
43fe83
-    print 'Failed to open connection to the hypervisor'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-try:
43fe83
-    (model, memory, cpus, mhz, nodes, socket, cores, threads) = conn.getInfo()
43fe83
-except:
43fe83
-    print 'Failed to extract the current node information'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-print "Xen running on %d %s processors at %d MHz, %d MBytes of memory" % (
43fe83
-       cpus, model, mhz, memory)
43fe83
-
43fe83
-if cpus > nodes * socket * cores * threads:
43fe83
-    print "Erroneous CPU information"
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-if cpus < nodes * socket * cores * threads:
43fe83
-    print "Strange, running in degrated mode, some CPU are not available"
43fe83
-
43fe83
-del conn
43fe83
-print "OK"
43fe83
-
43fe83
-sys.exit(0)
43fe83
diff --git a/python/tests/uuid.py b/python/tests/uuid.py
43fe83
deleted file mode 100755
43fe83
index db48e80..0000000
43fe83
--- a/python/tests/uuid.py
43fe83
+++ /dev/null
43fe83
@@ -1,41 +0,0 @@
43fe83
-#!/usr/bin/python -u
43fe83
-import libvirt
43fe83
-import sys
43fe83
-import os
43fe83
-
43fe83
-if not os.access("/proc/xen", os.R_OK):
43fe83
-    print 'System is not running a Xen kernel'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-conn = libvirt.openReadOnly(None)
43fe83
-if conn == None:
43fe83
-    print 'Failed to open connection to the hypervisor'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-ids = conn.listDomainsID()
43fe83
-if ids == None or len(ids) == 0:
43fe83
-    print 'Failed to list running domains'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-id = ids[-1]
43fe83
-
43fe83
-try:
43fe83
-    dom = conn.lookupByID(id)
43fe83
-except:
43fe83
-    print 'Failed to find the domain %d'
43fe83
-    sys.exit(1)
43fe83
-
43fe83
-name0 = dom.name()
43fe83
-uuid = dom.UUID()
43fe83
-print "Using domain %s" % (name0)
43fe83
-try:
43fe83
-    dom2 = conn.lookupByUUID(uuid)
43fe83
-except:
43fe83
-    print 'Failed to lookup domain %d based on its UUID'
43fe83
-    sys.exit(1)
43fe83
-if dom2.name() != name0:
43fe83
-    print 'lookup of %s based on UUID brings a different domain %s' % (
43fe83
-           name0, dom2.name())
43fe83
-
43fe83
-print "OK"
43fe83
-sys.exit(0)
43fe83
-- 
43fe83
1.8.3.2
43fe83