Author: gnichols Date: 2010-05-20 14:10:42 +0000 (Thu, 20 May 2010) New Revision: 513
Added: trunk/tools/unittest.py Removed: trunk/unittests/ Modified: trunk/tools/bin/v7-mount-data-image trunk/tools/rhts-regression-test.xml trunk/tools/rhtsvirtualreserve-ia64.xml trunk/tools/rhtsvirtualreserve-x86_64.xml Log: moving unit test code to tools
Modified: trunk/tools/bin/v7-mount-data-image =================================================================== --- trunk/tools/bin/v7-mount-data-image 2010-05-20 12:31:09 UTC (rev 512) +++ trunk/tools/bin/v7-mount-data-image 2010-05-20 14:10:42 UTC (rev 513) @@ -48,6 +48,7 @@ (options,args) = parser.parse_args()
fvTest = FvTest("fv_generic") +fvTest.configureHypervisor() if options.unmount: if options.loopBackDevice: fvTest.loopBackDevice = options.loopBackDevice
Modified: trunk/tools/rhts-regression-test.xml =================================================================== --- trunk/tools/rhts-regression-test.xml 2010-05-20 12:31:09 UTC (rev 512) +++ trunk/tools/rhts-regression-test.xml 2010-05-20 14:10:42 UTC (rev 513) @@ -5,6 +5,7 @@ <recipeSet>
<recipe testrepo='development'> + <distroRequires>ARCH = i386</distroRequires> <distroRequires>FAMILY = RedHatEnterpriseLinuxServer5</distroRequires> <distroRequires>NAME = RHEL5-Server-U3</distroRequires> @@ -22,6 +23,7 @@ <addrepo>http://qafiler.bos.redhat.com/testkits/V7/RHEL4/</addrepo> <test role='STANDALONE' name='/distribution/v7/single'/> </recipe> + <recipe testrepo='development'> <distroRequires>ARCH = x86_64</distroRequires> <distroRequires>FAMILY = RedHatEnterpriseLinuxServer5</distroRequires>
Modified: trunk/tools/rhtsvirtualreserve-ia64.xml =================================================================== --- trunk/tools/rhtsvirtualreserve-ia64.xml 2010-05-20 12:31:09 UTC (rev 512) +++ trunk/tools/rhtsvirtualreserve-ia64.xml 2010-05-20 14:10:42 UTC (rev 513) @@ -12,6 +12,7 @@ <hostRequires>HVM = 1</hostRequires> <hostRequires>MEMORY >= 2048</hostRequires> <addrepo>http://porkchop.redhat.com/released/RHEL-5-Server-Supplementary/U3/ia64/os/S...</addrepo> + <addrepo>http://qafiler.bos.redhat.com/testkits/V7/RHEL5/</addrepo> <test role='STANDALONE' name='/distribution/install'/> <test role='STANDALONE' name='/distribution/pkginstall'> <params> @@ -24,37 +25,12 @@ </params> </test> <test role='STANDALONE' name='/distribution/virt/start_stop'/> - <guestrecipe testrepo='development' guestname='ia64_pv_guest' guestargs=' --nonsparse --paravirt --file /var/lib/xen/images/ia64_pv_guest.img -s 10 ' whiteboard='domU:paravirt on partition '> - <distroRequires>ARCH = ia64</distroRequires> - <distroRequires>FAMILY = RedHatEnterpriseLinuxServer5</distroRequires> - <distroRequires>NAME = RHEL5-Server-U3</distroRequires> - <distroRequires>RELEASED = 1</distroRequires> - <addrepo>http://qafiler.bos.redhat.com/testkits/HTS/RHEL5/</addrepo> - <installPackage>kernel-xen</installPackage> - <test role='STANDALONE' name='/distribution/install'/> - <test role='STANDALONE' name='/distribution/virt/guestutils'/> - <test role='STANDALONE' name='/distribution/reservesys'> + <test role='STANDALONE' name='/distribution/reservesys'> <params> <param name='RESERVEBY' value='gnichols@redhat.com'/> <param name='RESERVETIME' value='86400'/> </params> </test> - </guestrecipe> - <guestrecipe testrepo='development' guestname='ia64_hvm_guest' guestargs=' --nonsparse --hvm --file /var/lib/xen/images/ia64_hvm_guest.img -s 10 ' whiteboard='domU:hvm on partition'> - <distroRequires>ARCH = ia64</distroRequires> - <distroRequires>FAMILY = RedHatEnterpriseLinuxServer5</distroRequires> - <distroRequires>NAME = RHEL5-Server-U3</distroRequires> - <distroRequires>RELEASED = 1</distroRequires> - <addrepo>http://qafiler.bos.redhat.com/testkits/HTS/RHEL5/</addrepo> - <test role='STANDALONE' name='/distribution/install'/> - <test role='STANDALONE' name='/distribution/virt/guestutils'/> - <test role='STANDALONE' name='/distribution/reservesys'> - <params> - <param name='RESERVEBY' value='gnichols@redhat.com'/> - <param name='RESERVETIME' value='86400'/> - </params> - </test> - </guestrecipe> </recipe> </recipeSet> </job>
Modified: trunk/tools/rhtsvirtualreserve-x86_64.xml =================================================================== --- trunk/tools/rhtsvirtualreserve-x86_64.xml 2010-05-20 12:31:09 UTC (rev 512) +++ trunk/tools/rhtsvirtualreserve-x86_64.xml 2010-05-20 14:10:42 UTC (rev 513) @@ -1,24 +1,19 @@ <job> <workflow>Virtual Workflow</workflow> <submitter>gnichols@redhat.com</submitter> - <whiteboard>2 Xen nonsparse block device rhel5.3 x86_64, pv/hvm guests on rhel5.3 x86_64 dom0 INSTALL ONLY </whiteboard> + <whiteboard>2 Xen nonsparse block device rhel5.5 x86_64 </whiteboard> <recipeSet> <recipe testrepo='development'> <distroRequires>ARCH = x86_64</distroRequires> <distroRequires>FAMILY = RedHatEnterpriseLinuxServer5</distroRequires> - <distroRequires>NAME = RHEL5-Server-U3</distroRequires> - <distroRequires>RELEASED = 1</distroRequires> + <distroRequires>NAME = RHEL5-Server-U5</distroRequires> <hostRequires>ARCH = x86_64</hostRequires> <hostRequires>HVM = 1</hostRequires> <hostRequires>MEMORY >= 2048</hostRequires> - <addrepo>http://porkchop.redhat.com/released/RHEL-5-Server-Supplementary/U3/x86_64/os...</addrepo> + <installPackage>-kernel-xen</installPackage> + <addrepo>http://porkchop.redhat.com/released/RHEL-5-Server-Supplementary/U4/x86_64/os...</addrepo> <addrepo>http://qafiler.bos.redhat.com/testkits/V7/RHEL5/</addrepo> <test role='STANDALONE' name='/distribution/install'/> - <test role='STANDALONE' name='/distribution/pkginstall'> - <params> - <param name='PKGARGNAME' value='xen-x86_64-guest-firmware'/> - </params> - </test> <test role='STANDALONE' name='/distribution/virt/install'> <params> <param name='KILLTIMEOVERRIDE' value='59280'/>
Copied: trunk/tools/unittest.py (from rev 512, trunk/unittests/unittest.py) =================================================================== --- trunk/tools/unittest.py (rev 0) +++ trunk/tools/unittest.py 2010-05-20 14:10:42 UTC (rev 513) @@ -0,0 +1,129 @@ +#!/usr/bin/env python +# Copyright (c) 2010 Red Hat, Inc. All rights reserved. This copyrighted material +# is made available to anyone wishing to use, modify, copy, or +# redistribute it subject to the terms and conditions of the GNU General +# Public License v.2. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Author: David Sommerseth davids@redhat.com +# + +import os, sys + +class UnitTest(object): + "Unified unit test class" + + def __init__(self, srcrootdir): + "UnitTest constructor. srcrootdir argument must point at the source root directory" + self.imported_mods = [] + self.mod_impcount = 0 + self.mod_impfail = 0 + self.mod_testpass = 0 + self.mod_testfail = 0 + self.mod_testmiss = 0 + self.rootdir = srcrootdir + sys.path.insert(0, self.rootdir) + + + def LoadModules(self, modules): + """Loads all the defined modules. The modules argument takes a tuple list + consisting of ('subdir','module name')""" + + for (directory, mod) in modules: + # Check if the directory is in the "include" path + try: + sys.path.index('%s/%s' % (self.rootdir,directory)) + except ValueError: + # Not found, insert it + sys.path.insert(0, '%s/%s' % (self.rootdir, directory)) + + try: + impmod = __import__(mod) + print "** Imported %s/%s" % (directory, mod) + self.imported_mods.append({'name': '%s/%s' %(directory, mod), + 'module': impmod}) + self.mod_impcount += 1 + except ImportError, e: + print "!! ** ERROR ** Failed to import %s/%s (Exception: %s)" % (directory, mod, str(e)) + self.mod_impfail += 1 + + return True + + + def RunTests(self): + "Runs the unit_test() function in all successfully imported modules" + + for m in self.imported_mods: + try: + # Check if the unit_test() function exists and is callable before trying + # to run the unit test + if callable(m['module'].unit_test): + print + print 78 * '-' + print "** Running unit test for: %s" % m['name'] + print 78 * '-' + res = m['module'].unit_test() + if res == 0: + print "** Result of %s: PASS" % m['name'] + self.mod_testpass += 1 + else: + print "** Result of %s: FAILED (return code: %s)" % (m['name'], str(res)) + self.mod_testfail += 1 + print 78 * '=' + else: + self.mod_testmiss += 1 + print "!!! ** ERROR ** Could not run %s::unit_test()" % m['name'] + except AttributeError: + self.mod_testmiss += 1 + print "!!! ** ERROR ** No %s::unit_test() method found" % m['name'] + + + def PrintTestSummary(self): + "Prints a result summary of all the tests" + print + print " --------------------" + print " ** TEST SUMMARY ** " + print " --------------------" + print + print " - Modules:" + print " Declared for test: %i" % (self.mod_impcount + self.mod_impfail) + print " Successfully imported: %i" % self.mod_impcount + print " Failed import: %i" % self.mod_impfail + print + print " - Tests:" + print " Tests scheduled: %i" % (self.mod_testpass + self.mod_testfail + self.mod_testmiss) + print " Sucessfully tests: %i" % self.mod_testpass + print " Failed tests: %i" % self.mod_testfail + print " Missing unit_test() %i" % self.mod_testmiss + print + + +if __name__ == '__main__': + + # Retrieve the root directory if the source dir + # - use the first occurence of the 'v7' subdir as the root dirq + srcrootdir_ar = os.getcwd().split('/') + rootdir = '/'.join(srcrootdir_ar[0:srcrootdir_ar.index('v7')+1]) + print "** Source root dir: %s" % rootdir + + # Prepare the unit tester + tests = UnitTest(rootdir) + + # Load defined modules ('subdir','import name') + tests.LoadModules((('v7','redhatrelease'), + ('v7','command'), + ('v7','hal'), + ('v7','hash'), + ('tests/info', 'info') + )) + # Run all tests + tests.RunTests() + tests.PrintTestSummary() +
v7-commits@lists.stg.fedorahosted.org