author | Danek Duvall <danek.duvall@oracle.com> |
Thu, 04 Aug 2011 13:17:33 -0700 | |
changeset 2493 | 5db1603f0c3f |
parent 2488 | 010931d9cabe |
child 2499 | 683824f135a1 |
permissions | -rw-r--r-- |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1 |
# CDDL HEADER START |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
2 |
# |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
3 |
# The contents of this file are subject to the terms of the |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
4 |
# Common Development and Distribution License (the "License"). |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
5 |
# You may not use this file except in compliance with the License. |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
6 |
# |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
7 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
8 |
# or http://www.opensolaris.org/os/licensing. |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
9 |
# See the License for the specific language governing permissions |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
10 |
# and limitations under the License. |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
11 |
# |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
12 |
# When distributing Covered Code, include this CDDL HEADER in each |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
13 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
14 |
# If applicable, add the following below this CDDL HEADER, with the |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
15 |
# fields enclosed by brackets "[]" replaced with your own identifying |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
16 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
17 |
# |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
18 |
# CDDL HEADER END |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
19 |
# |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
20 |
|
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2158
diff
changeset
|
21 |
# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
22 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
23 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
24 |
# Define the basic classes that all test cases are inherited from. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
25 |
# The currently defined test case classes are: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
26 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
27 |
# CliTestCase |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
28 |
# ManyDepotTestCase |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
29 |
# Pkg5TestCase |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
30 |
# SingleDepotTestCase |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
31 |
# SingleDepotTestCaseCorruptImage |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
32 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
33 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
34 |
import baseline |
2085
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
35 |
import ConfigParser |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
36 |
import copy |
1730
c12580e62699
14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents:
1715
diff
changeset
|
37 |
import difflib |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
38 |
import errno |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
39 |
import gettext |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
40 |
import hashlib |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
41 |
import httplib |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
42 |
import logging |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
43 |
import os |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
44 |
import pprint |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
45 |
import shutil |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
46 |
import signal |
1832
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
47 |
import stat |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
48 |
import subprocess |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
49 |
import sys |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
50 |
import tempfile |
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
51 |
import time |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
52 |
import unittest |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
53 |
import urllib2 |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
54 |
import urlparse |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
55 |
import platform |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
56 |
import pwd |
1730
c12580e62699
14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents:
1715
diff
changeset
|
57 |
import re |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
58 |
import ssl |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
59 |
import textwrap |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
60 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
61 |
import pkg.client.api_errors as apx |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
62 |
import pkg.client.publisher as publisher |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
63 |
import pkg.server.repository as sr |
2414
ce704b29a50c
18464 revoka-ca-cert needs a rethink
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2401
diff
changeset
|
64 |
import M2Crypto as m2 |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
65 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
66 |
from pkg.client.debugvalues import DebugValues |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
67 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
68 |
EmptyI = tuple() |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
69 |
EmptyDict = dict() |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
571
diff
changeset
|
70 |
|
2046
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
71 |
# relative to our proto area |
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
72 |
path_to_pub_util = "../../src/util/publish" |
2306
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
73 |
path_to_distro_import_utils = "../../src/util/distro-import" |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
74 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
75 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
76 |
# These are initialized by pkg5testenv.setup_environment. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
77 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
78 |
g_proto_area = "TOXIC" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
79 |
# User's value for TEMPDIR |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
80 |
g_tempdir = "/tmp" |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
81 |
g_fakeroot = "TOXIC" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
82 |
g_fakeroot_repo = "TOXIC" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
83 |
g_pkg_cmdpath = "TOXIC" |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
84 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
85 |
g_debug_output = False |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
86 |
if "DEBUG" in os.environ: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
87 |
g_debug_output = True |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
88 |
|
2272
d81ea073d050
3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2240
diff
changeset
|
89 |
# The lowest port to use in the test suite. |
d81ea073d050
3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2240
diff
changeset
|
90 |
g_base_port = None |
d81ea073d050
3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2240
diff
changeset
|
91 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
92 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
93 |
# XXX? |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
94 |
# |
1946
8ef3acf32d54
16132 various bits of pkg specify non-existent domains to gettext.install
Richard Lowe <richlowe@richlowe.net>
parents:
1908
diff
changeset
|
95 |
gettext.install("pkg", "/usr/share/locale") |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
96 |
|
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
97 |
OUTPUT_DOTS = 0 # Dots ... |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
98 |
OUTPUT_VERBOSE = 1 # Verbose |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
99 |
OUTPUT_PARSEABLE = 2 # Machine readable |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
100 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
101 |
class TestStopException(Exception): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
102 |
"""An exception used to signal that all testing should cease. |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
103 |
This is a framework-internal exception that tests should not |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
104 |
raise""" |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
105 |
pass |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
106 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
107 |
class TestSkippedException(Exception): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
108 |
"""An exception used to signal that a test was skipped. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
109 |
Should be initialized with a string giving a more detailed |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
110 |
reason. Test cases can raise this to the framework |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
111 |
that some prerequisite of the test is unsatisfied. A string |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
112 |
explaining the error should be passed at construction. """ |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
113 |
def __str__(self): |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
114 |
return "Test Skipped: " + " ".join(self.args) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
115 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
116 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
117 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
118 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
119 |
# Errors for which the traceback is likely not useful. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
120 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
121 |
import pkg.depotcontroller as depotcontroller |
1832
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
122 |
import pkg.portable as portable |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
123 |
import pkg.client.api |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
124 |
import pkg.client.progress |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
125 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
126 |
from pkg.client.debugvalues import DebugValues |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
127 |
|
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
128 |
# Version test suite is known to work with. |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
129 |
PKG_CLIENT_NAME = "pkg" |
2493
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
130 |
CLIENT_API_VERSION = 65 |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
131 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
132 |
ELIDABLE_ERRORS = [ TestSkippedException, depotcontroller.DepotStateException ] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
133 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
134 |
class Pkg5CommonException(AssertionError): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
135 |
def __init__(self, com = ""): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
136 |
Pkg5TestCase.failureException.__init__(self, com) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
137 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
138 |
topdivider = \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
139 |
",---------------------------------------------------------------------\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
140 |
botdivider = \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
141 |
"`---------------------------------------------------------------------\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
142 |
def format_comment(self, comment): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
143 |
if comment is not None: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
144 |
comment = comment.expandtabs() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
145 |
comm = "" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
146 |
for line in comment.splitlines(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
147 |
line = line.strip() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
148 |
if line == "": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
149 |
continue |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
150 |
comm += " " + line + "\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
151 |
return comm + "\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
152 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
153 |
return "<no comment>\n\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
154 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
155 |
def format_output(self, command, output): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
156 |
str = " Output Follows:\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
157 |
str += self.topdivider |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
158 |
if command is not None: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
159 |
str += "| $ " + command + "\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
160 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
161 |
if output is None or output == "": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
162 |
str += "| <no output>\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
163 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
164 |
for line in output.split("\n"): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
165 |
str += "| " + line.rstrip() + "\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
166 |
str += self.botdivider |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
167 |
return str |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
168 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
169 |
def format_debug(self, output): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
170 |
str = " Debug Buffer Follows:\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
171 |
str += self.topdivider |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
172 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
173 |
if output is None or output == "": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
174 |
str += "| <no debug buffer>\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
175 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
176 |
for line in output.split("\n"): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
177 |
str += "| " + line.rstrip() + "\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
178 |
str += self.botdivider |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
179 |
return str |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
180 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
181 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
182 |
class AssFailException(Pkg5CommonException): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
183 |
def __init__(self, comment = None, debug=None): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
184 |
Pkg5CommonException.__init__(self, comment) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
185 |
self.__comment = comment |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
186 |
self.__debug = debug |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
187 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
188 |
def __str__(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
189 |
str = "" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
190 |
if self.__comment is None: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
191 |
str += Exception.__str__(self) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
192 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
193 |
str += self.format_comment(self.__comment) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
194 |
if self.__debug is not None and self.__debug != "": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
195 |
str += self.format_debug(self.__debug) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
196 |
return str |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
197 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
198 |
|
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
199 |
class DebugLogHandler(logging.Handler): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
200 |
"""This class is a special log handler to redirect logger output to |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
201 |
the test case class' debug() method. |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
202 |
""" |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
203 |
|
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
204 |
def __init__(self, test_case): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
205 |
self.test_case = test_case |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
206 |
logging.Handler.__init__(self) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
207 |
|
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
208 |
def emit(self, record): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
209 |
self.test_case.debug(record) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
210 |
|
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
211 |
def setup_logging(test_case): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
212 |
# Ensure logger messages output by unit tests are redirected |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
213 |
# to debug output so they are not shown by default. |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
214 |
from pkg.client import global_settings |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
215 |
log_handler = DebugLogHandler(test_case) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
216 |
global_settings.info_log_handler = log_handler |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
217 |
global_settings.error_log_handler = log_handler |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
218 |
|
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
219 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
220 |
class Pkg5TestCase(unittest.TestCase): |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
221 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
222 |
# Needed for compatibility |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
223 |
failureException = AssertionError |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
224 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
225 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
226 |
# Some dns servers return results for unknown dns names to redirect |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
227 |
# callers to a common landing page. To avoid getting tripped up by |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
228 |
# these stupid servers make sure that bogus_url actually contains an |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
229 |
# syntactically invalid dns name so we'll never succeed at the lookup. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
230 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
231 |
bogus_url = "test.0.invalid" |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
232 |
__debug_buf = "" |
683
5e5d509f00e3
4422 t_pkg_authority pinging extant node accidentally
Brock Pytlik <bpytlik@sun.com>
parents:
616
diff
changeset
|
233 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
234 |
smf_cmds = { \ |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
235 |
"usr/bin/svcprop" : """\ |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
236 |
#!/usr/bin/python |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
237 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
238 |
import sys |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
239 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
240 |
if __name__ == "__main__": |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
241 |
sys.exit(1) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
242 |
"""} |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
243 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
244 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
245 |
def __init__(self, methodName='runTest'): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
246 |
super(Pkg5TestCase, self).__init__(methodName) |
2272
d81ea073d050
3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2240
diff
changeset
|
247 |
assert g_base_port |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
248 |
self.__test_root = None |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
249 |
self.__pid = os.getpid() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
250 |
self.__pwd = os.getcwd() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
251 |
self.__didteardown = False |
2272
d81ea073d050
3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2240
diff
changeset
|
252 |
self._base_port = g_base_port |
d81ea073d050
3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2240
diff
changeset
|
253 |
self.next_free_port = self._base_port |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
254 |
setup_logging(self) |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
255 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
256 |
def __str__(self): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
257 |
return "%s.py %s.%s" % (self.__class__.__module__, |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
258 |
self.__class__.__name__, self._testMethodName) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
259 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
260 |
def assertRaisesStringify(self, excClass, callableObj, *args, **kwargs): |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
261 |
"""Perform the same logic as assertRaises, but then verify that |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
262 |
the exception raised can be stringified.""" |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
263 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
264 |
try: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
265 |
callableObj(*args, **kwargs) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
266 |
except excClass, e: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
267 |
str(e) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
268 |
return |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
269 |
else: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
270 |
raise self.failureException, "%s not raised" % excClass |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2218
diff
changeset
|
271 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
272 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
273 |
# Uses property() to implements test_root as a read-only attribute. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
274 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
275 |
test_root = property(fget=lambda self: self.__test_root) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
276 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
277 |
def __get_ro_data_root(self): |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
278 |
if not self.__test_root: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
279 |
return None |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
280 |
return os.path.join(self.__test_root, "ro_data") |
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2158
diff
changeset
|
281 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
282 |
ro_data_root = property(fget=__get_ro_data_root) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
283 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
284 |
def persistent_setup_copy(self, orig): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
285 |
pass |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
286 |
|
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
287 |
def cmdline_run(self, cmdline, comment="", coverage=True, exit=0, |
2046
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
288 |
handle=False, out=False, prefix="", raise_error=True, su_wrap=None, |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
289 |
stderr=False, env_arg=None): |
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
290 |
wrapper = "" |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
291 |
if coverage: |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
292 |
wrapper = self.coverage_cmd |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
293 |
su_wrap, su_end = self.get_su_wrapper(su_wrap=su_wrap) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
294 |
|
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
295 |
cmdline = "%s%s%s %s%s" % (prefix, su_wrap, wrapper, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
296 |
cmdline, su_end) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
297 |
self.debugcmd(cmdline) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
298 |
|
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
299 |
newenv = os.environ.copy() |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
300 |
if coverage: |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
301 |
newenv.update(self.coverage_env) |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
302 |
if env_arg: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
303 |
newenv.update(env_arg) |
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
304 |
|
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
305 |
p = subprocess.Popen(cmdline, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
306 |
env=newenv, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
307 |
shell=True, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
308 |
stdout=subprocess.PIPE, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
309 |
stderr=subprocess.PIPE) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
310 |
|
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
311 |
if handle: |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
312 |
# Do nothing more. |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
313 |
return p |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
314 |
self.output, self.errout = p.communicate() |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
315 |
retcode = p.returncode |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
316 |
self.debugresult(retcode, exit, self.output) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
317 |
if self.errout != "": |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
318 |
self.debug(self.errout) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
319 |
|
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
320 |
if raise_error and retcode == 99: |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
321 |
raise TracebackException(cmdline, self.output + |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
322 |
self.errout, comment) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
323 |
|
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
324 |
if not isinstance(exit, list): |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
325 |
exit = [exit] |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
326 |
|
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
327 |
if raise_error and retcode not in exit: |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
328 |
raise UnexpectedExitCodeException(cmdline, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
329 |
exit, retcode, self.output + self.errout, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
330 |
comment) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
331 |
|
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
332 |
if out: |
2046
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
333 |
if stderr: |
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
334 |
return retcode, self.output, self.errout |
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
335 |
return retcode, self.output |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
336 |
return retcode |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
337 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
338 |
def debug(self, s): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
339 |
s = str(s) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
340 |
for x in s.splitlines(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
341 |
if g_debug_output: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
342 |
print >> sys.stderr, "# %s" % x |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
343 |
self.__debug_buf += x + "\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
344 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
345 |
def debugcmd(self, cmdline): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
346 |
wrapper = textwrap.TextWrapper(initial_indent="$ ", |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
347 |
subsequent_indent="\t", |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
348 |
break_long_words=False, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
349 |
break_on_hyphens=False) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
350 |
res = wrapper.wrap(cmdline.strip()) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
351 |
self.debug(" \\\n".join(res)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
352 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
353 |
def debugfilecreate(self, content, path): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
354 |
lines = content.splitlines() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
355 |
if lines == []: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
356 |
lines = [""] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
357 |
if len(lines) > 1: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
358 |
ins = " [+%d lines...]" % (len(lines) - 1) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
359 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
360 |
ins = "" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
361 |
self.debugcmd( |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
362 |
"echo '%s%s' > %s" % (lines[0], ins, path)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
363 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
364 |
def debugresult(self, retcode, expected, output): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
365 |
if output.strip() != "": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
366 |
self.debug(output.strip()) |
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
367 |
if not isinstance(expected, list): |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
368 |
expected = [expected] |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
369 |
if retcode is None or retcode != 0 or \ |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
370 |
retcode not in expected: |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
371 |
self.debug("[exited %s, expected %s]" % |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
372 |
(retcode, ", ".join(str(e) for e in expected))) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
373 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
374 |
def get_debugbuf(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
375 |
return self.__debug_buf |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
376 |
|
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
377 |
def get_su_wrapper(self, su_wrap=None): |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
378 |
if su_wrap: |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
379 |
if su_wrap == True: |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
380 |
su_wrap = get_su_wrap_user() |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
381 |
cov_env = " ".join( |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
382 |
("%s=%s" % e for e in self.coverage_env.items())) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
383 |
su_wrap = "su %s -c 'LD_LIBRARY_PATH=%s %s " % \ |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
384 |
(su_wrap, os.getenv("LD_LIBRARY_PATH", ""), cov_env) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
385 |
su_end = "'" |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
386 |
else: |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
387 |
su_wrap = "" |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
388 |
su_end = "" |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
389 |
return su_wrap, su_end |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
390 |
|
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
391 |
def getTeardownFunc(self): |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
392 |
return (self, self.tearDown) |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
393 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
394 |
def getSetupFunc(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
395 |
return (self, self.setUp) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
396 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
397 |
def setUp(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
398 |
self.__test_root = os.path.join(g_tempdir, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
399 |
"ips.test.%d" % self.__pid) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
400 |
self.__didtearDown = False |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
401 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
402 |
os.makedirs(self.__test_root, 0755) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
403 |
except OSError, e: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
404 |
if e.errno != errno.EEXIST: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
405 |
raise e |
2046
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
406 |
test_relative = os.path.sep.join(["..", "..", "src", "tests"]) |
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
407 |
test_src = os.path.join(g_proto_area, test_relative) |
2272
d81ea073d050
3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2240
diff
changeset
|
408 |
if getattr(self, "need_ro_data", False): |
d81ea073d050
3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2240
diff
changeset
|
409 |
shutil.copytree(os.path.join(test_src, "ro_data"), |
d81ea073d050
3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2240
diff
changeset
|
410 |
self.ro_data_root) |
2433
7af4ccfa1c06
5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents:
2414
diff
changeset
|
411 |
self.path_to_certs = os.path.join(self.ro_data_root, |
7af4ccfa1c06
5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents:
2414
diff
changeset
|
412 |
"signing_certs", "produced") |
7af4ccfa1c06
5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents:
2414
diff
changeset
|
413 |
self.keys_dir = os.path.join(self.path_to_certs, "keys") |
7af4ccfa1c06
5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents:
2414
diff
changeset
|
414 |
self.cs_dir = os.path.join(self.path_to_certs, |
7af4ccfa1c06
5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents:
2414
diff
changeset
|
415 |
"code_signing_certs") |
7af4ccfa1c06
5060 cert and key files should be validated when adding or updating publishers
Shawn Walker <shawn.walker@oracle.com>
parents:
2414
diff
changeset
|
416 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
417 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
418 |
# TMPDIR affects the behavior of mkdtemp and mkstemp. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
419 |
# Setting this here should ensure that tests will make temp |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
420 |
# files and dirs inside the test directory rather than |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
421 |
# polluting /tmp. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
422 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
423 |
os.environ["TMPDIR"] = self.__test_root |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
424 |
tempfile.tempdir = self.__test_root |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
425 |
setup_logging(self) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
426 |
|
2085
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
427 |
self.configure_rcfile( "%s/usr/share/lib/pkg/pkglintrc" % |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
428 |
g_proto_area, |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
429 |
{"info_classification_path": |
2223
2da8c49e53dc
17735 build should use custom pkglintrc to locate proto version of opensolaris.org.sections
Tim Foster <tim.s.foster@oracle.com>
parents:
2219
diff
changeset
|
430 |
"%s/usr/share/lib/pkg/opensolaris.org.sections" % |
2085
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
431 |
g_proto_area}, self.test_root, section="pkglint") |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
432 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
433 |
self.template_dir = "%s/etc/pkg/sysrepo" % g_proto_area |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
434 |
self.make_misc_files(self.smf_cmds, prefix="smf_cmds", |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
435 |
mode=0755) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
436 |
DebugValues["smf_cmds_dir"] = \ |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
437 |
os.path.join(self.test_root, "smf_cmds") |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
438 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
439 |
def impl_tearDown(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
440 |
# impl_tearDown exists so that we can ensure that this class's |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
441 |
# teardown is actually called. Sometimes, subclasses will |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
442 |
# implement teardown but forget to call the superclass teardown. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
443 |
if self.__didteardown: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
444 |
return |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
445 |
self.__didteardown = True |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
446 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
447 |
os.chdir(self.__pwd) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
448 |
except OSError: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
449 |
# working directory of last resort. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
450 |
os.chdir(g_tempdir) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
451 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
452 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
453 |
# Kill depots before blowing away test dir-- otherwise |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
454 |
# the depot can race with the shutil.rmtree() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
455 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
456 |
if hasattr(self, "killalldepots"): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
457 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
458 |
self.killalldepots() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
459 |
except Exception, e: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
460 |
print >> sys.stderr, str(e) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
461 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
462 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
463 |
# We have some sloppy subclasses which don't call the superclass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
464 |
# setUp-- in which case the dir might not exist. Tolerate it. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
465 |
# |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
466 |
# Also, avoid deleting our fakeroot since then we'd have to |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
467 |
# keep re-creating it. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
468 |
# |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
469 |
if self.__test_root is not None and \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
470 |
os.path.exists(self.__test_root): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
471 |
for d in os.listdir(self.__test_root): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
472 |
path = os.path.join(self.__test_root, d) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
473 |
if path in [g_fakeroot, g_fakeroot_repo]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
474 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
475 |
self.debug("removing: %s" % path) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
476 |
if os.path.isdir(path): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
477 |
shutil.rmtree(path) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
478 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
479 |
os.remove(path) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
480 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
481 |
def tearDown(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
482 |
# In reality this call does nothing. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
483 |
unittest.TestCase.tearDown(self) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
484 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
485 |
self.impl_tearDown() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
486 |
|
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
487 |
def run(self, result=None): |
436 | 488 |
if result is None: |
489 |
result = self.defaultTestResult() |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
490 |
pwd = os.getcwd() |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
491 |
result.startTest(self) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
492 |
testMethod = getattr(self, self._testMethodName) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
493 |
if getattr(result, "coverage", None) is not None: |
1513
3ece69a26155
5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents:
1505
diff
changeset
|
494 |
self.coverage_cmd, self.coverage_env = result.coverage |
3ece69a26155
5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents:
1505
diff
changeset
|
495 |
else: |
3ece69a26155
5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents:
1505
diff
changeset
|
496 |
self.coverage_cmd, self.coverage_env = "", {} |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
497 |
try: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
498 |
needtodie = False |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
499 |
try: |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
500 |
self.setUp() |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
501 |
except KeyboardInterrupt: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
502 |
# Try hard to make sure we've done a teardown. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
503 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
504 |
self.tearDown() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
505 |
except: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
506 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
507 |
self.impl_tearDown() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
508 |
raise TestStopException |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
509 |
except: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
510 |
# teardown could fail too, esp. if setup failed... |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
511 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
512 |
self.tearDown() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
513 |
except: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
514 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
515 |
# Try hard to make sure we've done a teardown. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
516 |
self.impl_tearDown() |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
517 |
result.addError(self, sys.exc_info()) |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
518 |
return |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
519 |
|
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
520 |
ok = False |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
521 |
error_added = False |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
522 |
try: |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
523 |
testMethod() |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
524 |
ok = True |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
525 |
except self.failureException: |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
526 |
result.addFailure(self, sys.exc_info()) |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
527 |
except KeyboardInterrupt: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
528 |
# Try hard to make sure we've done a teardown. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
529 |
needtodie = True |
2306
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
530 |
except TestSkippedException, err: |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
531 |
result.addSkip(self, err) |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
532 |
except: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
533 |
error_added = True |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
534 |
result.addError(self, sys.exc_info()) |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
535 |
|
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
536 |
try: |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
537 |
self.tearDown() |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
538 |
except KeyboardInterrupt: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
539 |
needtodie = True |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
540 |
except: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
541 |
# Try hard to make sure we've done a teardown. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
542 |
self.impl_tearDown() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
543 |
# Make sure we don't mark this error'd twice. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
544 |
if not error_added: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
545 |
result.addError(self, sys.exc_info()) |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
546 |
ok = False |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
547 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
548 |
if needtodie: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
549 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
550 |
self.impl_tearDown() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
551 |
except: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
552 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
553 |
raise TestStopException |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
554 |
|
436 | 555 |
if ok: |
556 |
result.addSuccess(self) |
|
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
557 |
finally: |
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
558 |
result.stopTest(self) |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
559 |
# make sure we restore our directory if it still exists. |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
560 |
try: |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
561 |
os.chdir(pwd) |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
562 |
except OSError, e: |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
563 |
# If directory doesn't exist anymore it doesn't |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
564 |
# matter. |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
565 |
if e.errno != errno.ENOENT: |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
566 |
raise |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
567 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
568 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
569 |
# The following are utility functions for use by testcases. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
570 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
571 |
def c_compile(self, prog_text, opts, outputfile): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
572 |
"""Given a C program (as a string), compile it into the |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
573 |
executable given by outputfile. Outputfile should be |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
574 |
given as a relative path, and will be located below the |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
575 |
test prefix path. Additional compiler options should be |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
576 |
passed in 'opts'. Suitable for compiling small test |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
577 |
programs.""" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
578 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
579 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
580 |
# We use a series of likely compilers. At present we support |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
581 |
# this testing with SunStudio. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
582 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
583 |
if os.path.dirname(outputfile) != "": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
584 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
585 |
os.makedirs(os.path.dirname(outputfile)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
586 |
except OSError, e: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
587 |
if e.errno != errno.EEXIST: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
588 |
raise |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
589 |
c_fd, c_path = tempfile.mkstemp(suffix=".c", |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
590 |
dir=self.test_root) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
591 |
c_fh = os.fdopen(c_fd, "w") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
592 |
c_fh.write(prog_text) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
593 |
c_fh.close() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
594 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
595 |
found = False |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
596 |
outpath = os.path.join(self.test_root, outputfile) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
597 |
compilers = ["/usr/bin/cc", "cc", "$CC"] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
598 |
for compiler in compilers: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
599 |
cmd = [compiler, "-o", outpath] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
600 |
cmd.extend(opts) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
601 |
cmd.append(c_path) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
602 |
try: |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
603 |
# Make sure to use shell=True so that env. |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
604 |
# vars and $PATH are evaluated. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
605 |
self.debugcmd(" ".join(cmd)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
606 |
s = subprocess.Popen(" ".join(cmd), |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
607 |
shell=True, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
608 |
stdout=subprocess.PIPE, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
609 |
stderr=subprocess.STDOUT) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
610 |
sout, serr = s.communicate() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
611 |
rc = s.returncode |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
612 |
if rc != 0 and rc != 127: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
613 |
try: os.remove(outpath) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
614 |
except OSError: pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
615 |
try: os.remove(c_path) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
616 |
except OSError: pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
617 |
raise RuntimeError( |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
618 |
"Compile failed: %s --> %d\n%s" % \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
619 |
(cmd, rc, sout)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
620 |
if rc == 127: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
621 |
self.debug("[%s not found]" % compiler) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
622 |
continue |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
623 |
# so rc == 0 |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
624 |
found = True |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
625 |
break |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
626 |
except OSError: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
627 |
continue |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
628 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
629 |
os.remove(c_path) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
630 |
except OSError: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
631 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
632 |
if not found: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
633 |
raise TestSkippedException( |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
634 |
"No suitable Sun Studio compiler found. " |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
635 |
"Tried: %s. Try setting $CC to a valid" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
636 |
"compiler." % compilers) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
637 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
638 |
def make_file(self, path, content, mode=0644): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
639 |
if not os.path.exists(os.path.dirname(path)): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
640 |
os.makedirs(os.path.dirname(path), 0777) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
641 |
self.debugfilecreate(content, path) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
642 |
fh = open(path, 'wb') |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
643 |
if isinstance(content, unicode): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
644 |
content = content.encode("utf-8") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
645 |
fh.write(content) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
646 |
fh.close() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
647 |
os.chmod(path, mode) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
648 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
649 |
def make_misc_files(self, files, prefix=None, mode=0644): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
650 |
""" Make miscellaneous text files. Files can be a |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
651 |
single relative pathname, a list of relative pathnames, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
652 |
or a hash mapping relative pathnames to specific contents. |
1839
53bdcdd547cb
11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
653 |
If file contents are not specified, the pathname of the |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
654 |
file is placed into the file as default content. """ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
655 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
656 |
outpaths = [] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
657 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
658 |
# If files is a string, make it a list. Then, if it is |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
659 |
# a list, simply turn it into a dict where each file's |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
660 |
# contents is its own name, so that we get some uniqueness. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
661 |
# |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
662 |
if isinstance(files, basestring): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
663 |
files = [files] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
664 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
665 |
if isinstance(files, list): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
666 |
nfiles = {} |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
667 |
for f in files: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
668 |
nfiles[f] = f |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
669 |
files = nfiles |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
670 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
671 |
if prefix is None: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
672 |
prefix = self.test_root |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
673 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
674 |
assert(not prefix.startswith(os.pathsep)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
675 |
prefix = os.path.join(self.test_root, prefix) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
676 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
677 |
for f, content in files.items(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
678 |
assert not f.startswith("/"), \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
679 |
("%s: misc file paths must be relative!" % f) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
680 |
path = os.path.join(prefix, f) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
681 |
self.make_file(path, content, mode) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
682 |
outpaths.append(path) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
683 |
return outpaths |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
684 |
|
2456
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
685 |
def make_manifest(self, content, manifest_dir="manifests", pfmri=None): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
686 |
# Trim to ensure nice looking output. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
687 |
content = content.strip() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
688 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
689 |
# Place inside of test prefix. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
690 |
manifest_dir = os.path.join(self.test_root, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
691 |
manifest_dir) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
692 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
693 |
if not os.path.exists(manifest_dir): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
694 |
os.makedirs(manifest_dir) |
2456
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
695 |
t_fd, t_path = tempfile.mkstemp(prefix="mfst.", |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
696 |
dir=manifest_dir) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
697 |
t_fh = os.fdopen(t_fd, "w") |
2456
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
698 |
if pfmri: |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
699 |
t_fh.write("set name=pkg.fmri value=%s\n" % pfmri) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
700 |
t_fh.write(content) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
701 |
t_fh.close() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
702 |
self.debugfilecreate(content, t_path) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
703 |
return t_path |
435
461b1c739de9
1753 An exception thrown during the teardown phase of the test program leaves pkg.depot running.
Brock Pytlik <bpytlik@sun.com>
parents:
430
diff
changeset
|
704 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
705 |
@staticmethod |
2414
ce704b29a50c
18464 revoka-ca-cert needs a rethink
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2401
diff
changeset
|
706 |
def calc_pem_hash(pth): |
ce704b29a50c
18464 revoka-ca-cert needs a rethink
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2401
diff
changeset
|
707 |
# Find the hash of pem representation the file. |
ce704b29a50c
18464 revoka-ca-cert needs a rethink
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2401
diff
changeset
|
708 |
cert = m2.X509.load_cert(pth) |
ce704b29a50c
18464 revoka-ca-cert needs a rethink
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2401
diff
changeset
|
709 |
return hashlib.sha1(cert.as_pem()).hexdigest() |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
710 |
|
1730
c12580e62699
14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents:
1715
diff
changeset
|
711 |
def reduceSpaces(self, string): |
c12580e62699
14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents:
1715
diff
changeset
|
712 |
"""Reduce runs of spaces down to a single space.""" |
c12580e62699
14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents:
1715
diff
changeset
|
713 |
return re.sub(" +", " ", string) |
1946
8ef3acf32d54
16132 various bits of pkg specify non-existent domains to gettext.install
Richard Lowe <richlowe@richlowe.net>
parents:
1908
diff
changeset
|
714 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
715 |
def assertEqualDiff(self, expected, actual, bound_white_space=False): |
1730
c12580e62699
14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents:
1715
diff
changeset
|
716 |
"""Compare two strings.""" |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
717 |
|
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
718 |
if not isinstance(expected, basestring): |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
719 |
expected = pprint.pformat(expected) |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
720 |
if not isinstance(actual, basestring): |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
721 |
actual = pprint.pformat(actual) |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
722 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
723 |
expected_lines = expected.splitlines() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
724 |
actual_lines = actual.splitlines() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
725 |
if bound_white_space: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
726 |
expected_lines = ["'%s'" % l for l in expected_lines] |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
727 |
actual_lines = ["'%s'" % l for l in actual_lines] |
1730
c12580e62699
14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents:
1715
diff
changeset
|
728 |
self.assertEqual(expected, actual, |
c12580e62699
14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents:
1715
diff
changeset
|
729 |
"Actual output differed from expected output.\n" + |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
730 |
"\n".join(difflib.unified_diff(expected_lines, actual_lines, |
1730
c12580e62699
14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents:
1715
diff
changeset
|
731 |
"Expected output", "Actual output", lineterm=""))) |
1946
8ef3acf32d54
16132 various bits of pkg specify non-existent domains to gettext.install
Richard Lowe <richlowe@richlowe.net>
parents:
1908
diff
changeset
|
732 |
|
2085
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
733 |
def configure_rcfile(self, rcfile, config, test_root, section="DEFAULT", |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
734 |
suffix=""): |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
735 |
"""Reads the provided rcfile file, setting key/value |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
736 |
pairs in the provided section those from the 'config' |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
737 |
dictionary. The new config file is written to the supplied |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
738 |
test_root, returning the name of that new file. |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
739 |
|
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
740 |
Used to set keys to point to paths beneath our test_root, |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
741 |
which would otherwise be shipped as hard-coded paths, relative |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
742 |
to /. |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
743 |
""" |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
744 |
|
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
745 |
new_rcfile = file("%s/%s%s" % (test_root, os.path.basename(rcfile), |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
746 |
suffix), "w") |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
747 |
|
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
748 |
conf = ConfigParser.SafeConfigParser() |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
749 |
conf.readfp(open(rcfile)) |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
750 |
|
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
751 |
for key in config: |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
752 |
conf.set(section, key, config[key]) |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
753 |
|
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
754 |
conf.write(new_rcfile) |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
755 |
return new_rcfile.name |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
756 |
|
1730
c12580e62699
14347 Add tests to exercise the new -F tsv option for pkg publisher
Gary Pennington <gary.pennington@sun.com>
parents:
1715
diff
changeset
|
757 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
758 |
class _Pkg5TestResult(unittest._TextTestResult): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
759 |
baseline = None |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
760 |
machsep = "|" |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
761 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
762 |
def __init__(self, stream, output, baseline, bailonfail=False, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
763 |
show_on_expected_fail=False, archive_dir=None): |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
764 |
unittest.TestResult.__init__(self) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
765 |
self.stream = stream |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
766 |
self.output = output |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
767 |
self.baseline = baseline |
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
768 |
self.success = [] |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
769 |
self.mismatches = [] |
1421
d6733f41c267
3961 Test suite should have a flag that makes it stop after encountering a failure
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1101
diff
changeset
|
770 |
self.bailonfail = bailonfail |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
771 |
self.show_on_expected_fail = show_on_expected_fail |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
772 |
self.archive_dir = archive_dir |
2306
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
773 |
self.skips = [] |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
774 |
|
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
775 |
def getDescription(self, test): |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
776 |
return str(test) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
777 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
778 |
# Override the unittest version of this so that success is |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
779 |
# considered "matching the baseline" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
780 |
def wasSuccessful(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
781 |
return len(self.mismatches) == 0 |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
782 |
|
2306
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
783 |
def wasSkipped(self): |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
784 |
return len(self.skips) != 0 |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
785 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
786 |
def dobailout(self, test): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
787 |
""" Pull the ejection lever. Stop execution, doing as |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
788 |
much forcible cleanup as possible. """ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
789 |
inst, tdf = test.getTeardownFunc() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
790 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
791 |
tdf() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
792 |
except Exception, e: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
793 |
print >> sys.stderr, str(e) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
794 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
795 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
796 |
if getattr(test, "persistent_setup", None): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
797 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
798 |
test.reallytearDown() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
799 |
except Exception, e: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
800 |
print >> sys.stderr, str(e) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
801 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
802 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
803 |
if hasattr(inst, "killalldepots"): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
804 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
805 |
inst.killalldepots() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
806 |
except Exception, e: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
807 |
print >> sys.stderr, str(e) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
808 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
809 |
raise TestStopException() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
810 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
811 |
def fmt_parseable(self, match, actual, expected): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
812 |
if match == baseline.BASELINE_MATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
813 |
mstr = "MATCH" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
814 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
815 |
mstr = "MISMATCH" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
816 |
return "%s|%s|%s" % (mstr, actual, expected) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
817 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
818 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
819 |
@staticmethod |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
820 |
def fmt_prefix_with(instr, prefix): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
821 |
res = "" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
822 |
for s in instr.splitlines(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
823 |
res += "%s%s\n" % (prefix, s) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
824 |
return res |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
825 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
826 |
@staticmethod |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
827 |
def fmt_box(instr, title, prefix=""): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
828 |
trailingdashes = (50 - len(title)) * "-" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
829 |
res = "\n.---" + title + trailingdashes + "\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
830 |
for s in instr.splitlines(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
831 |
if s.strip() == "": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
832 |
continue |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
833 |
res += "| %s\n" % s |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
834 |
res += "`---" + len(title) * "-" + trailingdashes |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
835 |
return _Pkg5TestResult.fmt_prefix_with(res, prefix) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
836 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
837 |
def do_archive(self, test, info): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
838 |
assert self.archive_dir |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
839 |
if not os.path.exists(self.archive_dir): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
840 |
os.makedirs(self.archive_dir, mode=0755) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
841 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
842 |
archive_path = os.path.join(self.archive_dir, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
843 |
"%d" % os.getpid()) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
844 |
if not os.path.exists(archive_path): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
845 |
os.makedirs(archive_path, mode=0755) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
846 |
archive_path = os.path.join(archive_path, test.id()) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
847 |
if g_debug_output: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
848 |
self.stream.writeln("# Archiving to %s" % archive_path) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
849 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
850 |
if os.path.exists(test.test_root): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
851 |
shutil.copytree(test.test_root, archive_path, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
852 |
symlinks=True) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
853 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
854 |
# If the test has failed without creating its directory, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
855 |
# make it manually, so that we have a place to write out |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
856 |
# ERROR_INFO. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
857 |
os.makedirs(archive_path, mode=0755) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
858 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
859 |
f = open(os.path.join(archive_path, "ERROR_INFO"), "w") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
860 |
f.write("------------------DEBUG LOG---------------\n") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
861 |
f.write(test.get_debugbuf()) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
862 |
if info is not None: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
863 |
f.write("\n\n------------------EXCEPTION---------------\n") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
864 |
f.write(info) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
865 |
f.close() |
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
866 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
867 |
def addSuccess(self, test): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
868 |
unittest.TestResult.addSuccess(self, test) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
869 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
870 |
# If we're debugging, we'll have had output since we |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
871 |
# announced the name of the test, so restate it. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
872 |
if g_debug_output: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
873 |
self.statename(test) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
874 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
875 |
errinfo = self.format_output_and_exc(test, None) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
876 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
877 |
bresult = self.baseline.handleresult(str(test), "pass") |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
878 |
expected = self.baseline.expectedresult(str(test)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
879 |
if self.output == OUTPUT_PARSEABLE: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
880 |
res = self.fmt_parseable(bresult, "pass", expected) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
881 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
882 |
elif self.output == OUTPUT_VERBOSE: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
883 |
if bresult == baseline.BASELINE_MATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
884 |
res = "match pass" |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
885 |
else: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
886 |
res = "MISMATCH pass (expected: %s)" % \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
887 |
expected |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
888 |
res = self.fmt_box(errinfo, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
889 |
"Successful Test", "# ") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
890 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
891 |
assert self.output == OUTPUT_DOTS |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
892 |
res = "." |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
893 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
894 |
if self.output != OUTPUT_DOTS: |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
895 |
self.stream.writeln(res) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
896 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
897 |
self.stream.write(res) |
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
898 |
self.success.append(test) |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
899 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
900 |
if bresult == baseline.BASELINE_MISMATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
901 |
self.mismatches.append(test) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
902 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
903 |
if bresult == baseline.BASELINE_MISMATCH and self.archive_dir: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
904 |
self.do_archive(test, None) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
905 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
906 |
# Bail out completely if the 'bail on fail' flag is set |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
907 |
# but iff the result disagrees with the baseline. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
908 |
if self.bailonfail and bresult == baseline.BASELINE_MISMATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
909 |
self.dobailout(test) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
910 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
911 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
912 |
def addError(self, test, err): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
913 |
errtype, errval = err[:2] |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
914 |
# for a few special exceptions, we delete the traceback so |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
915 |
# as to elide it. use only when the traceback itself |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
916 |
# is not likely to be useful. |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
917 |
if errtype in ELIDABLE_ERRORS: |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
918 |
unittest.TestResult.addError(self, test, |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
919 |
(err[0], err[1], None)) |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
920 |
else: |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
921 |
unittest.TestResult.addError(self, test, err) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
922 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
923 |
# If we're debugging, we'll have had output since we |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
924 |
# announced the name of the test, so restate it. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
925 |
if g_debug_output: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
926 |
self.statename(test) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
927 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
928 |
errinfo = self.format_output_and_exc(test, err) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
929 |
|
1002
56ab3be9a8b7
3488 Test suite should supress expected failures (or notate them more clearly)
Danek Duvall <danek.duvall@sun.com>
parents:
683
diff
changeset
|
930 |
bresult = self.baseline.handleresult(str(test), "error") |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
931 |
expected = self.baseline.expectedresult(str(test)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
932 |
if self.output == OUTPUT_PARSEABLE: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
933 |
if errtype in ELIDABLE_ERRORS: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
934 |
res = self.fmt_parseable(bresult, "ERROR", expected) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
935 |
res += "\n# %s\n" % str(errval).strip() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
936 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
937 |
res = self.fmt_parseable(bresult, "ERROR", expected) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
938 |
res += "\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
939 |
if bresult == baseline.BASELINE_MISMATCH \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
940 |
or self.show_on_expected_fail: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
941 |
res += self.fmt_prefix_with(errinfo, "# ") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
942 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
943 |
elif self.output == OUTPUT_VERBOSE: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
944 |
if bresult == baseline.BASELINE_MATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
945 |
b = "match" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
946 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
947 |
b = "MISMATCH" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
948 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
949 |
if errtype in ELIDABLE_ERRORS: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
950 |
res = "%s ERROR\n" % b |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
951 |
res += "#\t%s" % str(errval) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
952 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
953 |
res = "%s ERROR\n" % b |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
954 |
if bresult == baseline.BASELINE_MISMATCH \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
955 |
or self.show_on_expected_fail: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
956 |
res += self.fmt_box(errinfo, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
957 |
"Error Information", "# ") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
958 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
959 |
elif self.output == OUTPUT_DOTS: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
960 |
if bresult == baseline.BASELINE_MATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
961 |
res = "e" |
1002
56ab3be9a8b7
3488 Test suite should supress expected failures (or notate them more clearly)
Danek Duvall <danek.duvall@sun.com>
parents:
683
diff
changeset
|
962 |
else: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
963 |
res = "E" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
964 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
965 |
if self.output == OUTPUT_DOTS: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
966 |
self.stream.write(res) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
967 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
968 |
self.stream.writeln(res) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
969 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
970 |
if bresult == baseline.BASELINE_MISMATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
971 |
self.mismatches.append(test) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
972 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
973 |
# Check to see if we should archive this baseline mismatch. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
974 |
if bresult == baseline.BASELINE_MISMATCH and self.archive_dir: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
975 |
self.do_archive(test, self._exc_info_to_string(err, test)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
976 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
977 |
# Bail out completely if the 'bail on fail' flag is set |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
978 |
# but iff the result disagrees with the baseline. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
979 |
if self.bailonfail and bresult == baseline.BASELINE_MISMATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
980 |
self.dobailout(test) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
981 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
982 |
def format_output_and_exc(self, test, error): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
983 |
res = "" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
984 |
dbgbuf = test.get_debugbuf() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
985 |
if dbgbuf != "": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
986 |
res += dbgbuf |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
987 |
if error is not None: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
988 |
res += self._exc_info_to_string(error, test) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
989 |
return res |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
990 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
991 |
def addFailure(self, test, err): |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
992 |
unittest.TestResult.addFailure(self, test, err) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
993 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
994 |
bresult = self.baseline.handleresult(str(test), "fail") |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
995 |
expected = self.baseline.expectedresult(str(test)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
996 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
997 |
# If we're debugging, we'll have had output since we |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
998 |
# announced the name of the test, so restate it. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
999 |
if g_debug_output: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1000 |
self.statename(test) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1001 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1002 |
errinfo = self.format_output_and_exc(test, err) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1003 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1004 |
if self.output == OUTPUT_PARSEABLE: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1005 |
res = self.fmt_parseable(bresult, "FAIL", expected) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1006 |
res += "\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1007 |
if bresult == baseline.BASELINE_MISMATCH \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1008 |
or self.show_on_expected_fail: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1009 |
res += self.fmt_prefix_with(errinfo, "# ") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1010 |
elif self.output == OUTPUT_VERBOSE: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1011 |
if bresult == baseline.BASELINE_MISMATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1012 |
res = "MISMATCH FAIL (expected: %s)" % expected |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1013 |
else: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1014 |
res = "match FAIL (expected: FAIL)" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1015 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1016 |
if bresult == baseline.BASELINE_MISMATCH \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1017 |
or self.show_on_expected_fail: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1018 |
res += self.fmt_box(errinfo, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1019 |
"Failure Information", "# ") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1020 |
|
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1021 |
elif self.output == OUTPUT_DOTS: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1022 |
if bresult == baseline.BASELINE_MATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1023 |
res = "f" |
1002
56ab3be9a8b7
3488 Test suite should supress expected failures (or notate them more clearly)
Danek Duvall <danek.duvall@sun.com>
parents:
683
diff
changeset
|
1024 |
else: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1025 |
res = "F" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1026 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1027 |
if self.output == OUTPUT_DOTS: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1028 |
self.stream.write(res) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1029 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1030 |
self.stream.writeln(res) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1031 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1032 |
if bresult == baseline.BASELINE_MISMATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1033 |
self.mismatches.append(test) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1034 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1035 |
# Check to see if we should archive this baseline mismatch. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1036 |
if bresult == baseline.BASELINE_MISMATCH and self.archive_dir: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1037 |
self.do_archive(test, self._exc_info_to_string(err, test)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1038 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1039 |
# Bail out completely if the 'bail on fail' flag is set |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1040 |
# but iff the result disagrees with the baseline. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1041 |
if self.bailonfail and bresult == baseline.BASELINE_MISMATCH: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1042 |
self.dobailout(test) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1043 |
|
2306
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1044 |
def addSkip(self, test, err): |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1045 |
"""Python 2.7 adds formal support for skipped tests in unittest |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1046 |
For now, we'll record this as a success, but also save the |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1047 |
reason why we wanted to skip this test""" |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1048 |
self.addSuccess(test) |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1049 |
self.skips.append((test, err)) |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1050 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1051 |
def addPersistentSetupError(self, test, err): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1052 |
errtype, errval = err[:2] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1053 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1054 |
errinfo = self.format_output_and_exc(test, err) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1055 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1056 |
res = "# ERROR during persistent setup for %s\n" % test.id() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1057 |
res += "# As a result, all test cases in this class will " \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1058 |
"result in errors." |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1059 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1060 |
if errtype in ELIDABLE_ERRORS: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1061 |
res += "# " + str(errval) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1062 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1063 |
res += self.fmt_box(errinfo, \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1064 |
"Persistent Setup Error Information", "# ") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1065 |
self.stream.writeln(res) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1066 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1067 |
def addPersistentTeardownError(self, test, err): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1068 |
errtype, errval = err[:2] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1069 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1070 |
errinfo = self.format_output_and_exc(test, err) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1071 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1072 |
res = "# ERROR during persistent teardown for %s\n" % test.id() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1073 |
if errtype in ELIDABLE_ERRORS: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1074 |
res += "# " + str(errval) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1075 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1076 |
res += self.fmt_box(errinfo, \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1077 |
"Persistent Teardown Error Information", "# ") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1078 |
self.stream.writeln(res) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1079 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1080 |
def statename(self, test, prefix=""): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1081 |
name = self.getDescription(test) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1082 |
if self.output == OUTPUT_VERBOSE: |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
1083 |
name = name.ljust(65) + " " |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1084 |
elif self.output == OUTPUT_PARSEABLE: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1085 |
name += "|" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1086 |
elif self.output == OUTPUT_DOTS: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1087 |
return |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1088 |
self.stream.write(name) |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1089 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1090 |
def startTest(self, test): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1091 |
unittest.TestResult.startTest(self, test) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1092 |
test.debug("_" * 75) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1093 |
test.debug("Start: %s" % \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1094 |
self.getDescription(test)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1095 |
if test._testMethodDoc is not None: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1096 |
docs = [" " + x.strip() \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1097 |
for x in test._testMethodDoc.splitlines()] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1098 |
while len(docs) > 0 and docs[-1] == "": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1099 |
del docs[-1] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1100 |
for x in docs: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1101 |
test.debug(x) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1102 |
test.debug("_" * 75) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1103 |
test.debug("") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1104 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1105 |
if not g_debug_output: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1106 |
self.statename(test) |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1107 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1108 |
def printErrors(self): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1109 |
self.stream.writeln() |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1110 |
self.printErrorList('ERROR', self.errors) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1111 |
self.printErrorList('FAIL', self.failures) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1112 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1113 |
def printErrorList(self, flavour, errors): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1114 |
for test, err in errors: |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1115 |
self.stream.writeln(self.separator1) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1116 |
self.stream.writeln("%s: %s" % |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1117 |
(flavour, self.getDescription(test))) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1118 |
self.stream.writeln(self.separator2) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1119 |
self.stream.writeln("%s" % err) |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1120 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1121 |
class Pkg5TestRunner(unittest.TextTestRunner): |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1122 |
"""TestRunner for test suites that we want to be able to compare |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1123 |
against a result baseline.""" |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1124 |
baseline = None |
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1125 |
|
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1126 |
def __init__(self, baseline, stream=sys.stderr, output=OUTPUT_DOTS, |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1127 |
timing_file=None, bailonfail=False, coverage=None, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1128 |
show_on_expected_fail=False, archive_dir=None): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1129 |
"""Set up the test runner""" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1130 |
# output is one of OUTPUT_DOTS, OUTPUT_VERBOSE, OUTPUT_PARSEABLE |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1131 |
super(Pkg5TestRunner, self).__init__(stream) |
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
1132 |
self.baseline = baseline |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1133 |
self.output = output |
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1134 |
self.timing_file = timing_file |
1421
d6733f41c267
3961 Test suite should have a flag that makes it stop after encountering a failure
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1101
diff
changeset
|
1135 |
self.bailonfail = bailonfail |
1513
3ece69a26155
5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents:
1505
diff
changeset
|
1136 |
self.coverage = coverage |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1137 |
self.show_on_expected_fail = show_on_expected_fail |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1138 |
self.archive_dir = archive_dir |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1139 |
|
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1140 |
def _makeResult(self): |
1421
d6733f41c267
3961 Test suite should have a flag that makes it stop after encountering a failure
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1101
diff
changeset
|
1141 |
return _Pkg5TestResult(self.stream, self.output, self.baseline, |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1142 |
bailonfail=self.bailonfail, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1143 |
show_on_expected_fail=self.show_on_expected_fail, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1144 |
archive_dir=self.archive_dir) |
430
3fb945d3bff3
2627 Test suite should have support for baselining
Brad Hall <bhall@eng.sun.com>
parents:
diff
changeset
|
1145 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1146 |
@staticmethod |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1147 |
def __write_timing_info(stream, suite_name, class_list, method_list): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1148 |
if not class_list and not method_list: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1149 |
return |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1150 |
tot = 0 |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1151 |
print >> stream, "Tests run for '%s' Suite, " \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1152 |
"broken down by class:\n" % suite_name |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1153 |
for secs, cname in class_list: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1154 |
print >> stream, "%6.2f %s.%s" % (secs, suite_name, cname) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1155 |
tot += secs |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1156 |
for secs, mcname, mname in method_list: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1157 |
if mcname != cname: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1158 |
continue |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1159 |
print >> stream, \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1160 |
" %6.2f %s" % (secs, mname) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1161 |
print >> stream |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1162 |
print >> stream, "%6.2f Total time\n" % tot |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1163 |
print >> stream, "=" * 60 |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1164 |
print >> stream, "\nTests run for '%s' Suite, " \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1165 |
"sorted by time taken:\n" % suite_name |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1166 |
for secs, cname, mname in method_list: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1167 |
print >> stream, "%6.2f %s %s" % (secs, cname, mname) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1168 |
print >> stream, "%6.2f Total time\n" % tot |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1169 |
print >> stream, "=" * 60 |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1170 |
print >> stream, "" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1171 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1172 |
def _do_timings(self, test): |
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1173 |
timing = {} |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1174 |
lst = [] |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1175 |
suite_name = None |
2306
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1176 |
if not getattr(test, "_tests", None): |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1177 |
return |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1178 |
|
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1179 |
for t in test._tests: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1180 |
for (sname, cname, mname), secs in t.timing.items(): |
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1181 |
lst.append((secs, cname, mname)) |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1182 |
if cname not in timing: |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1183 |
timing[cname] = 0 |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1184 |
timing[cname] += secs |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1185 |
suite_name = sname |
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1186 |
lst.sort() |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1187 |
clst = sorted((secs, cname) for cname, secs in timing.items()) |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1188 |
|
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1189 |
if self.timing_file: |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1190 |
try: |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1191 |
fh = open(self.timing_file, "ab+") |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1192 |
opened = True |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1193 |
except KeyboardInterrupt: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1194 |
raise TestStopException() |
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1195 |
except Exception: |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1196 |
fh = sys.stderr |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1197 |
opened = False |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1198 |
self.__write_timing_info(fh, suite_name, clst, lst) |
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1199 |
if opened: |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1200 |
fh.close() |
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1201 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1202 |
def run(self, test): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1203 |
"Run the given test case or test suite." |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1204 |
result = self._makeResult() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1205 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1206 |
startTime = time.time() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1207 |
result.coverage = self.coverage |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1208 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1209 |
test.run(result) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1210 |
finally: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1211 |
stopTime = time.time() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1212 |
timeTaken = stopTime - startTime |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1213 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1214 |
run = result.testsRun |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1215 |
if run > 0: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1216 |
if self.output != OUTPUT_VERBOSE: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1217 |
result.printErrors() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1218 |
self.stream.writeln("# " + result.separator2) |
2306
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1219 |
|
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1220 |
self.stream.writeln("\n# Ran %d test%s in %.3fs" |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1221 |
" - skipped %d tests." % |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1222 |
(run, run != 1 and "s" or "", timeTaken, |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1223 |
len(result.skips))) |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1224 |
|
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1225 |
if result.wasSkipped() and \ |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1226 |
self.output == OUTPUT_VERBOSE: |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1227 |
self.stream.writeln("Skipped tests:") |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1228 |
for test,reason in result.skips: |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1229 |
self.stream.writeln("%s: %s" % |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
1230 |
(test, reason)) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1231 |
self.stream.writeln() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1232 |
if not result.wasSuccessful(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1233 |
self.stream.write("FAILED (") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1234 |
success, failed, errored, mismatches = map(len, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1235 |
(result.success, result.failures, result.errors, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1236 |
result.mismatches)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1237 |
self.stream.write("successes=%d, " % success) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1238 |
self.stream.write("failures=%d, " % failed) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1239 |
self.stream.write("errors=%d, " % errored) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1240 |
self.stream.write("mismatches=%d" % mismatches) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1241 |
self.stream.writeln(")") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1242 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1243 |
self._do_timings(test) |
448
bcfa99ac18b0
2664 test suite baseline enhancements
Brad Hall <bhall@eng.sun.com>
parents:
436
diff
changeset
|
1244 |
return result |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1245 |
|
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1246 |
|
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1247 |
class Pkg5TestSuite(unittest.TestSuite): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1248 |
"""Test suite that extends unittest.TestSuite to handle persistent |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1249 |
tests. Persistent tests are ones that are able to only call their |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1250 |
setUp/tearDown functions once per class, instead of before and after |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1251 |
every test case. Aside from actually running the test it defers the |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1252 |
majority of its work to unittest.TestSuite. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1253 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1254 |
To make a test class into a persistent one, add this class |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1255 |
variable declaration: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1256 |
persistent_setup = True |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1257 |
""" |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1258 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1259 |
def __init__(self, tests=()): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1260 |
unittest.TestSuite.__init__(self, tests) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1261 |
self.timing = {} |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1262 |
self.__pid = os.getpid() |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1263 |
|
1890
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1264 |
# The site module deletes the function to change the |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1265 |
# default encoding so a forced reload of sys has to |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1266 |
# be done at least once. |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1267 |
reload(sys) |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1268 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1269 |
def cleanup_and_die(self, inst, info): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1270 |
print >> sys.stderr, \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1271 |
"\nCtrl-C: Attempting cleanup during %s" % info |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1272 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1273 |
if hasattr(inst, "killalldepots"): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1274 |
print >> sys.stderr, "Killing depots..." |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1275 |
inst.killalldepots() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1276 |
print >> sys.stderr, "Stopping tests..." |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1277 |
raise TestStopException() |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1278 |
|
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1279 |
def run(self, result): |
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1280 |
self.timing = {} |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1281 |
inst = None |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1282 |
tdf = None |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
1283 |
try: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1284 |
persistent_setup = getattr(self._tests[0], |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1285 |
"persistent_setup", False) |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
1286 |
except IndexError: |
1890
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1287 |
# No tests; that's ok. |
571
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
1288 |
return |
1a2452c33cb9
3476 Most cli test cases can't be run standalone anymore
Brad Hall <bhall@eng.sun.com>
parents:
516
diff
changeset
|
1289 |
|
1890
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1290 |
# This is needed because the import of some modules (such as |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1291 |
# pygtk or pango) causes the default encoding for Python to be |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1292 |
# changed which can can cause tests to succeed when they should |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1293 |
# fail due to unicode issues: |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1294 |
# https://bugzilla.gnome.org/show_bug.cgi?id=132040 |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1295 |
default_utf8 = getattr(self._tests[0], "default_utf8", False) |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1296 |
if not default_utf8: |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1297 |
# Now reset to the default a standard Python |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1298 |
# distribution uses. |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1299 |
sys.setdefaultencoding("ascii") |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1300 |
else: |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1301 |
sys.setdefaultencoding("utf-8") |
011afb71c52a
15037 action parsing can't handle unicode objects which don't decode to ascii
Shawn Walker <shawn.walker@oracle.com>
parents:
1887
diff
changeset
|
1302 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1303 |
def setUp_donothing(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1304 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1305 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1306 |
def tearDown_donothing(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1307 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1308 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1309 |
def setUp_dofail(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1310 |
raise TestSkippedException( |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1311 |
"Persistent setUp Failed, skipping test.") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1312 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1313 |
# test case setUp() may require running pkg commands |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1314 |
# so setup a fakeroot to run them from. |
2364
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
1315 |
fakeroot_create() |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
1316 |
env_sanitize() |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1317 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1318 |
if persistent_setup: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1319 |
setUpFailed = False |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1320 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1321 |
# Save a reference to the tearDown func and neuter |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1322 |
# normal per-test-function teardown. |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1323 |
inst, tdf = self._tests[0].getTeardownFunc() |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1324 |
inst.reallytearDown = tdf |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1325 |
inst.tearDown = tearDown_donothing |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1326 |
|
1513
3ece69a26155
5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents:
1505
diff
changeset
|
1327 |
if result.coverage: |
3ece69a26155
5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents:
1505
diff
changeset
|
1328 |
inst.coverage_cmd, inst.coverage_env = result.coverage |
3ece69a26155
5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents:
1505
diff
changeset
|
1329 |
else: |
3ece69a26155
5032 make coverage should only report on the files in our gate
Danek Duvall <danek.duvall@sun.com>
parents:
1505
diff
changeset
|
1330 |
inst.coverage_cmd, inst.coverage_env = "", {} |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1331 |
|
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1332 |
try: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1333 |
inst.setUp() |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1334 |
except KeyboardInterrupt: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1335 |
self.cleanup_and_die(inst, "persistent setup") |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1336 |
except: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1337 |
result.addPersistentSetupError(inst, sys.exc_info()) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1338 |
setUpFailed = True |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1339 |
# XXX do cleanup? |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1340 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1341 |
# If the setUp function didn't work, then cause |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1342 |
# every test case to fail. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1343 |
if setUpFailed: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1344 |
inst.setUp = setUp_dofail |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1345 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1346 |
inst.setUp = setUp_donothing |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1347 |
|
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1348 |
for test in self._tests: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1349 |
if result.shouldStop: |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1350 |
break |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1351 |
real_test_name = test._testMethodName |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1352 |
suite_name = test._Pkg5TestCase__suite_name |
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1353 |
cname = test.__class__.__name__ |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1354 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1355 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1356 |
# Update test environment settings. We redo this |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1357 |
# before running each test case since previously |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1358 |
# executed test cases may have messed with these |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1359 |
# environment settings. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1360 |
# |
2364
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
1361 |
env_sanitize(dv_keep=["smf_cmds_dir"]) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1362 |
|
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1363 |
# Populate test with the data from the instance |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1364 |
# already constructed, but update the method name. |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1365 |
# We need to do this so that we have all the state |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1366 |
# that the object is populated with when setUp() is |
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1367 |
# called (depot controller list, etc). |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1368 |
if persistent_setup: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1369 |
name = test._testMethodName |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1370 |
doc = test._testMethodDoc |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1371 |
test = copy.copy(inst) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1372 |
test._testMethodName = name |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1373 |
test._testMethodDoc = doc |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1374 |
test.persistent_setup_copy(inst) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1375 |
|
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1376 |
test_start = time.time() |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1377 |
test(result) |
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1378 |
test_end = time.time() |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1379 |
self.timing[suite_name, cname, real_test_name] = \ |
1101
35f360e2ee19
5247 Test suite should provide timing info
Brock Pytlik <bpytlik@sun.com>
parents:
1002
diff
changeset
|
1380 |
test_end - test_start |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1381 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1382 |
if persistent_setup: |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1383 |
try: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1384 |
inst.reallytearDown() |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1385 |
except KeyboardInterrupt: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1386 |
self.cleanup_and_die(inst, "persistent teardown") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1387 |
except: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1388 |
result.addPersistentTeardownError(inst, sys.exc_info()) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1389 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1390 |
# Try to ensure that all depots have been nuked. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1391 |
if hasattr(inst, "killalldepots"): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1392 |
inst.killalldepots() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1393 |
|
2364
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
1394 |
fakeroot_destroy() |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1395 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1396 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1397 |
def get_su_wrap_user(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1398 |
for u in ["noaccess", "nobody"]: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1399 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1400 |
pwd.getpwnam(u) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1401 |
return u |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1402 |
except (KeyError, NameError): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1403 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1404 |
raise RuntimeError("Unable to determine user for su.") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1405 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1406 |
class DepotTracebackException(Pkg5CommonException): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1407 |
def __init__(self, logfile, output): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1408 |
Pkg5CommonException.__init__(self) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1409 |
self.__logfile = logfile |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1410 |
self.__output = output |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1411 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1412 |
def __str__(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1413 |
str = "During this test, a depot Traceback was detected.\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1414 |
str += "Log file: %s.\n" % self.__logfile |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1415 |
str += "Log file output is:\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1416 |
str += self.format_output(None, self.__output) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1417 |
return str |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1418 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1419 |
class TracebackException(Pkg5CommonException): |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1730
diff
changeset
|
1420 |
def __init__(self, command, output=None, comment=None, debug=None): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1421 |
Pkg5CommonException.__init__(self) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1422 |
self.__command = command |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1423 |
self.__output = output |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1424 |
self.__comment = comment |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1425 |
self.__debug = debug |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1426 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1427 |
def __str__(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1428 |
if self.__comment is None and self.__output is None: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1429 |
return (Exception.__str__(self)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1430 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1431 |
str = "" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1432 |
str += self.format_comment(self.__comment) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1433 |
str += self.format_output(self.__command, self.__output) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1434 |
if self.__debug is not None and self.__debug != "": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1435 |
str += self.format_debug(self.__debug) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1436 |
return str |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1437 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1438 |
class UnexpectedExitCodeException(Pkg5CommonException): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1439 |
def __init__(self, command, expected, got, output=None, comment=None): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1440 |
Pkg5CommonException.__init__(self) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1441 |
self.__command = command |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1442 |
self.__output = output |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1443 |
self.__expected = expected |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1444 |
self.__got = got |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1445 |
self.__comment = comment |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1446 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1447 |
def __str__(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1448 |
if self.__comment is None and self.__output is None: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1449 |
return (Exception.__str__(self)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1450 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1451 |
str = "" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1452 |
str += self.format_comment(self.__comment) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1453 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1454 |
str += " Invoked: %s\n" % self.__command |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1455 |
str += " Expected exit status: %s. Got: %d." % \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1456 |
(self.__expected, self.__got) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1457 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1458 |
str += self.format_output(self.__command, self.__output) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1459 |
return str |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1460 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1461 |
@property |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1462 |
def exitcode(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1463 |
return self.__got |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1464 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1465 |
class PkgSendOpenException(Pkg5CommonException): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1466 |
def __init__(self, com = ""): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1467 |
Pkg5CommonException.__init__(self, com) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1468 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1469 |
class CliTestCase(Pkg5TestCase): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1470 |
bail_on_fail = False |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1471 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1472 |
def setUp(self, image_count=1): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1473 |
Pkg5TestCase.setUp(self) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1474 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1475 |
self.__imgs_path = {} |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1476 |
self.__imgs_index = -1 |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1477 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1478 |
for i in range(0, image_count): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1479 |
path = os.path.join(self.test_root, "image%d" % i) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1480 |
self.__imgs_path[i] = path |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1481 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1482 |
self.set_image(0) |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
1483 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1484 |
def tearDown(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1485 |
Pkg5TestCase.tearDown(self) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1486 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1487 |
def persistent_setup_copy(self, orig): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1488 |
Pkg5TestCase.persistent_setup_copy(self, orig) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1489 |
self.__imgs_path = copy.copy(orig.__imgs_path) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1490 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1491 |
def set_image(self, ii): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1492 |
# ii is the image index |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1493 |
if self.__imgs_index == ii: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1494 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1495 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1496 |
self.__imgs_index = ii |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1497 |
path = self.__imgs_path[self.__imgs_index] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1498 |
assert path and path != "/" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1499 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1500 |
self.debug("image %d selected: %s" % (ii, path)) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1501 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1502 |
def set_img_path(self, path): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1503 |
self.__imgs_path[self.__imgs_index] = path |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1504 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1505 |
def img_index(self): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1506 |
return self.__imgs_index |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1507 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1508 |
def img_path(self, ii=None): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1509 |
if ii != None: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1510 |
return self.__imgs_path[ii] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1511 |
return self.__imgs_path[self.__imgs_index] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1512 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1513 |
def get_img_path(self): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1514 |
# for backward compatibilty |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1515 |
return self.img_path() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1516 |
|
2476
25342deb3749
3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents:
2475
diff
changeset
|
1517 |
def get_img_file_path(self, relpath): |
25342deb3749
3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents:
2475
diff
changeset
|
1518 |
"""Given a path relative to root, return the absolute path of |
25342deb3749
3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents:
2475
diff
changeset
|
1519 |
the item in the image.""" |
25342deb3749
3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents:
2475
diff
changeset
|
1520 |
|
25342deb3749
3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents:
2475
diff
changeset
|
1521 |
return os.path.join(self.img_path(), relpath) |
25342deb3749
3262 symlink loops can cause operation traceback
Shawn Walker <shawn.walker@oracle.com>
parents:
2475
diff
changeset
|
1522 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1523 |
def get_img_api_obj(self, cmd_path=None, ii=None): |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
1524 |
progresstracker = pkg.client.progress.NullProgressTracker() |
2092
0ef66bf272d3
16852 pkg should look at its image for certs if active image lacks certs
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2089
diff
changeset
|
1525 |
if not cmd_path: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1526 |
cmd_path = os.path.join(self.img_path(), "pkg") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1527 |
res = pkg.client.api.ImageInterface(self.img_path(ii=ii), |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
1528 |
CLIENT_API_VERSION, progresstracker, lambda x: False, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1529 |
PKG_CLIENT_NAME, cmdpath=cmd_path) |
2092
0ef66bf272d3
16852 pkg should look at its image for certs if active image lacks certs
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2089
diff
changeset
|
1530 |
return res |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
1531 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1532 |
def image_create(self, repourl=None, destroy=True, **kwargs): |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1533 |
"""A convenience wrapper for callers that only need basic image |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1534 |
creation functionality. This wrapper creates a full (as opposed |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1535 |
to user) image using the pkg.client.api and returns the related |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1536 |
API object.""" |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1537 |
|
2092
0ef66bf272d3
16852 pkg should look at its image for certs if active image lacks certs
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2089
diff
changeset
|
1538 |
if destroy: |
0ef66bf272d3
16852 pkg should look at its image for certs if active image lacks certs
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2089
diff
changeset
|
1539 |
self.image_destroy() |
2373
0569a9dc0072
18379 image-create should ignore .zfs snapdir
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2364
diff
changeset
|
1540 |
mkdir_eexist_ok(self.img_path()) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1541 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1542 |
self.debug("image_create %s" % self.img_path()) |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1543 |
progtrack = pkg.client.progress.NullProgressTracker() |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1544 |
api_inst = pkg.client.api.image_create(PKG_CLIENT_NAME, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1545 |
CLIENT_API_VERSION, self.img_path(), |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1546 |
pkg.client.api.IMG_TYPE_ENTIRE, False, repo_uri=repourl, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1547 |
progtrack=progtrack, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1548 |
**kwargs) |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1549 |
return api_inst |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1550 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1551 |
def pkg_image_create(self, repourl=None, prefix=None, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1552 |
additional_args="", exit=0): |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1553 |
"""Executes pkg(1) client to create a full (as opposed to user) |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1554 |
image; returns exit code of client or raises an exception if |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1555 |
exit code doesn't match 'exit' or equals 99..""" |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1556 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1557 |
if repourl and prefix is None: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1558 |
prefix = "test" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1559 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1560 |
self.image_destroy() |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1561 |
os.mkdir(self.img_path()) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1562 |
self.debug("pkg_image_create %s" % self.img_path()) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1563 |
cmdline = "%s image-create -F " % g_pkg_cmdpath |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1564 |
if repourl: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1565 |
cmdline = "%s -p %s=%s " % (cmdline, prefix, repourl) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1566 |
cmdline += additional_args |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1567 |
cmdline = "%s %s" % (cmdline, self.img_path()) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1568 |
self.debugcmd(cmdline) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1569 |
|
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1570 |
p = subprocess.Popen(cmdline, shell=True, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1571 |
stdout=subprocess.PIPE, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1572 |
stderr=subprocess.STDOUT) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1573 |
output = p.stdout.read() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1574 |
retcode = p.wait() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1575 |
self.debugresult(retcode, 0, output) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1576 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1577 |
if retcode == 99: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1578 |
raise TracebackException(cmdline, output) |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1839
diff
changeset
|
1579 |
if retcode != exit: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1580 |
raise UnexpectedExitCodeException(cmdline, 0, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1581 |
retcode, output) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1582 |
return retcode |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1583 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1584 |
def image_destroy(self): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1585 |
if os.path.exists(self.img_path()): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1586 |
self.debug("image_destroy %s" % self.img_path()) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1587 |
# Make sure we're not in the image. |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1588 |
os.chdir(self.test_root) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1589 |
shutil.rmtree(self.img_path()) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1590 |
|
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2046
diff
changeset
|
1591 |
def pkg(self, command, exit=0, comment="", prefix="", su_wrap=None, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1592 |
out=False, stderr=False, cmd_path=None, use_img_root=True, |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1593 |
debug_smf=True): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1594 |
if debug_smf and "smf_cmds_dir" not in command: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1595 |
command = "--debug smf_cmds_dir=%s %s" % \ |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1596 |
(DebugValues["smf_cmds_dir"], command) |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
1597 |
if use_img_root and "-R" not in command and \ |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
1598 |
"image-create" not in command and "version" not in command: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
1599 |
command = "-R %s %s" % (self.get_img_path(), command) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1600 |
if not cmd_path: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1601 |
cmd_path = g_pkg_cmdpath |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1602 |
cmdline = "%s %s" % (cmd_path, command) |
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1603 |
return self.cmdline_run(cmdline, exit=exit, comment=comment, |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2046
diff
changeset
|
1604 |
prefix=prefix, su_wrap=su_wrap, out=out, stderr=stderr) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1605 |
|
2381
45a20c3a277a
11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2373
diff
changeset
|
1606 |
def pkgdepend_resolve(self, args, exit=0, comment="", su_wrap=False): |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
1607 |
ops = "" |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
1608 |
if "-R" not in args: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
1609 |
ops = "-R %s" % self.get_img_path() |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
1610 |
cmdline = "%s/usr/bin/pkgdepend %s resolve %s" % ( |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
1611 |
g_proto_area, ops, args) |
2381
45a20c3a277a
11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2373
diff
changeset
|
1612 |
return self.cmdline_run(cmdline, comment=comment, exit=exit, |
45a20c3a277a
11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2373
diff
changeset
|
1613 |
su_wrap=su_wrap) |
45a20c3a277a
11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2373
diff
changeset
|
1614 |
|
45a20c3a277a
11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2373
diff
changeset
|
1615 |
def pkgdepend_generate(self, args, exit=0, comment="", su_wrap=False): |
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1616 |
cmdline = "%s/usr/bin/pkgdepend generate %s" % (g_proto_area, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1617 |
args) |
2381
45a20c3a277a
11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2373
diff
changeset
|
1618 |
return self.cmdline_run(cmdline, comment=comment, exit=exit, |
45a20c3a277a
11307 pkgdep can traceback for unprivileged user
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2373
diff
changeset
|
1619 |
su_wrap=su_wrap) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1620 |
|
2478
34959e45030b
18740 resolve's line echoing decisions need work
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2476
diff
changeset
|
1621 |
def pkgfmt(self, args, exit=0, su_wrap=False): |
34959e45030b
18740 resolve's line echoing decisions need work
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2476
diff
changeset
|
1622 |
cmd="%s/usr/bin/pkgfmt %s" % (g_proto_area, args) |
34959e45030b
18740 resolve's line echoing decisions need work
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2476
diff
changeset
|
1623 |
self.cmdline_run(cmd, exit=exit, su_wrap=su_wrap) |
34959e45030b
18740 resolve's line echoing decisions need work
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2476
diff
changeset
|
1624 |
|
2085
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
1625 |
def pkglint(self, args, exit=0, comment="", testrc=True): |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
1626 |
if testrc: |
10a27146ebc2
16802 pkglint should check the value of info.classification in manifests
Tim Foster <tim.s.foster@oracle.com>
parents:
2081
diff
changeset
|
1627 |
rcpath = "%s/pkglintrc" % self.test_root |
2081
f2189c4a03c4
16824 pkglint should remove its workaround for 16811
Tim Foster <tim.s.foster@oracle.com>
parents:
2073
diff
changeset
|
1628 |
cmdline = "%s/usr/bin/pkglint -f %s %s" % \ |
f2189c4a03c4
16824 pkglint should remove its workaround for 16811
Tim Foster <tim.s.foster@oracle.com>
parents:
2073
diff
changeset
|
1629 |
(g_proto_area, rcpath, args) |
f2189c4a03c4
16824 pkglint should remove its workaround for 16811
Tim Foster <tim.s.foster@oracle.com>
parents:
2073
diff
changeset
|
1630 |
else: |
f2189c4a03c4
16824 pkglint should remove its workaround for 16811
Tim Foster <tim.s.foster@oracle.com>
parents:
2073
diff
changeset
|
1631 |
cmdline = "%s/usr/bin/pkglint %s" % (g_proto_area, args) |
2046
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
1632 |
return self.cmdline_run(cmdline, exit=exit, out=True, |
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
1633 |
comment=comment, stderr=True) |
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
1634 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1635 |
def pkgrecv(self, server_url=None, command=None, exit=0, out=False, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1636 |
comment=""): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1637 |
args = [] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1638 |
if server_url: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1639 |
args.append("-s %s" % server_url) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1640 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1641 |
if command: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1642 |
args.append(command) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1643 |
|
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1644 |
cmdline = "%s/usr/bin/pkgrecv %s" % (g_proto_area, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1645 |
" ".join(args)) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1646 |
return self.cmdline_run(cmdline, comment=comment, exit=exit, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1647 |
out=out) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1648 |
|
2240
de59b73f1428
14965 merge should be productized
Shawn Walker <shawn.walker@oracle.com>
parents:
2223
diff
changeset
|
1649 |
def pkgmerge(self, args, comment="", exit=0, su_wrap=False): |
de59b73f1428
14965 merge should be productized
Shawn Walker <shawn.walker@oracle.com>
parents:
2223
diff
changeset
|
1650 |
cmdline = "%s/usr/bin/pkgmerge %s" % (g_proto_area, args) |
de59b73f1428
14965 merge should be productized
Shawn Walker <shawn.walker@oracle.com>
parents:
2223
diff
changeset
|
1651 |
return self.cmdline_run(cmdline, comment=comment, exit=exit, |
de59b73f1428
14965 merge should be productized
Shawn Walker <shawn.walker@oracle.com>
parents:
2223
diff
changeset
|
1652 |
su_wrap=su_wrap) |
de59b73f1428
14965 merge should be productized
Shawn Walker <shawn.walker@oracle.com>
parents:
2223
diff
changeset
|
1653 |
|
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1654 |
def pkgrepo(self, command, comment="", exit=0, su_wrap=False): |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1655 |
cmdline = "%s/usr/bin/pkgrepo %s" % (g_proto_area, command) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1656 |
return self.cmdline_run(cmdline, comment=comment, exit=exit, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1657 |
su_wrap=su_wrap) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1658 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1659 |
def pkgsign(self, depot_url, command, exit=0, comment=""): |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1660 |
args = [] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1661 |
if depot_url: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1662 |
args.append("-s %s" % depot_url) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1663 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1664 |
if command: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1665 |
args.append(command) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1666 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1667 |
cmdline = "%s/usr/bin/pkgsign %s" % (g_proto_area, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1668 |
" ".join(args)) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1669 |
return self.cmdline_run(cmdline, comment=comment, exit=exit) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1670 |
|
2456
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1671 |
def pkgsend(self, depot_url="", command="", exit=0, comment="", |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1672 |
allow_timestamp=False): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1673 |
args = [] |
2456
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1674 |
if allow_timestamp: |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1675 |
args.append("-D allow-timestamp") |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1676 |
if depot_url: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1677 |
args.append("-s " + depot_url) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1678 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1679 |
if command: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1680 |
args.append(command) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1681 |
|
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1682 |
prefix = "cd %s;" % self.test_root |
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2158
diff
changeset
|
1683 |
cmdline = "%s/usr/bin/pkgsend %s" % (g_proto_area, |
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1684 |
" ".join(args)) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1685 |
|
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1686 |
retcode, out = self.cmdline_run(cmdline, comment=comment, |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1687 |
exit=exit, out=True, prefix=prefix, raise_error=False) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1688 |
errout = self.errout |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1689 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1690 |
cmdop = command.split(' ')[0] |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1691 |
if cmdop in ("open", "append") and retcode == 0: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1692 |
out = out.rstrip() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1693 |
assert out.startswith("export PKG_TRANS_ID=") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1694 |
arr = out.split("=") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1695 |
assert arr |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1696 |
out = arr[1] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1697 |
os.environ["PKG_TRANS_ID"] = out |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1698 |
self.debug("$ export PKG_TRANS_ID=%s" % out) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1699 |
# retcode != 0 will be handled below |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1700 |
|
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1701 |
published = None |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1702 |
if (cmdop == "close" and retcode == 0) or cmdop == "publish": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1703 |
os.environ["PKG_TRANS_ID"] = "" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1704 |
self.debug("$ export PKG_TRANS_ID=") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1705 |
for l in out.splitlines(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1706 |
if l.startswith("pkg:/"): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1707 |
published = l |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1708 |
break |
1839
53bdcdd547cb
11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
1709 |
elif (cmdop == "generate" and retcode == 0): |
53bdcdd547cb
11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
1710 |
published = out |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1711 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1712 |
if retcode == 99: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1713 |
raise TracebackException(cmdline, out, comment) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1714 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1715 |
if retcode != exit: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1716 |
raise UnexpectedExitCodeException(cmdline, exit, |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1717 |
retcode, out + errout, comment) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1718 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1719 |
return retcode, published |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1720 |
|
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1721 |
def pkgsend_bulk(self, depot_url, commands, exit=0, comment="", |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1722 |
no_catalog=False, refresh_index=False): |
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1723 |
""" Send a series of packaging commands; useful for quickly |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1724 |
doing a bulk-load of stuff into the repo. All commands are |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1725 |
expected to work; if not, the transaction is abandoned. If |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1726 |
'exit' is set, then if none of the actions triggers that |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1727 |
exit code, an UnexpectedExitCodeException is raised. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1728 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1729 |
A list containing the fmris of any packages that were |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1730 |
published as a result of the commands executed will be |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1731 |
returned; it will be empty if none were. """ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1732 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
1733 |
if isinstance(commands, (list, tuple)): |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
1734 |
commands = "".join(commands) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
1735 |
|
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1736 |
extra_opts = [] |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1737 |
if no_catalog: |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1738 |
extra_opts.append("--no-catalog") |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1739 |
extra_opts = " ".join(extra_opts) |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
1740 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1741 |
plist = [] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1742 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1743 |
accumulate = [] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1744 |
current_fmri = None |
2046
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
1745 |
retcode = None |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1746 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1747 |
for line in commands.split("\n"): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1748 |
line = line.strip() |
1839
53bdcdd547cb
11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
1749 |
|
53bdcdd547cb
11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
1750 |
# pkgsend_bulk can't be used w/ import or |
53bdcdd547cb
11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
1751 |
# generate. |
53bdcdd547cb
11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
1752 |
assert not line.startswith("import"), \ |
53bdcdd547cb
11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
1753 |
"pkgsend_bulk cannot be used with import" |
53bdcdd547cb
11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
1754 |
assert not line.startswith("generate"), \ |
53bdcdd547cb
11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
1755 |
"pkgsend_bulk cannot be used with generate" |
53bdcdd547cb
11023 DirectoryBundle emits bad paths if basedir has trailing /
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
1756 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1757 |
if line == "": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1758 |
continue |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1759 |
if line.startswith("add"): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1760 |
self.assert_(current_fmri != None, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1761 |
"Missing open in pkgsend string") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1762 |
accumulate.append(line[4:]) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1763 |
continue |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1764 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1765 |
if current_fmri: # send any content seen so far (can be 0) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1766 |
fd, f_path = tempfile.mkstemp(dir=self.test_root) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1767 |
for l in accumulate: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1768 |
os.write(fd, "%s\n" % l) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1769 |
os.close(fd) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1770 |
try: |
2456
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1771 |
cmd = "publish %s -d %s %s" % ( |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1772 |
extra_opts, self.test_root, |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1773 |
f_path) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1774 |
current_fmri = None |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1775 |
accumulate = [] |
2456
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1776 |
# Various tests rely on the |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1777 |
# ability to specify version |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1778 |
# down to timestamp for ease |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1779 |
# of testing or because they're |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1780 |
# actually testing timestamp |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1781 |
# package behaviour. |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
1782 |
retcode, published = \ |
2456
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1783 |
self.pkgsend(depot_url, cmd, |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1784 |
allow_timestamp=True) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1785 |
if retcode == 0 and published: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1786 |
plist.append(published) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1787 |
except: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1788 |
os.remove(f_path) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1789 |
raise |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1790 |
os.remove(f_path) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1791 |
if line.startswith("open"): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1792 |
current_fmri = line[5:].strip() |
2456
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1793 |
if commands.find("pkg.fmri") == -1: |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1794 |
# If no explicit pkg.fmri set |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1795 |
# action was found, add one. |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1796 |
accumulate.append("set " |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1797 |
"name=pkg.fmri value=%s" % |
063737b8ee9b
9809 pkgsend publish should take bundle files as sources for files
Shawn Walker <shawn.walker@oracle.com>
parents:
2453
diff
changeset
|
1798 |
current_fmri) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1799 |
|
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1800 |
if exit == 0 and refresh_index: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1801 |
self.pkgrepo("-s %s refresh --no-catalog" % |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1802 |
depot_url) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1803 |
except UnexpectedExitCodeException, e: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1804 |
if e.exitcode != exit: |
502
3f98e94acc4a
2690 test suite depot starting/stopping
Brad Hall <bhall@eng.sun.com>
parents:
448
diff
changeset
|
1805 |
raise |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1806 |
retcode = e.exitcode |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1807 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1808 |
if retcode != exit: |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1809 |
raise UnexpectedExitCodeException(line, exit, retcode, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1810 |
self.output + self.errout) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1811 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1812 |
return plist |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1813 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1814 |
def merge(self, args=EmptyI, exit=0): |
2046
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
1815 |
pub_utils = os.path.join(g_proto_area, path_to_pub_util) |
2522cde7adc2
13536 We need a way to audit one or more packages
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
1816 |
prog = os.path.join(pub_utils, "merge.py") |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1817 |
cmd = "%s %s" % (prog, " ".join(args)) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1818 |
self.cmdline_run(cmd, exit=exit) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1819 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1820 |
def sysrepo(self, args, exit=0, out=False, stderr=False, comment="", |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1821 |
fill_missing_args=True): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1822 |
ops = "" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1823 |
if "-R" not in args: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1824 |
args += " -R %s" % self.get_img_path() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1825 |
if "-c" not in args: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1826 |
args += " -c %s" % os.path.join(self.test_root, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1827 |
"sysrepo_cache") |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1828 |
if "-l" not in args: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1829 |
args += " -l %s" % os.path.join(self.test_root, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1830 |
"sysrepo_logs") |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1831 |
if "-p" not in args and fill_missing_args: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1832 |
args += " -p %s" % self.next_free_port |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1833 |
if "-r" not in args: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1834 |
args += " -r %s" % os.path.join(self.test_root, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1835 |
"sysrepo_runtime") |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1836 |
if "-t" not in args: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1837 |
args += " -t %s" % self.template_dir |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1838 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1839 |
cmdline = "%s/usr/lib/pkg.sysrepo %s" % ( |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1840 |
g_proto_area, args) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1841 |
e = {"PKG5_TEST_ENV": "1"} |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1842 |
return self.cmdline_run(cmdline, comment=comment, exit=exit, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1843 |
out=out, stderr=stderr, env_arg=e) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
1844 |
|
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1845 |
def copy_repository(self, src, dest, pub_map): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1846 |
"""Copies the packages from the src repository to a new |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1847 |
destination repository that will be created at dest. In |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1848 |
addition, any packages from the src_pub will be assigned |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1849 |
to the dest_pub during the copy. The new repository will |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1850 |
not have a catalog or search indices, so a depot server |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1851 |
pointed at the new repository must be started with the |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1852 |
--rebuild option. |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1853 |
""" |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1854 |
|
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
1855 |
# Preserve destination repository's configuration if it exists. |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1856 |
dest_cfg = os.path.join(dest, "pkg5.repository") |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1730
diff
changeset
|
1857 |
dest_cfg_data = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1730
diff
changeset
|
1858 |
if os.path.exists(dest_cfg): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1730
diff
changeset
|
1859 |
with open(dest_cfg, "rb") as f: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1730
diff
changeset
|
1860 |
dest_cfg_data = f.read() |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1861 |
shutil.rmtree(dest, True) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1862 |
os.makedirs(dest, mode=0755) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1863 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1730
diff
changeset
|
1864 |
# Ensure config is written back out. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1730
diff
changeset
|
1865 |
if dest_cfg_data: |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
1866 |
with open(dest_cfg, "wb") as f: |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
1867 |
f.write(dest_cfg_data) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1730
diff
changeset
|
1868 |
|
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1869 |
def copy_manifests(src_root, dest_root): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1870 |
# Now copy each manifest and replace any references to |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1871 |
# the old publisher with that of the new publisher as |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1872 |
# they are copied. |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1873 |
src_pkg_root = os.path.join(src_root, "pkg") |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1874 |
dest_pkg_root = os.path.join(dest_root, "pkg") |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1875 |
for stem in os.listdir(src_pkg_root): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1876 |
src_pkg_path = os.path.join(src_pkg_root, stem) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1877 |
dest_pkg_path = os.path.join(dest_pkg_root, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1878 |
stem) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1879 |
for mname in os.listdir(src_pkg_path): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1880 |
# Ensure destination manifest directory |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1881 |
# exists. |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1882 |
if not os.path.isdir(dest_pkg_path): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1883 |
os.makedirs(dest_pkg_path, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1884 |
mode=0755) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1885 |
|
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1886 |
msrc = open(os.path.join(src_pkg_path, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1887 |
mname), "rb") |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1888 |
mdest = open(os.path.join(dest_pkg_path, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1889 |
mname), "wb") |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1890 |
for l in msrc: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1891 |
if l.find("pkg://") == -1: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1892 |
mdest.write(l) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1893 |
continue |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1894 |
nl = l |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1895 |
for src_pub in pub_map: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1896 |
nl = nl.replace( |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1897 |
src_pub, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1898 |
pub_map[src_pub]) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1899 |
mdest.write(nl) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1900 |
msrc.close() |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1901 |
mdest.close() |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1902 |
|
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1903 |
src_pub_root = os.path.join(src, "publisher") |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1904 |
if os.path.exists(src_pub_root): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1905 |
dest_pub_root = os.path.join(dest, "publisher") |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1906 |
for pub in os.listdir(src_pub_root): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1907 |
if pub not in pub_map: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1908 |
continue |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1909 |
src_root = os.path.join(src_pub_root, pub) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1910 |
dest_root = os.path.join(dest_pub_root, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1911 |
pub_map[pub]) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1912 |
for entry in os.listdir(src_root): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1913 |
# Skip the catalog, index, and pkg |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1914 |
# directories as they will be copied |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1915 |
# manually. |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1916 |
if entry not in ("catalog", "index", |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1917 |
"pkg", "tmp", "trans"): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1918 |
spath = os.path.join(src_root, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1919 |
entry) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1920 |
dpath = os.path.join(dest_root, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1921 |
entry) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1922 |
shutil.copytree(spath, dpath) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1923 |
continue |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1924 |
if entry != "pkg": |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1925 |
continue |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
1926 |
copy_manifests(src_root, dest_root) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
1927 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1928 |
def get_img_manifest_cache_dir(self, pfmri, ii=None): |
2475
77cfb483dd88
18486 package operations can fail during cache cleanup
Shawn Walker <shawn.walker@oracle.com>
parents:
2456
diff
changeset
|
1929 |
"""Returns the path to the manifest cache directory for the |
77cfb483dd88
18486 package operations can fail during cache cleanup
Shawn Walker <shawn.walker@oracle.com>
parents:
2456
diff
changeset
|
1930 |
given fmri.""" |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1931 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1932 |
img = self.get_img_api_obj(ii=ii).img |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1933 |
|
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1934 |
if not pfmri.publisher: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1935 |
# Allow callers to not specify a fully-qualified FMRI |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1936 |
# if it can be asssumed which publisher likely has |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1937 |
# the package. |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1938 |
pubs = [ |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1939 |
p.prefix |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1940 |
for p in img.gen_publishers(inc_disabled=True) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1941 |
] |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1942 |
assert len(pubs) == 1 |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1943 |
pfmri.publisher = pubs[0] |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1944 |
return img.get_manifest_dir(pfmri) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1945 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1946 |
def get_img_manifest_path(self, pfmri): |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2047
diff
changeset
|
1947 |
"""Returns the path to the manifest for the given fmri.""" |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1948 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1949 |
img = self.get_img_api_obj().img |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1950 |
|
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1951 |
if not pfmri.publisher: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1952 |
# Allow callers to not specify a fully-qualified FMRI |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1953 |
# if it can be asssumed which publisher likely has |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1954 |
# the package. |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1955 |
pubs = [ |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1956 |
p.prefix |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1957 |
for p in img.gen_publishers(inc_disabled=True) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1958 |
] |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1959 |
assert len(pubs) == 1 |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1960 |
pfmri.publisher = pubs[0] |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
1961 |
return img.get_manifest_path(pfmri) |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1962 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1963 |
def get_img_manifest(self, pfmri): |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1964 |
"""Retrieves the client's cached copy of the manifest for the |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1965 |
given package FMRI and returns it as a string. Callers are |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1966 |
responsible for all error handling.""" |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1967 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1968 |
mpath = self.get_img_manifest_path(pfmri) |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1969 |
with open(mpath, "rb") as f: |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1970 |
return f.read() |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1971 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1972 |
def write_img_manifest(self, pfmri, mdata): |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1973 |
"""Overwrites the client's cached copy of the manifest for the |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1974 |
given package FMRI using the provided string. Callers are |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1975 |
responsible for all error handling.""" |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1976 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1977 |
mpath = self.get_img_manifest_path(pfmri) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1978 |
mdir = self.get_img_manifest_cache_dir(pfmri) |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1979 |
|
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1980 |
# Dump the manifest directory for the package to ensure any |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1981 |
# cached information related to it is gone. |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1982 |
shutil.rmtree(mdir, True) |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1983 |
self.assert_(not os.path.exists(mdir)) |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1984 |
os.makedirs(mdir, mode=0755) |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1985 |
|
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1986 |
# Finally, write the new manifest. |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1987 |
with open(mpath, "wb") as f: |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1988 |
f.write(mdata) |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
1989 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1990 |
def validate_fsobj_attrs(self, act, target=None): |
1832
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
1991 |
"""Used to verify that the target item's mode, attrs, timestamp, |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
1992 |
etc. match as expected. The actual""" |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
1993 |
|
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
1994 |
if act.name not in ("file", "dir"): |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
1995 |
return |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
1996 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
1997 |
img_path = self.img_path() |
1832
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
1998 |
if not target: |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
1999 |
target = act.attrs["path"] |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2000 |
|
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2001 |
fpath = os.path.join(img_path, target) |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2002 |
lstat = os.lstat(fpath) |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2003 |
|
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2004 |
# Verify owner. |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2005 |
expected = portable.get_user_by_name(act.attrs["owner"], None, |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2006 |
False) |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2007 |
actual = lstat.st_uid |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2008 |
self.assertEqual(expected, actual) |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2009 |
|
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2010 |
# Verify group. |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2011 |
expected = portable.get_group_by_name(act.attrs["group"], None, |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2012 |
False) |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2013 |
actual = lstat.st_gid |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2014 |
self.assertEqual(expected, actual) |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2015 |
|
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2016 |
# Verify mode. |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2017 |
expected = int(act.attrs["mode"], 8) |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2018 |
actual = stat.S_IMODE(lstat.st_mode) |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2019 |
self.assertEqual(expected, actual) |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1795
diff
changeset
|
2020 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2021 |
def validate_html_file(self, fname, exit=0, comment="", |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2022 |
options="-quiet -utf8"): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2023 |
cmdline = "tidy %s %s" % (options, fname) |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
2024 |
return self.cmdline_run(cmdline, comment=comment, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
2025 |
coverage=False, exit=exit) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2026 |
|
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2027 |
def create_repo(self, repodir, properties=EmptyDict, version=None): |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2028 |
""" Convenience routine to help subclasses create a package |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2029 |
repository. Returns a pkg.server.repository.Repository |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2030 |
object. """ |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2031 |
|
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2032 |
# Note that this must be deferred until after PYTHONPATH |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2033 |
# is set up. |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2034 |
import pkg.server.repository as sr |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2035 |
try: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2036 |
repo = sr.repository_create(repodir, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2037 |
properties=properties, version=version) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2038 |
self.debug("created repository %s" % repodir) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2039 |
except sr.RepositoryExistsError: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2040 |
# Already exists. |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2041 |
repo = sr.Repository(root=repodir, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2042 |
properties=properties) |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2043 |
return repo |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2044 |
|
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
2045 |
def get_repo(self, repodir, read_only=False): |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
2046 |
""" Convenience routine to help subclasses retrieve a |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
2047 |
pkg.server.repository.Repository object for a given |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
2048 |
path. """ |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
2049 |
|
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
2050 |
# Note that this must be deferred until after PYTHONPATH |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
2051 |
# is set up. |
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
2052 |
import pkg.server.repository as sr |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2053 |
return sr.Repository(read_only=read_only, root=repodir) |
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1949
diff
changeset
|
2054 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2055 |
def prep_depot(self, port, repodir, logpath, refresh_index=False, |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2056 |
debug_features=EmptyI, properties=EmptyI, start=False): |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2057 |
""" Convenience routine to help subclasses prepare |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2058 |
depots. Returns a depotcontroller. """ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2059 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2060 |
# Note that this must be deferred until after PYTHONPATH |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2061 |
# is set up. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2062 |
import pkg.depotcontroller as depotcontroller |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2063 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2064 |
self.debug("prep_depot: set depot port %d" % port) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2065 |
self.debug("prep_depot: set depot repository %s" % repodir) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2066 |
self.debug("prep_depot: set depot log to %s" % logpath) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2067 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2068 |
dc = depotcontroller.DepotController( |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2069 |
wrapper_start=self.coverage_cmd.split(), |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2070 |
env=self.coverage_env) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2071 |
dc.set_depotd_path(g_proto_area + "/usr/lib/pkg.depotd") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2072 |
dc.set_depotd_content_root(g_proto_area + "/usr/share/lib/pkg") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2073 |
for f in debug_features: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2074 |
dc.set_debug_feature(f) |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2075 |
dc.set_repodir(repodir) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2076 |
dc.set_logpath(logpath) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2077 |
dc.set_port(port) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1730
diff
changeset
|
2078 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2079 |
for section in properties: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2080 |
for prop, val in properties[section].iteritems(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2081 |
dc.set_property(section, prop, val) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2082 |
if refresh_index: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2083 |
dc.set_refresh_index() |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2084 |
|
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2085 |
if start: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2086 |
# If the caller requested the depot be started, then let |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2087 |
# the depot process create the repository. |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2088 |
dc.start() |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2089 |
self.debug("depot on port %s started" % port) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2090 |
else: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2091 |
# Otherwise, create the repository with the assumption |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2092 |
# that the caller wants that at the least, but doesn't |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2093 |
# need the depot server (yet). |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2094 |
self.create_repo(repodir, properties=properties) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2095 |
return dc |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2096 |
|
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2097 |
def wait_repo(self, repodir, timeout=5.0): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2098 |
"""Wait for the specified repository to complete its current |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2099 |
operations before continuing.""" |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2100 |
|
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2101 |
check_interval = 0.20 |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2102 |
time.sleep(check_interval) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2103 |
|
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2104 |
begintime = time.time() |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2105 |
ready = False |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2106 |
while (time.time() - begintime) <= timeout: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2107 |
status = self.get_repo(repodir).get_status() |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2108 |
rdata = status.get("repository", {}) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2109 |
repo_status = rdata.get("status", "") |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2110 |
if repo_status == "online": |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2111 |
for pubdata in rdata.get("publishers", |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2112 |
{}).values(): |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2113 |
if pubdata.get("status", "") != "online": |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2114 |
ready = False |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2115 |
break |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2116 |
else: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2117 |
# All repository stores were ready. |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2118 |
ready = True |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2119 |
|
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2120 |
if not ready: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2121 |
time.sleep(check_interval) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2122 |
else: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2123 |
break |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2124 |
|
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2125 |
if not ready: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2126 |
raise RuntimeError("Repository readiness " |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2127 |
"timeout exceeded.") |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2128 |
|
2306
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
2129 |
def importer(self, args=EmptyI, out=False, stderr=False, exit=0): |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
2130 |
distro_import_utils = os.path.join(g_proto_area, |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
2131 |
path_to_distro_import_utils) |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
2132 |
prog = os.path.join(distro_import_utils, "importer.py") |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
2133 |
cmd = "%s %s" % (prog, " ".join(args)) |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
2134 |
return self.cmdline_run(cmd, out=out, stderr=stderr, exit=exit) |
dfc3f8634dcc
17158 importer.py could use some basic unit tests
Tim Foster <tim.s.foster@oracle.com>
parents:
2293
diff
changeset
|
2135 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2136 |
def _api_attach(self, api_obj, catch_wsie=True, **kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2137 |
self.debug("attach: %s" % str(kwargs)) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2138 |
for pd in api_obj.gen_plan_attach(**kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2139 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2140 |
self._api_finish(api_obj, catch_wsie=catch_wsie) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2141 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2142 |
def _api_detach(self, api_obj, catch_wsie=True, **kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2143 |
self.debug("detach: %s" % str(kwargs)) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2144 |
for pd in api_obj.gen_plan_detach(**kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2145 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2146 |
self._api_finish(api_obj, catch_wsie=catch_wsie) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2147 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2148 |
def _api_sync(self, api_obj, catch_wsie=True, **kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2149 |
self.debug("sync: %s" % str(kwargs)) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2150 |
for pd in api_obj.gen_plan_sync(**kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2151 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2152 |
self._api_finish(api_obj, catch_wsie=catch_wsie) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2153 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2154 |
def _api_install(self, api_obj, pkg_list, catch_wsie=True, **kwargs): |
1886
650a8de627ae
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents:
1859
diff
changeset
|
2155 |
self.debug("install %s" % " ".join(pkg_list)) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2156 |
for pd in api_obj.gen_plan_install(pkg_list, **kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2157 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2158 |
self._api_finish(api_obj, catch_wsie=catch_wsie) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2159 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2160 |
def _api_uninstall(self, api_obj, pkg_list, catch_wsie=True, **kwargs): |
1886
650a8de627ae
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents:
1859
diff
changeset
|
2161 |
self.debug("uninstall %s" % " ".join(pkg_list)) |
2382
b91a97e46434
18413 recursive uninstall functionality should be removed
Shawn Walker <shawn.walker@oracle.com>
parents:
2381
diff
changeset
|
2162 |
for pd in api_obj.gen_plan_uninstall(pkg_list, **kwargs): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2163 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2164 |
self._api_finish(api_obj, catch_wsie=catch_wsie) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2165 |
|
2401
e9061090d198
18416 pkg update <foo> child recursion should do a sync instead of an update
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2382
diff
changeset
|
2166 |
def _api_update(self, api_obj, catch_wsie=True, **kwargs): |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2085
diff
changeset
|
2167 |
self.debug("planning update") |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2168 |
for pd in api_obj.gen_plan_update(**kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2169 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2170 |
self._api_finish(api_obj, catch_wsie=catch_wsie) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2171 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2172 |
def _api_change_varcets(self, api_obj, catch_wsie=True, **kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2173 |
self.debug("change varcets: %s" % str(kwargs)) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2174 |
for pd in api_obj.gen_plan_change_varcets(**kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2175 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2176 |
self._api_finish(api_obj, catch_wsie=catch_wsie) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2177 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2178 |
def _api_finish(self, api_obj, catch_wsie=True): |
1886
650a8de627ae
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents:
1859
diff
changeset
|
2179 |
api_obj.prepare() |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2180 |
try: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2181 |
api_obj.execute_plan() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2182 |
except apx.WrapSuccessfulIndexingException: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2183 |
if not catch_wsie: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2184 |
raise |
1886
650a8de627ae
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents:
1859
diff
changeset
|
2185 |
api_obj.reset() |
650a8de627ae
15777 pkgdep resolve should provide an option to only resolve against the manifests provided
Brock Pytlik <bpytlik@sun.com>
parents:
1859
diff
changeset
|
2186 |
|
2274
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2187 |
def file_inode(self, path): |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2188 |
"""Return the inode number of a file in the image.""" |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2189 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2190 |
file_path = os.path.join(self.get_img_path(), path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2191 |
st = os.stat(file_path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2192 |
return st.st_ino |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2193 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2194 |
def file_size(self, path): |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2195 |
"""Return the size of a file in the image.""" |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2196 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2197 |
file_path = os.path.join(self.get_img_path(), path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2198 |
st = os.stat(file_path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2199 |
return st.st_size |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2200 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2201 |
def file_chmod(self, path, mode): |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2202 |
"""Change the mode of a file in the image.""" |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2203 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2204 |
file_path = os.path.join(self.get_img_path(), path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2205 |
os.chmod(file_path, mode) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2206 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2207 |
def file_exists(self, path): |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2208 |
"""Assert the existence of a file in the image.""" |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2209 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2210 |
file_path = os.path.join(self.get_img_path(), path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2211 |
if not os.path.isfile(file_path): |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2212 |
self.assert_(False, "File %s does not exist" % path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2213 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2214 |
def file_doesnt_exist(self, path): |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2215 |
"""Assert the non-existence of a file in the image.""" |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2216 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2217 |
file_path = os.path.join(self.get_img_path(), path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2218 |
if os.path.exists(file_path): |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2219 |
self.assert_(False, "File %s exists" % path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2220 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2221 |
def file_remove(self, path): |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2222 |
"""Remove a file in the image.""" |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2223 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2224 |
file_path = os.path.join(self.get_img_path(), path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2225 |
portable.remove(file_path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2226 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2227 |
def file_contains(self, path, string): |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2228 |
"""Assert the existence of a string in a file in the image.""" |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2229 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2230 |
file_path = os.path.join(self.get_img_path(), path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2231 |
try: |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2232 |
f = file(file_path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2233 |
except: |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2234 |
self.assert_(False, |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2235 |
"File %s does not exist or contain %s" % |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2236 |
(path, string)) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2237 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2238 |
for line in f: |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2239 |
if string in line: |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2240 |
f.close() |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2241 |
break |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2242 |
else: |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2243 |
f.close() |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2244 |
self.assert_(False, "File %s does not contain %s" % |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2245 |
(path, string)) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2246 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2247 |
def file_doesnt_contain(self, path, string): |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2248 |
"""Assert the non-existence of a string in a file in the |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2249 |
image.""" |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2250 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2251 |
file_path = os.path.join(self.get_img_path(), path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2252 |
f = file(file_path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2253 |
for line in f: |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2254 |
if string in line: |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2255 |
f.close() |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2256 |
self.assert_(False, "File %s contains %s" % |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2257 |
(path, string)) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2258 |
else: |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2259 |
f.close() |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2260 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2261 |
def file_append(self, path, string): |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2262 |
"""Append a line to a file in the image.""" |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2263 |
|
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2264 |
file_path = os.path.join(self.get_img_path(), path) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2265 |
with open(file_path, "a+") as f: |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2266 |
f.write("\n%s\n" % string) |
1c8cd2ff57d3
17958 when fixing duplicate action conflicts after uninstall, pkg should leave editable files alone
Danek Duvall <danek.duvall@oracle.com>
parents:
2272
diff
changeset
|
2267 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2268 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2269 |
class ManyDepotTestCase(CliTestCase): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2270 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2271 |
def __init__(self, methodName="runTest"): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2272 |
super(ManyDepotTestCase, self).__init__(methodName) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2273 |
self.dcs = {} |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2274 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2275 |
def setUp(self, publishers, debug_features=EmptyI, start_depots=False, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2276 |
image_count=1): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2277 |
CliTestCase.setUp(self, image_count=image_count) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2278 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2279 |
self.debug("setup: %s" % self.id()) |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2280 |
self.debug("creating %d repo(s)" % len(publishers)) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2281 |
self.debug("publishers: %s" % publishers) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2282 |
self.debug("debug_features: %s" % list(debug_features)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2283 |
self.dcs = {} |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2284 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2285 |
for n, pub in enumerate(publishers): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2286 |
i = n + 1 |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2287 |
testdir = os.path.join(self.test_root) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2288 |
|
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2289 |
try: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2290 |
os.makedirs(testdir, 0755) |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2291 |
except OSError, e: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2292 |
if e.errno != errno.EEXIST: |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2293 |
raise e |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2294 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2295 |
depot_logfile = os.path.join(testdir, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2296 |
"depot_logfile%d" % i) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2297 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2298 |
props = { "publisher": { "prefix": pub } } |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2299 |
|
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2300 |
# We pick an arbitrary base port. This could be more |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2301 |
# automated in the future. |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2302 |
repodir = os.path.join(testdir, "repo_contents%d" % i) |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2303 |
self.dcs[i] = self.prep_depot(self.next_free_port, |
2272
d81ea073d050
3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2240
diff
changeset
|
2304 |
repodir, |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2305 |
depot_logfile, debug_features=debug_features, |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2306 |
properties=props, start=start_depots) |
2272
d81ea073d050
3617 Testsuite should allow choice for base port to use
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2240
diff
changeset
|
2307 |
self.next_free_port += 1 |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2308 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2309 |
def check_traceback(self, logpath): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2310 |
""" Scan logpath looking for tracebacks. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2311 |
Raise a DepotTracebackException if one is seen. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2312 |
""" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2313 |
self.debug("check for depot tracebacks in %s" % logpath) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2314 |
logfile = open(logpath, "r") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2315 |
output = logfile.read() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2316 |
for line in output.splitlines(): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2317 |
if line.find("Traceback") > -1: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2318 |
raise DepotTracebackException(logpath, output) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2319 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2320 |
def restart_depots(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2321 |
self.debug("restarting %d depot(s)" % len(self.dcs)) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2322 |
for i in sorted(self.dcs.keys()): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2323 |
dc = self.dcs[i] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2324 |
self.debug("stopping depot at url: %s" % dc.get_depot_url()) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2325 |
dc.stop() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2326 |
self.debug("starting depot at url: %s" % dc.get_depot_url()) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2327 |
dc.start() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2328 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2329 |
def killall_sighandler(self, signum, frame): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2330 |
print >> sys.stderr, \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2331 |
"Ctrl-C: I'm killing depots, please wait.\n" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2332 |
print self |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2333 |
self.signalled = True |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2334 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2335 |
def killalldepots(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2336 |
self.signalled = False |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2337 |
self.debug("killalldepots: %s" % self.id()) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2338 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2339 |
oldhdlr = signal.signal(signal.SIGINT, self.killall_sighandler) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2340 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2341 |
try: |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2342 |
check_dc = [] |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2343 |
for i in sorted(self.dcs.keys()): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2344 |
dc = self.dcs[i] |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2345 |
if not dc.started: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2346 |
continue |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2347 |
check_dc.append(dc) |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2348 |
path = dc.get_repodir() |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2349 |
self.debug("stopping depot at url: %s, %s" % \ |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2350 |
(dc.get_depot_url(), path)) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2351 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2352 |
status = 0 |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2353 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2354 |
status = dc.kill() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2355 |
except Exception: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2356 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2357 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2358 |
if status: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2359 |
self.debug("depot: %s" % status) |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2360 |
|
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2361 |
for dc in check_dc: |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2362 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2363 |
self.check_traceback(dc.get_logpath()) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2364 |
except Exception: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2365 |
pass |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2366 |
finally: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2367 |
signal.signal(signal.SIGINT, oldhdlr) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2368 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2369 |
self.dcs = {} |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2370 |
if self.signalled: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2371 |
raise KeyboardInterrupt("Ctrl-C while killing depots.") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2372 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2373 |
def tearDown(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2374 |
self.debug("ManyDepotTestCase.tearDown: %s" % self.id()) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2375 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2376 |
self.killalldepots() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2377 |
CliTestCase.tearDown(self) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2378 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2379 |
def run(self, result=None): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2380 |
if result is None: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2381 |
result = self.defaultTestResult() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2382 |
CliTestCase.run(self, result) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2383 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2384 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2385 |
class SingleDepotTestCase(ManyDepotTestCase): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2386 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2387 |
def setUp(self, debug_features=EmptyI, publisher="test", |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2388 |
start_depot=False, image_count=1): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2389 |
ManyDepotTestCase.setUp(self, [publisher], |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2390 |
debug_features=debug_features, start_depots=start_depot, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2391 |
image_count=image_count) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2392 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2393 |
def __get_dc(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2394 |
if self.dcs: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2395 |
return self.dcs[1] |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2396 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2397 |
return None |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2398 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2399 |
@property |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2400 |
def durl(self): |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2401 |
return self.dc.get_depot_url() |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2402 |
|
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2403 |
@property |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2404 |
def rurl(self): |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2405 |
return self.dc.get_repo_url() |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2406 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2407 |
# dc is a readonly property which is an alias for self.dcs[1], |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2408 |
# for convenience of writing test cases. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2409 |
dc = property(fget=__get_dc) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2410 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2411 |
class SingleDepotTestCaseCorruptImage(SingleDepotTestCase): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2412 |
""" A class which allows manipulation of the image directory that |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2413 |
SingleDepotTestCase creates. Specifically, it supports removing one |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2414 |
or more of the files or subdirectories inside an image (publisher, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2415 |
cfg_cache, etc...) in a controlled way. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2416 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2417 |
To add a new directory or file to be corrupted, it will be necessary |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2418 |
to update corrupt_image_create to recognize a new option in config |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2419 |
and perform the appropriate action (removing the directory or file |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2420 |
for example). |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2421 |
""" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2422 |
|
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2423 |
def setUp(self, debug_features=EmptyI, publisher="test", |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2424 |
start_depot=False): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2425 |
SingleDepotTestCase.setUp(self, debug_features=debug_features, |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1890
diff
changeset
|
2426 |
publisher=publisher, start_depot=start_depot) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2427 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2428 |
self.__imgs_path_backup = {} |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2429 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2430 |
def tearDown(self): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2431 |
SingleDepotTestCase.tearDown(self) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2432 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2433 |
def backup_img_path(self, ii=None): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2434 |
if ii != None: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2435 |
return self.__imgs_path_backup[ii] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2436 |
return self.__imgs_path_backup[self.img_index()] |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2437 |
|
2092
0ef66bf272d3
16852 pkg should look at its image for certs if active image lacks certs
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2089
diff
changeset
|
2438 |
def corrupt_image_create(self, repourl, config, subdirs, prefix="test", |
2488
010931d9cabe
18688 pkg clients shouldn't attempt to find an image at startup
Shawn Walker <shawn.walker@oracle.com>
parents:
2478
diff
changeset
|
2439 |
destroy=True): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2440 |
""" Creates two levels of directories under the original image |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2441 |
directory. In the first level (called bad), it builds a "corrupt |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2442 |
image" which means it builds subdirectories the subdirectories |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
2443 |
specified by subdirs (essentially determining whether a user |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2444 |
image or a full image will be built). It populates these |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2445 |
subdirectories with a partial image directory stucture as |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
2446 |
specified by config. As another subdirectory of bad, it |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2447 |
creates a subdirectory called final which represents the |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2448 |
directory the command was actually run from (which is why |
2092
0ef66bf272d3
16852 pkg should look at its image for certs if active image lacks certs
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2089
diff
changeset
|
2449 |
img_path is set to that location). Existing image destruction |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2450 |
was made optional to allow testing of two images installed next |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2451 |
to each other (a user and full image created in the same |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2452 |
directory for example). """ |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2453 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2454 |
ii = self.img_index() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2455 |
if ii not in self.__imgs_path_backup: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2456 |
self.__imgs_path_backup[ii] = self.img_path() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2457 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2458 |
self.set_img_path(os.path.join(self.img_path(), "bad")) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2459 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2460 |
if destroy: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2461 |
self.image_destroy() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2462 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2463 |
for s in subdirs: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2464 |
if s == "var/pkg": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2465 |
cmdline = "pkg image-create -F -p %s=%s %s" % \ |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2466 |
(prefix, repourl, self.img_path()) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2467 |
elif s == ".org.opensolaris,pkg": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2468 |
cmdline = "pkg image-create -U -p %s=%s %s" % \ |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2469 |
(prefix, repourl, self.img_path()) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2470 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2471 |
raise RuntimeError("Got unknown subdir option:" |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2472 |
"%s\n" % s) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2473 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2474 |
self.debugcmd(cmdline) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2475 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2476 |
# Run the command to actually create a good image |
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2477 |
p = subprocess.Popen(cmdline, shell=True, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2478 |
stdout=subprocess.PIPE, |
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
2479 |
stderr=subprocess.STDOUT) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2480 |
output = p.stdout.read() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2481 |
retcode = p.wait() |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2482 |
self.debugresult(retcode, 0, output) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2483 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2484 |
if retcode == 99: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2485 |
raise TracebackException(cmdline, output) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2486 |
if retcode != 0: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2487 |
raise UnexpectedExitCodeException(cmdline, 0, |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2488 |
retcode, output) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2489 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2490 |
tmpDir = os.path.join(self.img_path(), s) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2491 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2492 |
# This is where the actual corruption of the |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2493 |
# image takes place. A normal image was created |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2494 |
# above and this goes in and removes critical |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2495 |
# directories and files. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2496 |
if "publisher_absent" in config or \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2497 |
"publisher_empty" in config: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2498 |
shutil.rmtree(os.path.join(tmpDir, "publisher")) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2499 |
if "known_absent" in config or \ |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2500 |
"known_empty" in config: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2501 |
shutil.rmtree(os.path.join(tmpDir, "state", |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2502 |
"known")) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2503 |
if "known_empty" in config: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2504 |
os.mkdir(os.path.join(tmpDir, "state", "known")) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2505 |
if "publisher_empty" in config: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2506 |
os.mkdir(os.path.join(tmpDir, "publisher")) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2507 |
if "cfg_cache_absent" in config: |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
2508 |
os.remove(os.path.join(tmpDir, "pkg5.image")) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2509 |
if "index_absent" in config: |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
2510 |
shutil.rmtree(os.path.join(tmpDir, "cache", |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2097
diff
changeset
|
2511 |
"index")) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2512 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2513 |
# Make find root start at final. (See the doc string for |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2514 |
# more explanation.) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2515 |
cmd_path = os.path.join(self.img_path(), "final") |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2516 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2517 |
os.mkdir(cmd_path) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2518 |
return cmd_path |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2519 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2520 |
def debug(s): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2521 |
s = str(s) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2522 |
for x in s.splitlines(): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2523 |
if g_debug_output: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2524 |
print >> sys.stderr, "# %s" % x |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2525 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2526 |
def mkdir_eexist_ok(p): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2527 |
try: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2528 |
os.mkdir(p) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2529 |
except OSError, e: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2530 |
if e.errno != errno.EEXIST: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2531 |
raise e |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2532 |
|
2364
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2533 |
def env_sanitize(dv_keep=None): |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2534 |
if dv_keep == None: |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2535 |
dv_keep = [] |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2536 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2537 |
dv_saved = {} |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2538 |
for dv in dv_keep: |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2539 |
# save some DebugValues settings |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2540 |
dv_saved[dv] = DebugValues[dv] |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2541 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2542 |
# clear any existing DebugValues settings |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2543 |
DebugValues.clear() |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2544 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2545 |
# clear misc environment variables |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2546 |
for e in ["PKG_CMDPATH"]: |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2547 |
if e in os.environ: |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2548 |
del os.environ[e] |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2549 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2550 |
# Set image path to a path that's not actually an |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2551 |
# image to force failure of tests that don't |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2552 |
# explicitly provide an image root either through the |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2553 |
# default behaviour of the pkg() helper routine or |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2554 |
# another method. |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2555 |
os.environ["PKG_IMAGE"] = g_tempdir |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2556 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2557 |
# Test suite should never attempt to access the |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2558 |
# live root image. |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2559 |
os.environ["PKG_NO_LIVE_ROOT"] = "1" |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2560 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2561 |
# Pkg interfaces should never know they are being |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2562 |
# run from within the test suite. |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2563 |
os.environ["PKG_NO_RUNPY_CMDPATH"] = "1" |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2564 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2565 |
# always print out recursive linked image commands |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2566 |
os.environ["PKG_DISP_LINKED_CMDS"] = "1" |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2567 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2568 |
# Pretend that we're being run from the fakeroot image. |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2569 |
if g_pkg_cmdpath != "TOXIC": |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2570 |
DebugValues["simulate_cmdpath"] = g_pkg_cmdpath |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2571 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2572 |
# Update the path to smf commands |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2573 |
for dv in dv_keep: |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2574 |
DebugValues[dv] = dv_saved[dv] |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2575 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2576 |
# always get detailed data from the solver |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2577 |
DebugValues["plan"] = True |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2578 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2579 |
def fakeroot_destroy(): |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2580 |
global g_fakeroot |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2581 |
global g_fakeroot_repo |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2582 |
global g_pkg_cmdpath |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2583 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2584 |
try: |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2585 |
os.stat(g_pkg_cmdpath) |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2586 |
except OSError, e: |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2587 |
# fakeroot already removed |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2588 |
return |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2589 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2590 |
test_root = os.path.join(g_tempdir, "ips.test.%d" % os.getpid()) |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2591 |
for d in os.listdir(test_root): |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2592 |
path = os.path.join(test_root, d) |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2593 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2594 |
# make sure there are no turds |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2595 |
assert (path in [g_fakeroot, g_fakeroot_repo]) |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2596 |
debug("removing: %s" % path) |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2597 |
if os.path.isdir(path): |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2598 |
shutil.rmtree(path) |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2599 |
else: |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2600 |
os.remove(path) |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2601 |
debug("removing: %s" % test_root) |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2602 |
shutil.rmtree(test_root) |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2603 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2604 |
g_fakeroot = "TOXIC" |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2605 |
g_fakeroot_repo = "TOXIC" |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2606 |
g_pkg_cmdpath = "TOXIC" |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2607 |
|
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2608 |
def fakeroot_create(): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2609 |
global g_fakeroot |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2610 |
global g_fakeroot_repo |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2611 |
global g_pkg_cmdpath |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2612 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2613 |
try: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2614 |
os.stat(g_pkg_cmdpath) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2615 |
except OSError, e: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2616 |
pass |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2617 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2618 |
# fakeroot already exists |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2619 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2620 |
|
2364
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2621 |
# when creating the fakeroot we want to make sure pkg doesn't |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2622 |
# touch the real root. |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2623 |
env_sanitize() |
7598ee41dcbc
18340 unquoted matching patterns cause spurious test case failures
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2339
diff
changeset
|
2624 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2625 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2626 |
# When accessing images via the pkg apis those apis will try |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2627 |
# to access the image containing the command from which the |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2628 |
# apis were invoked. Normally when running the test suite the |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2629 |
# command is run.py in a developers workspace, and that |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2630 |
# workspace lives in the root image. But accessing the root |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2631 |
# image during a test suite run is verboten. Hence, here we |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2632 |
# create a temporary image from which we can run the pkg |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2633 |
# command. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2634 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2635 |
test_root = os.path.join(g_tempdir, "ips.test.%d" % os.getpid()) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2636 |
fakeroot_repo = os.path.join(test_root, "fakeroot_repo") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2637 |
fakeroot = os.path.join(test_root, "fakeroot") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2638 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2639 |
# create directories |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2640 |
mkdir_eexist_ok(test_root) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2641 |
mkdir_eexist_ok(fakeroot_repo) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2642 |
mkdir_eexist_ok(fakeroot) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2643 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2644 |
debug("fakeroot repo create %s" % fakeroot_repo) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2645 |
repo = sr.repository_create(fakeroot_repo) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2646 |
repo.add_publisher(publisher.Publisher("bobcat")) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2647 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2648 |
debug("fakeroot image create %s" % fakeroot) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2649 |
cmd_path = os.path.join(fakeroot, "pkg") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2650 |
progtrack = pkg.client.progress.NullProgressTracker() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2651 |
api_inst = pkg.client.api.image_create(PKG_CLIENT_NAME, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2652 |
CLIENT_API_VERSION, fakeroot, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2653 |
pkg.client.api.IMG_TYPE_ENTIRE, False, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2654 |
repo_uri="file://" + fakeroot_repo, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2655 |
prefix="bobcat", progtrack=progtrack, cmdpath=cmd_path) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2656 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2657 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2658 |
# put a copy of the pkg command in our fake root directory. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2659 |
# we do this because when recursive linked image commands are |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2660 |
# run, the pkg interfaces may fork and exec additional copies |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2661 |
# of pkg(1), and in this case we want them to run the copy of |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2662 |
# pkg from the fake root. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2663 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2664 |
fakeroot_cmdpath = os.path.join(fakeroot, "pkg") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2665 |
shutil.copy(os.path.join(g_proto_area, "usr", "bin", "pkg"), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2666 |
fakeroot_cmdpath) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2667 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2668 |
g_fakeroot = fakeroot |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2669 |
g_fakeroot_repo = fakeroot_repo |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2670 |
g_pkg_cmdpath = fakeroot_cmdpath |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2671 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2319
diff
changeset
|
2672 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2673 |
def eval_assert_raises(ex_type, eval_ex_func, func, *args): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2674 |
try: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2675 |
func(*args) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2676 |
except ex_type, e: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2677 |
print str(e) |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2678 |
if not eval_ex_func(e): |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2679 |
raise |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2680 |
else: |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1516
diff
changeset
|
2681 |
raise RuntimeError("Function did not raise exception.") |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2682 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2683 |
class SysrepoStateException(Exception): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2684 |
pass |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2685 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2686 |
class ApacheController(object): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2687 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2688 |
def __init__(self, conf, port, work_dir, testcase=None, https=False): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2689 |
""" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2690 |
The 'conf' parameter is a path to a httpd.conf file. The 'port' |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2691 |
parameter is a port to run on. The 'work_dir' is a temporary |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2692 |
directory to store runtime state. The 'testcase' parameter is |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2693 |
the Pkg5TestCase to use when writing output. The 'https' |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2694 |
parameter is a boolean indicating whether this instance expects |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2695 |
to be contacted via https or not. |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2696 |
""" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2697 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2698 |
self.apachectl = "/usr/apache2/2.2/bin/httpd" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2699 |
if not os.path.exists(work_dir): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2700 |
os.makedirs(work_dir) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2701 |
self.__conf_path = os.path.join(work_dir, "sysrepo.conf") |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2702 |
self.__port = port |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2703 |
self.__repo_hdl = None |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2704 |
self.__starttime = 0 |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2705 |
self.__state = None |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2706 |
self.__tc = testcase |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2707 |
prefix = "http" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2708 |
if https: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2709 |
prefix = "https" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2710 |
self.__url = "%s://localhost:%d" % (prefix, self.__port) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2711 |
portable.copyfile(conf, self.__conf_path) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2712 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2713 |
def __set_conf(self, path): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2714 |
portable.copyfile(path, self.__conf_path) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2715 |
if self.__state == "started": |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2716 |
self.restart() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2717 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2718 |
def __get_conf(self): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2719 |
return self.__conf_path |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2720 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2721 |
conf = property(__get_conf, __set_conf) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2722 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2723 |
def _network_ping(self): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2724 |
try: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2725 |
urllib2.urlopen(self.__url) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2726 |
except urllib2.HTTPError, e: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2727 |
if e.code == httplib.FORBIDDEN: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2728 |
return True |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2729 |
return False |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2730 |
except urllib2.URLError, e: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2731 |
if isinstance(e.reason, ssl.SSLError): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2732 |
return True |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2733 |
return False |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2734 |
return True |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2735 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2736 |
def debug(self, msg): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2737 |
if self.__tc: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2738 |
self.__tc.debug(msg) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2739 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2740 |
def debugresult(self, result, expected, msg): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2741 |
if self.__tc: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2742 |
self.__tc.debugresult(result, expected, msg) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2743 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2744 |
def start(self): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2745 |
if self._network_ping(): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2746 |
raise SysrepoStateException("A depot (or some " + |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2747 |
"other network process) seems to be " + |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2748 |
"running on port %d already!" % self.__port) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2749 |
cmdline = ["/usr/bin/setpgrp", self.apachectl, "-f", |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2750 |
self.__conf_path, "-k", "start", "-DFOREGROUND"] |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2751 |
try: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2752 |
self.__starttime = time.time() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2753 |
self.debug(" ".join(cmdline)) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2754 |
self.__repo_hdl = subprocess.Popen(cmdline, shell=False, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2755 |
stdout=subprocess.PIPE, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2756 |
stderr=subprocess.PIPE) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2757 |
if self.__repo_hdl is None: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2758 |
raise SysrepoStateException("Could not start " |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2759 |
"sysrepo") |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2760 |
begintime = time.time() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2761 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2762 |
sleeptime = 0.0 |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2763 |
check_interval = 0.20 |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2764 |
contact = False |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2765 |
while (time.time() - begintime) <= 40.0: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2766 |
rc = self.__repo_hdl.poll() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2767 |
if rc is not None: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2768 |
raise SysrepoStateException("Sysrepo " |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2769 |
"exited unexpectedly while " |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2770 |
"starting (exit code %d)" % rc) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2771 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2772 |
if self.is_alive(): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2773 |
contact = True |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2774 |
break |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2775 |
time.sleep(check_interval) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2776 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2777 |
if contact == False: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2778 |
self.stop() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2779 |
raise SysrepoStateException("Sysrepo did not " |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2780 |
"respond to repeated attempts to make " |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2781 |
"contact") |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2782 |
self.__state = "started" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2783 |
except KeyboardInterrupt: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2784 |
if self.__repo_hdl: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2785 |
self.kill(now=True) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2786 |
raise |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2787 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2788 |
def kill(self, now=False): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2789 |
if not self.__repo_hdl: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2790 |
return |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2791 |
try: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2792 |
lifetime = time.time() - self.__starttime |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2793 |
if now == False and lifetime < 1.0: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2794 |
time.sleep(1.0 - lifetime) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2795 |
finally: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2796 |
try: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2797 |
os.kill(-1 * self.__repo_hdl.pid, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2798 |
signal.SIGKILL) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2799 |
except OSError: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2800 |
pass |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2801 |
self.__repo_hdl.wait() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2802 |
self.__state = "killed" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2803 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2804 |
def stop(self): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2805 |
if self.__state == "stopped": |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2806 |
return |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2807 |
cmdline = [self.apachectl, "-f", self.__conf_path, "-k", |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2808 |
"stop"] |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2809 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2810 |
try: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2811 |
hdl = subprocess.Popen(cmdline, shell=False, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2812 |
stdout=subprocess.PIPE, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2813 |
stderr=subprocess.PIPE) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2814 |
stop_output, stop_errout = hdl.communicate() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2815 |
stop_retcode = hdl.returncode |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2816 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2817 |
# retrieve output from the apache process we've just |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2818 |
# stopped |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2819 |
output, errout = self.__repo_hdl.communicate() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2820 |
self.debug(errout) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2821 |
self.debugresult(stop_retcode, 0, output) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2822 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2823 |
if stop_errout != "": |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2824 |
self.debug(stop_errout) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2825 |
if stop_output != "": |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2826 |
self.debug(stop_output) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2827 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2828 |
ret = hdl.wait() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2829 |
if ret != 0: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2830 |
self.kill(now=True) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2831 |
else: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2832 |
self.__state = "stopped" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2833 |
except KeyboardInterrupt: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2834 |
self.kill(now=True) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2835 |
raise |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2836 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2837 |
def restart(self): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2838 |
self.stop() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2839 |
self.start() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2840 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2841 |
def chld_sighandler(self, signum, frame): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2842 |
pass |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2843 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2844 |
def killall_sighandler(self, signum, frame): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2845 |
print >> sys.stderr, \ |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2846 |
"Ctrl-C: I'm killing depots, please wait.\n" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2847 |
print self |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2848 |
self.signalled = True |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2849 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2850 |
def is_alive(self): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2851 |
""" First, check that the depot process seems to be alive. |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2852 |
Then make a little HTTP request to see if the depot is |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2853 |
responsive to requests """ |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2854 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2855 |
if self.__repo_hdl == None: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2856 |
return False |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2857 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2858 |
status = self.__repo_hdl.poll() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2859 |
if status != None: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2860 |
return False |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2861 |
return self._network_ping() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2862 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2863 |
@property |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2864 |
def url(self): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2865 |
return self.__url |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2866 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2867 |
class SysrepoController(ApacheController): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2868 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2869 |
def __init__(self, conf, port, work_dir, testcase=None, https=False): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2870 |
ApacheController.__init__(self, conf, port, work_dir, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2871 |
testcase=None, https=False) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2872 |
self.apachectl = "/usr/apache2/2.2/bin/64/httpd" |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2873 |
|
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2874 |
def _network_ping(self): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2875 |
try: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2876 |
urllib2.urlopen(urlparse.urljoin(self.url, "syspub/0")) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2877 |
except urllib2.HTTPError, e: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2878 |
if e.code == httplib.FORBIDDEN: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2879 |
return True |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2880 |
return False |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2881 |
except urllib2.URLError: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2882 |
return False |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2306
diff
changeset
|
2883 |
return True |