author | David Powell <david.e.powell@oracle.com> |
Thu, 11 Aug 2011 15:41:42 -0700 | |
changeset 764 | ebb25c1dac73 |
parent 758 | 06c57694c78d |
child 793 | 0a5a7daf579b |
permissions | -rw-r--r-- |
667
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.6 |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
2 |
# |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
4 |
# |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
8 |
# |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
13 |
# |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
19 |
# |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
21 |
# |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
22 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
23 |
# |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
24 |
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
25 |
# |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
26 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
27 |
import radtest.fw as fw |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
28 |
import radtest.results as results |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
29 |
import radtest.main as main |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
30 |
import os |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
31 |
import os.path |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
32 |
import subprocess |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
33 |
import sys |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
34 |
|
754
d0a995fd0c9c
15126 debug setting not inherited by slave daemons
David Powell <david.e.powell@oracle.com>
parents:
667
diff
changeset
|
35 |
_VP_DIR = "usr/lib/rad/java" |
667
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
36 |
_JUNIT_JAR = "/usr/share/lib/java/junit.jar" |
758
06c57694c78d
18722 - Add tests for authentication and PAM conversation processing.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
754
diff
changeset
|
37 |
_SCF_JAR = "usr/share/vpanels/scf-common.jar" |
667
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
38 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
39 |
class JavaExecutor(fw.ExtTestFinder): |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
40 |
""" Finds tests matching a particular pattern and executes them """ |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
41 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
42 |
def __init__(self): |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
43 |
fw.ExtTestFinder.__init__(self, ".class") |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
44 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
45 |
def is_test(self, path, name): |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
46 |
return name.endswith("Test") |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
47 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
48 |
def make_classpath(self, root, dir): |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
49 |
vproot = os.path.join(root, _VP_DIR) |
754
d0a995fd0c9c
15126 debug setting not inherited by slave daemons
David Powell <david.e.powell@oracle.com>
parents:
667
diff
changeset
|
50 |
vpjars = [ "rad.jar", "adr.jar", "afunix.jar" ] |
758
06c57694c78d
18722 - Add tests for authentication and PAM conversation processing.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
754
diff
changeset
|
51 |
scfjar = os.path.join(root, _SCF_JAR) |
667
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
52 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
53 |
classpathents = map(lambda x: os.path.join(vproot, x), vpjars) |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
54 |
classpathents.append(_JUNIT_JAR) |
758
06c57694c78d
18722 - Add tests for authentication and PAM conversation processing.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
754
diff
changeset
|
55 |
classpathents.append(scfjar) |
667
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
56 |
classpathents.append(dir) |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
57 |
return ":".join(classpathents) |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
58 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
59 |
def run_common(self, dir, jargs, pargs): |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
60 |
root = os.getenv("ROOT") |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
61 |
classpath = self.make_classpath(root, dir) |
764
ebb25c1dac73
18812 Support building with alternate java implementations
David Powell <david.e.powell@oracle.com>
parents:
758
diff
changeset
|
62 |
javacmd = os.getenv("JAVA_HOME", "/usr") + "/bin/java" |
667
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
63 |
|
764
ebb25c1dac73
18812 Support building with alternate java implementations
David Powell <david.e.powell@oracle.com>
parents:
758
diff
changeset
|
64 |
args = [javacmd, "-classpath", classpath, "testutil.TestExec"] |
667
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
65 |
args.extend(jargs) |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
66 |
args.extend(self.findtests(dir)) |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
67 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
68 |
myenv = os.environ.copy() |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
69 |
proc = fw.with_proto_libs(myenv, root, |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
70 |
lambda: subprocess.Popen(args, env = myenv, **pargs)) |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
71 |
return proc |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
72 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
73 |
def run(self, result, resultsdir = None, dir = ""): |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
74 |
if resultsdir: |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
75 |
args = ["-r", resultsdir] |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
76 |
else: |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
77 |
args = [] |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
78 |
proc = self.run_common(dir, args, |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
79 |
{ "stdout" : subprocess.PIPE }) |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
80 |
results.parse_raw(proc.stdout, result, resultsdir) |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
81 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
82 |
def run_raw(self, dir = ""): |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
83 |
proc = self.run_common(dir, [ "-v" ], {}) |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
84 |
proc.wait() |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
85 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
86 |
if __name__ == "__main__": |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
87 |
# Without a results directory, python loses exception data |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
88 |
# main.main(JavaExecutor()) |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
89 |
|
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
90 |
if len(sys.argv) > 1: |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
91 |
dir = sys.argv[1] |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
92 |
else: |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
93 |
dir = "build" |
00b8c739a174
17940 need formal testing harness
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
94 |
JavaExecutor().run_raw(dir) |