Index: xen/tools/xm-test/lib/XmTestLib/XenDomain.py =================================================================== --- xen.orig/tools/xm-test/lib/XmTestLib/XenDomain.py 2006-05-05 10:27:12.000000000 +0100 +++ xen/tools/xm-test/lib/XmTestLib/XenDomain.py 2006-07-14 14:25:26.000000000 +0100 @@ -232,6 +232,45 @@ elif not self.console and noConsole == False: return self.getConsole() + def new(self): + ret, output = traceCommand("xm new %s" % self.config) + if ret != 0: + raise DomainError("Failed to create domain", + extra=output, + errorcode=ret) + + def restart(self, noConsole = False): + """ actually this is .start(), but that name is taken """ + + ret, output = traceCommand("xm start %s" % self.config.getOpt("name")) + + if ret != 0: + raise DomainError("Failed to create domain", + extra=output, + errorcode=ret) + + # HVM domains require waiting for boot + if self.getDomainType() == "HVM": + waitForBoot() + + # Go through device list and run console cmds + for dev in self.devices.keys(): + self.devices[dev].execAddCmds() + + if self.console and noConsole == True: + self.closeConsole() + + elif self.console and noConsole == False: + return self.console + + elif not self.console and noConsole == False: + return self.getConsole() + + + def delete(self): + ret, output = traceCommand("xm delete %s" % self.config.getOpt("name")) + return ret + def stop(self): prog = "xm" cmd = " shutdown " Index: xen/tools/xm-test/tests/new/02_new_start_pos.py =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ xen/tools/xm-test/tests/new/02_new_start_pos.py 2006-07-14 14:25:26.000000000 +0100 @@ -0,0 +1,68 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith + +import sys +import re +import time + +from XmTestLib import * + +# Create a domain (default XmTestDomain, with our ramdisk) +domain = XmTestDomain() + +if int(getInfo("free_memory")) < domain.config.getOpt("memory"): + SKIP("This test needs %i MB of free memory (%i MB avail)" % + (domain.config.getOpt("memory"), int(getInfo("free_memory")))) + +# Start it +try: + domain.new() +except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + +try: + console = domain.restart() +except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + +try: + # Run 'ls' + run = console.runCmd("ls") +except ConsoleError, e: + saveLog(console.getHistory()) + FAIL(str(e)) + +# Save a transcript for human review +saveLog(console.getHistory()) + +# Close the console +domain.closeConsole() + +# Stop the domain (nice shutdown) +domain.stop() + +# Attempt delete for 10 times, pausing 2 seconds between each invoke +for i in range(10): + ret = domain.delete() + if ret == 0: + break + time.sleep(2) + +if ret != 0: + print "Failed to remove test domain: %d" % ret + FAIL("Unable to remove test domain") + +if not re.search("proc", run["output"]): + if verbose: + print run["output"] + FAIL("'ls' output looks wrong (didn't see /proc)") + + Index: xen/tools/xm-test/tests/new/01_new_basic_pos.py =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ xen/tools/xm-test/tests/new/01_new_basic_pos.py 2006-07-14 14:25:26.000000000 +0100 @@ -0,0 +1,31 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith + +import sys +import re +import time + +from XmTestLib import * + +# Create a domain (default XmTestDomain, with our ramdisk) +domain = XmTestDomain() + +if int(getInfo("free_memory")) < domain.config.getOpt("memory"): + SKIP("This test needs %i MB of free memory (%i MB avail)" % + (domain.config.getOpt("memory"), int(getInfo("free_memory")))) + +# Start it +try: + domain.new() +except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + +ret = domain.delete() +if ret != 0: + print "Failed to remove test domain: %d" % ret + FAIL("Unable to remove test domain") Index: xen/tools/xm-test/tests/Makefile.am =================================================================== --- xen.orig/tools/xm-test/tests/Makefile.am 2006-06-20 11:36:46.000000000 +0100 +++ xen/tools/xm-test/tests/Makefile.am 2006-07-14 14:25:26.000000000 +0100 @@ -27,7 +27,8 @@ vcpu-pin \ vtpm \ enforce_dom0_cpus \ - save restore migrate + save restore migrate \ + new EXTRA_DIST = $(SUBDIRS) Makefile.am.template Index: xen/tools/xm-test/tests/new/03_new_start_stress_pos.py =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ xen/tools/xm-test/tests/new/03_new_start_stress_pos.py 2006-07-14 14:25:35.000000000 +0100 @@ -0,0 +1,79 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith + +import sys +import re +import time + +from XmTestLib import * + +DOMS = 10 +MEM = 32 +DUR = 60 + +# Create a domain (default XmTestDomain, with our ramdisk) +domains = [] +consoles = [] + +for i in range(DOMS): + domain = XmTestDomain(name = '03_stress_%d' % i, + extraConfig={"memory":MEM}) + # Start it + try: + domain.new() + except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + + domains.append(domain) + +for domain in domains: + try: + console = domain.restart() + except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + + consoles.append(console) + + +for console in consoles: + try: + # Run 'ls' + run = console.runCmd("ls") + except ConsoleError, e: + saveLog(console.getHistory()) + FAIL(str(e)) + + # Save a transcript for human review + saveLog(console.getHistory()) + +for domain in domains: + # Close the console + domain.closeConsole() + # Stop the domain (nice shutdown) + domain.stop() + + # Attempt delete for 10 times, pausing 2 seconds between each invoke + for i in range(10): + ret = domain.delete() + if ret == 0: + break + time.sleep(2) + + if ret != 0: + print "Failed to remove test domain: %d" % ret + FAIL("Unable to remove test domain") + + if not re.search("proc", run["output"]): + if verbose: + print run["output"] + FAIL("'ls' output looks wrong (didn't see /proc)") + + Index: xen/tools/xm-test/tests/new/04_new_same_name_neg.py =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ xen/tools/xm-test/tests/new/04_new_same_name_neg.py 2006-07-14 14:25:41.000000000 +0100 @@ -0,0 +1,39 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2005 +# Author: Dan Smith + +import sys +import re +import time + +from XmTestLib import * + +# Create a domain (default XmTestDomain, with our ramdisk) +first_domain = XmTestDomain(name = "04_name_same_name") + +# Start it +try: + first_domain.new() +except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra + FAIL(str(e)) + +try: + second_domain = XmTestDomain(name = "04_name_same_name") + second_domain.new() +except DomainError, e: + if verbose: + print "Failed to create test domain because:" + print e.extra +else: + FAIL("Succeeded to create two domains of the same name") + + +try: + ret = first_domain.delete() + ret = second_domain.delete() +except: + pass Index: xen/tools/xm-test/tests/new/Makefile.am =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ xen/tools/xm-test/tests/new/Makefile.am 2006-07-14 14:25:41.000000000 +0100 @@ -0,0 +1,22 @@ +SUBDIRS = + +TESTS = 01_new_basic_pos.test \ + 02_new_start_pos.test \ + 03_new_start_stress_pos.test \ + 04_new_same_name_neg.test + +EXTRA_DIST = $(TESTS) + +TESTS_ENVIRONMENT=@TENV@ + +%.test: %.py + cp $< $@ + chmod +x $@ + +clean-local: am_config_clean-local + +am_config_clean-local: + rm -f *test + rm -f *log + rm -f *~ + Index: xen/tools/xm-test/configure.ac =================================================================== --- xen.orig/tools/xm-test/configure.ac 2006-07-14 14:15:26.000000000 +0100 +++ xen/tools/xm-test/configure.ac 2006-07-14 14:25:26.000000000 +0100 @@ -135,6 +135,7 @@ tests/vcpu-disable/Makefile tests/vtpm/Makefile tests/enforce_dom0_cpus/Makefile + tests/new/Makefile lib/XmTestReport/xmtest.py lib/XmTestLib/config.py ])