📄 runsuite.java
字号:
/* Derby - Class org.apache.derbyTesting.functionTests.harness.RunSuite Copyright 1999, 2004 The Apache Software Foundation or its licensors, as applicable. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */package org.apache.derbyTesting.functionTests.harness;import org.apache.derby.tools.sysinfo;import java.io.File;import java.io.InputStream;import java.io.InputStreamReader;import java.io.BufferedReader;import java.io.FileReader;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.BufferedOutputStream;import java.io.BufferedWriter;import java.io.FileWriter;import java.io.PrintWriter;import java.io.IOException;import java.io.FileNotFoundException;import java.lang.ClassNotFoundException;import java.sql.Timestamp;import java.util.Enumeration;import java.util.Properties;import java.util.Vector;import java.util.StringTokenizer;public class RunSuite{ static final boolean verbose=true; static String suites; // list of subsuites in this suite static Vector suitesToRun; // Vector of suites to run // Properties which may be specified static String jvmName = ""; static String javaCmd = "java"; static String jvmflags = ""; // jvm flags as one string static String javaVersion; static String classpath; static String classpathServer; static String testJavaFlags = ""; // formerly systest_javaflags static String userdir; static String framework; static String runwithibmjvm; static String excludeJCC; static boolean useprocess = true; static boolean skipsed = false; static String systemdiff = "false"; static String topSuiteName = ""; static String outputdir; // location of output (default is userdir) static String outcopy = "false"; // true if support files should go to outDir static String canondir; // location of master dir (default is master) static String bootcp; // path for j9 bootclasspath setting static String serverJvm; // path for j9 bootclasspath setting static String ijdefaultResourcePackage; // for ij tests only static String debug; // for setting verbose mode to pass down to RunTest static String timeout; // to allow killing a hanging test static String shutdownurl; //used mainly by useprocess=false tests static String reportstderr; // can set to disable (to turn off JIT errors, etc.) static Properties suiteProperties; static Properties specialProperties; // Output variables static PrintWriter pwOut = null; // for writing suite output static File outDir; // test out dir static File runDir; // where the suite/tests are run static File outFile; // suite output file public static void main(String[] args) throws Exception { if ((System.getProperty("java.vm.name") != null) && System.getProperty("java.vm.name").equals("J9")) { javaCmd = "j9"; String javaHome = System.getProperty("java.home"); //jvmflags = "-Xiss16k -Xss512k -Xmso16k -Xmx392388k"; } String j9config = System.getProperty("com.ibm.oti.configuration"); if (j9config != null) if (j9config.equals("foun10")) jvmName="j9_foundation"; else if (j9config.equals("max")) jvmName="j9_13"; String suiteName = args[0]; if ( suiteName == null ) { System.out.println("No suite name argument."); System.exit(1); } topSuiteName = suiteName; System.out.println("Top suite: " + suiteName); // suiteName may be one suite or a list of suites suitesToRun = new Vector(); // Get properties set in the suite's properties file suiteProperties = getSuiteProperties(suiteName, true); // There may be system properties which will override // the suiteProperties. This will make it easier when you // do not want to edit the suite props for a special case getSystemProperties(); // Get any special properties that are not the usual // expected properties (we separate these from suiteProperties // to avoid conflicts) specialProperties = SpecialFlags.getSpecialProperties(suiteProperties); // Setup the initial output setOutput(suiteName); // Get the current time to write a timestamp String startTime = CurrentTime.getTime(); pwOut.println("******* Start Suite: " + suiteName + " " + startTime + " *******"); // Write sysinfo to the output file if (useprocess) // doesn't work on Mac { SysInfoLog sysLog= new SysInfoLog(); sysLog.exec(jvmName, javaCmd, classpath, framework, pwOut, useprocess); } getSuitesList(suiteName, true); // Get the current time to write a timestamp String endTime = CurrentTime.getTime(); pwOut.println("******* End Suite: " + suiteName + " " + endTime + " *******"); pwOut.close(); String genrep = System.getProperty("genrep"); boolean isGenrep = true; if (genrep!=null) isGenrep = "true".equalsIgnoreCase(genrep); if (isGenrep) { String[] genargs = new String[6]; genargs[0] = args[0]; genargs[1] = jvmName; genargs[2] = javaCmd; genargs[3] = classpath; genargs[4] = framework; if (useprocess) genargs[5] = "true"; else genargs[5] = "false"; GenerateReport.main(genargs); } } static void getSuitesList(String topparent, boolean isTop) throws Exception, ClassNotFoundException, IOException { // Get the suite properties if it exists Properties p; if ( (suites == null) || (suites.length()==0) ) { // There is a single suite, not a list, just add it if (verbose) System.out.println("Suite to run: " + topparent+":"+topparent); suitesToRun.addElement(topparent+":"+topparent); // Use RunList class to issue the RunTest commands if (verbose) System.out.println("Now do RunList"); //System.out.println("skipsed: " + skipsed); RunList rl = new RunList(suitesToRun, runDir, outDir, pwOut, suiteProperties, specialProperties, topparent); suitesToRun.removeAllElements(); } else { isTop = false; // Build the Vector from suites string StringTokenizer st = new StringTokenizer(suites); String subparent = ""; while (st.hasMoreTokens()) { subparent = st.nextToken(); p = getSuiteProperties(subparent, isTop); if ( (p.getProperty("suites") == null) || (subparent.equals(topparent)) ) { suitesToRun.addElement(topparent+":"+subparent); //System.out.println("Add to suitesToRun: " + topparent+":"+subparent); // Use RunList class to issue the RunTest commands if (verbose) System.out.println("Now do RunList"); //System.out.println("skipsed: " + skipsed); RunList rl = new RunList(suitesToRun, runDir, outDir, pwOut, suiteProperties, specialProperties, topparent); suitesToRun.removeAllElements(); } else // This suite also has nested suites { String sublist = p.getProperty("suites"); //System.out.println("list for this SubSuite= " + sublist); BuildSuitesVector(subparent, sublist); // Use RunList class to issue the RunTest commands if (verbose) System.out.println("Now do RunList"); //System.out.println("skipsed: " + skipsed); RunList rl = new RunList(suitesToRun, runDir, outDir, pwOut, suiteProperties, specialProperties, subparent); suitesToRun.removeAllElements(); } } } } static void BuildSuitesVector(String parent, String subsuites) throws ClassNotFoundException, IOException { Properties p; StringTokenizer st = new StringTokenizer(subsuites); String child = ""; while (st.hasMoreTokens()) { child = st.nextToken(); if (child.equals(parent)) { suitesToRun.addElement(parent+":"+child); //System.out.println("Add this: " + parent+":"+child); } else { p = getSuiteProperties(child, false); if ( p.getProperty("suites") == null ) { suitesToRun.addElement(parent+":"+child); //System.out.println("Add this: " + parent+":"+child); } else { String moresuites = p.getProperty("suites"); BuildSuitesVector(child, moresuites); } } } } static Properties getSuiteProperties(String suiteName, boolean isTop) throws ClassNotFoundException, IOException { // Locate the suite's config file and get the properties // The file should be in the harness dir or user.dir String suiteProps = "suites" + '/' + suiteName + ".properties"; userdir = System.getProperty("user.dir"); InputStream is = RunTest.loadTestResource(suiteProps); if (is == null) { // Look in userdir suiteProps = userdir + '/' + suiteName + ".properties"; is = RunTest.loadTestResource(suiteProps); } Properties p = new Properties(); if (is == null) return p; p.load(is); // The top level suite may have special properties // which get propagated to any subsuites if (isTop == true) { String tmpjvmName=jvmName; jvmName = p.getProperty("jvm"); if ( (jvmName == null) || (jvmName.length()==0) )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -