1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2006
# Author: Stefan Berger <stefanb@us.ibm.com>
#
# Simple test that starts two labeled domains; both domains should start
#
# The following xm subcommands are tested:
# - dumppolicy
# - labels
from XmTestLib import *
from acm_utils import *
import commands
import os
testlabel1 = "green"
testlabel2 = "red"
status, output = traceCommand("xm labels")
labels = ["SystemManagement", "blue", "red", "green"]
for l in labels:
if not re.search(l, output):
FAIL("Label '%s' not found in current policy!", l)
status, output = traceCommand("xm dumppolicy")
if status != 0:
FAIL("'xm dumppolicy' returned an error code.")
lines = ["ssidref 0: 00 00 00 00",
"ssidref 1: 01 00 00 00",
"ssidref 2: 00 01 00 00",
"ssidref 3: 00 00 01 00",
"ssidref 4: 00 00 00 01"]
for l in lines:
if not re.search(l, output):
FAIL("Could not find '%s' in output of 'xm dumppolicy'" % l)
config = {"access_control":"policy=%s,label=%s" % (testpolicy,testlabel1)}
verbose = True
domain1 = XmTestDomain(name="domain-%s" % testlabel1,
extraConfig=config)
try:
domain1.start(noConsole=True)
except DomainError, e:
if verbose:
print e.extra
FAIL("Unable to start 1st labeled test domain.")
config = {"access_control":"policy=%s,label=%s" % (testpolicy,testlabel2)}
domain2 = XmTestDomain(name="domain-%s" % testlabel2,
extraConfig=config)
try:
domain2.start(noConsole=True)
except DomainError, e:
if verbose:
print e.extra
FAIL("Unable to start 2nd labeled test domain.")
domain2.destroy()
domain1.destroy()
|