source: trunk/packages/xen-3.1/xen-3.1/tools/xm-test/tests/unpause/01_unpause_basic_pos.py @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

  • Property svn:mime-type set to text/script
File size: 1.8 KB
Line 
1#!/usr/bin/python
2
3# Copyright (C) International Business Machines Corp., 2005
4# Author: Paul Larson  <pl@us.ibm.com>
5
6# Description:
7# Positive Tests:
8# Tests for xm unpause
9# 1) Create domain, verify it's up with console
10# 2) randomly pause and unpause the domain
11# 3) unpause it one last time
12# 4) verify it's still alive with console
13
14import time
15import commands
16from random import *
17
18from XmTestLib import *
19
20# Create a domain (default XmTestDomain, with our ramdisk)
21domain = XmTestDomain()
22
23# Start it
24try:
25    console = domain.start()
26except DomainError, e:
27    if verbose:
28        print "Failed to create test domain because:"
29        print e.extra
30    FAIL(str(e))
31
32try:
33    # Make sure a command succeeds
34    run = console.runCmd("ls")
35except ConsoleError, e:
36    FAIL(str(e))
37
38# Close the console
39domain.closeConsole()
40
41seed(time.time())
42
43for i in range(100):
44    pauseit = randint(0,1)
45    if(pauseit):
46        # Pause the domain
47        status, output = traceCommand("xm pause %s" % domain.getName())
48        if status != 0:
49            FAIL("xm pause returned invalid %i != 0", status)
50    else:
51        # Unpause the domain
52        status, output = traceCommand("xm unpause %s" % domain.getName())
53        if status != 0:
54            FAIL("xm unpause returned invalid %i != 0", status)
55
56# Make sure the domain is unpaused before we finish up
57status, output = traceCommand("xm unpause %s" % domain.getName())
58if status != 0:
59    FAIL("xm unpause returned invalid %i != 0", status)
60
61# Are we still alive after all that?
62try:
63    console = domain.getConsole()
64    run = console.runCmd("ls")
65except ConsoleError, e:
66    FAIL(str(e))
67
68# Close the console
69domain.closeConsole()
70
71if run["return"] != 0:
72    FAIL("console failed to attach to supposedly unpaused domain")
73
74# Stop the domain (nice shutdown)
75domain.stop()
76
Note: See TracBrowser for help on using the repository browser.