⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runlist.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/*    Derby - Class org.apache.derbyTesting.functionTests.harness.RunList   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.FileWriter;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.PrintStream;import java.io.IOException;import java.io.FileNotFoundException;import java.lang.ClassNotFoundException;import java.lang.reflect.Method;import java.util.Enumeration;import java.util.Properties;import java.util.Vector;import java.util.StringTokenizer;public class RunList{	static String jvmName = "currentjvm";	static String javaCmd = "java";	static String javaArgs;	static jvm jvm;	static String javaVersion; // System.getProperty("java.version")	static String majorVersion;	static String minorVersion;	static String jversion; // to pass jvm to RunTest as -Djvm=1.2 etc.	static int iminor;	static int imajor;	static boolean skip = false;	static boolean driverNotFound = false;	static boolean needSync = false;	static boolean needJdk12 = false;	static boolean needJdk12ext = false;	static boolean excludedFromJCC = false;	static String clientExclusionMessage;	static Boolean needIBMjvm = null;	static boolean needJdk14 = false;        static boolean needEncryption = false;	static String jvmflags;	static String testJavaFlags;	static String classpath;	static String classpathServer;    static String framework;    static String usesystem;    static String upgradetest;    static String jarfile;    static String useoutput;	static String keepfiles = "false";	static String encryption;	static String testEncryptionProvider;	static String jdk12test;	static String jdk12exttest;	static String jdk14test;	static String runwithibmjvm = null;	static String runwithj9;	static String runwithjvm;	static String excludeJCC;	static boolean useprocess = true;	static String skipsed = "false";	static boolean fw_set = false;	static String systemdiff = "false";	static String suiteName = "";	static String fullsuiteName = "";	static String topSuiteName = ""; // The very top suite creating RunLists	static String topParentSuite = ""; // The "subparent" of the very top suite	static String topSpecialProps = ""; // special properties at the top suite	static String otherSpecialProps = ""; // special properties (individual suite)	static String ijdefaultResourcePackage; // for ij tests, the package resource	static String outcopy; // cases where copyfiles should go to outDir	static String userdir; // current user directory	static String mtestdir; // required by multi tests	static boolean verbose = false; // for debug output	static String reportstderr;	static String timeout;	static String shutdownurl;    static PrintWriter pwOut; // for writing suite output	static String outputdir; // location of output (default is userdir)	static String topsuitedir; // for nested suites, need top output location	static String topreportdir; // where to place the .pass and .fail files	static String canondir; // location of masters (default is master)	static String bootcp; // for j9 bootclasspath	static String serverJvm; // for starting another jvm for networkserver, j9 default.	static String serverJvmName; // for starting another jvm for networkserver, j9_22 default.    static File outDir; // test out dir    static File outFile; // suite output file    static File runDir; // location of suite.runall (list of tests)	static File runFile; // suite.runall file	static Properties suiteProperties;	static Properties specialProperties; // for testSpecialProps	static BufferedReader runlistFile;    static String [] clientExclusionKeywords = new String [] {        "at-or-before:", "at-or-after:", "when-at-or-before:jdk",        "when-at-or-after:jdk", "when:jdk"    };    public RunList()    {    }    /**    * RunList    * suitesToRun: a Vector of suites from RunSuite    * outDir: The output directory for the suite(s)    * pwOut: The output for writing suite and test results    * suiteProperties: From RunSuite for the top suite    * (individual suites in the vector may have their own    * properties which must also be located and applied)    */    public RunList(Vector suitesToRun,         File runDir, File outDir, PrintWriter pwOut,        Properties suiteProperties,         Properties specialProperties,         String topParentSuite)        throws ClassNotFoundException, IOException, Exception    {        this.runDir = runDir;        this.outDir = outDir;        this.pwOut = pwOut;        this.suiteProperties = suiteProperties; // usual suite props        this.specialProperties = specialProperties; // for special test Flags        this.topSuiteName = suiteProperties.getProperty("suitename");        //System.out.println("----------------------------------------");        //System.out.println("RunList topSuiteName= " + topSuiteName);        this.topParentSuite = topParentSuite;        //System.out.println("topParentSuite= " + topParentSuite);        // Run the suites        runSuites(suitesToRun);    }    private static void runSuites(Vector suitesToRun)        throws ClassNotFoundException,        FileNotFoundException, IOException, Exception    {        // For each suite, locate its properties and runall files        // which should be in the "suites" dir or user.dir        String suiteName = "";        userdir = System.getProperty("user.dir");        //System.out.println("Number of suites in list = " + suitesToRun.size());        Properties p = null;        // First get the top level suiteProperties since some        // special properties might need to be used by all sub-suites        setTopSuiteProperties();        // Now set the properties for the topParentSuite (a sub-parent of the top)        Properties topParentSuiteProps =             locateSuiteProperties(topParentSuite, suiteProperties, true, true);        setSuiteProperties(topParentSuiteProps, topParentSuite, suiteProperties, true, true);        // Now handle the list of child suites under this parent        for (int i = 0; i < suitesToRun.size(); i++)        {            /* Note: nesting of suites can be complex, especially if the             subsuites of the top suite also contain subsuites; we must take             care in setting of special properties like framework which may             need to propagate to its subsuites, but not back to the very top            */            Properties subProps = null;            fullsuiteName = (String)suitesToRun.elementAt(i);            //System.out.println("fullsuiteName: " + fullsuiteName);            String subSuite = fullsuiteName.substring(0,fullsuiteName.lastIndexOf(":"));            //System.out.println("subSuite: " + subSuite);            if ( !subSuite.equals(topParentSuite) )            {                subProps = locateSuiteProperties(subSuite, topParentSuiteProps, true, false);            }            else            {                // reset in case a previous subsuite had set framework, etc                subProps = topParentSuiteProps;            }            setSuiteProperties(subProps, subSuite, topParentSuiteProps, true, false);            // Now handle the child suite of this subSuite            suiteName = fullsuiteName.substring(fullsuiteName.lastIndexOf(":")+1);            //System.out.println("child suiteName: " + suiteName);            p = locateSuiteProperties(suiteName, subProps, false, false);            setSuiteProperties(p, suiteName, subProps, false, false);            // Now locate the suite runall file containing the tests            String runfile = "suites" + '/' + suiteName + ".runall";            InputStream is =  org.apache.derbyTesting.functionTests.harness.RunTest.loadTestResource(runfile);            if (is == null)            {                // Look in userdir                is = org.apache.derbyTesting.functionTests.harness.RunTest.loadTestResource(userdir + '/' + suiteName + ".runall");            }            if (is == null)            {                System.out.println("Suite runall file not found for " + suiteName);                continue;            }            // Create a BufferedReader to read the list of tests to run            runlistFile = new BufferedReader(new InputStreamReader(is, "UTF-8"));            if (runlistFile == null)            {                System.out.println("The suite runall file could not be read.");            }            else            {                String startTime = CurrentTime.getTime();                pwOut.println("**** Start SubSuite: " + fullsuiteName +                    " jdk" + javaVersion +                    " " + startTime + " ****");                if ( (framework != null) && (framework.length()>0) )                {                    pwOut.println("Framework: " + framework);                }                else                    pwOut.println("Framework: No special framework.");                // Create the file to list the suites that get skipped	            File f = new File(outDir, topSuiteName);	            File skipFile = new File(f, topSuiteName+".skip");		    //we catch an IOException here to work around a jvm bug on the Psion.		    PrintStream ps = null;		    try { ps = new PrintStream		            ( new FileOutputStream(skipFile.getCanonicalPath(),true) ); }		    catch (IOException e) {			FileWriter fw = new FileWriter(skipFile);			fw.close();			ps = new PrintStream			    ( new FileOutputStream(skipFile.getCanonicalPath(),true) );		    }                System.out.println("Now run the suite's tests");                //System.out.println("shutdownurl: " + shutdownurl);                if (skip) // Skip a suite under certain environments				{				    addToSkipFile(topSuiteName+":"+fullsuiteName, ps);					if(driverNotFound)                    	pwOut.println("Cannot run the suite, framework driver not found");					else if(needSync)                    	pwOut.println("Cannot run the suite, sync product not found");					else if(needJdk12ext)                    	pwOut.println("Cannot run the suite, requires jdk12 or higher with extensions");					else if(needJdk12)                    	pwOut.println("Cannot run the suite, requires jdk12 or higher, have jdk" + javaVersion);					else if(needJdk14)                    	pwOut.println("Cannot run the suite, requires jdk14 or higher, have jdk" + javaVersion);					else if(excludedFromJCC)                    	pwOut.println(clientExclusionMessage);					else if((needIBMjvm == null || needIBMjvm.booleanValue() == false))                    	pwOut.println("Cannot run the suite, requires IBM jvm, jvm vendor is " + System.getProperty("java.vendor"));					else                    	pwOut.println("Cannot run the suite, have jdk" + javaVersion);				 }                else                {                    System.out.println("Run the tests...");                    // Unjar any jarfile define for an upgrade suite                    //System.out.println("jarfile: " + jarfile);                    if (jarfile != null)                    {                        //System.out.println("unjar jar file...");                        UnJar uj = new UnJar();                        uj.unjar(jarfile, outDir.getCanonicalPath(), true);                        if ( (upgradetest.equals("true")) && (suiteName.startsWith("convert")) )                        {                            // need to rename the directory                            // such as kimono -- rename to convertKimono			    String tmpname = jarfile.substring(0, jarfile.indexOf("JAR"));                            File tmp = new File(outDir, tmpname);			    File convert = new File(outDir, usesystem);                            boolean renamed = tmp.renameTo(convert);                            //System.out.println("renamed: " + renamed);                        }                    }                    // Run the tests for this suite                    runTests(p, fullsuiteName);                }                String endTime = CurrentTime.getTime();                pwOut.println("**** End SubSuite: " + fullsuiteName +                    " jdk" + javaVersion +                    " " + endTime + " ****");                //System.out.println("--------------------------------------");                ps.close();            }        }    }    private static void runTests(Properties suiteProps, String suite)        throws IOException, Exception    {	    // save a copy of the system properties at this point; when runing with	    // java threads we need to reset the system properties to this list;	    // otherwise we start to accumulate extraneous properties from	    // individual tests (does not happen with exec (useprocess==true)	    // because each test case has its own fresh VM	    ManageSysProps.saveSysProps();        // Build command string for RunTest()        StringBuffer sb = new StringBuffer();	    jvm = jvm.getJvm(jvmName);	    Vector jvmProps = new Vector();	    if ((javaCmd.length()>0) )	    {	        jvm.setJavaCmd(javaCmd);	        jvmProps.addElement("javaCmd=" + javaCmd);	    }        if ( (testJavaFlags != null) && (testJavaFlags.length()>0) )            jvmProps.addElement("testJavaFlags=" + testJavaFlags);	    if (classpath != null)	        jvmProps.addElement("classpath=" + classpath);	    if (classpathServer != null)	        jvmProps.addElement("classpathServer=" + classpathServer);	    if (jversion != null)	        jvmProps.addElement("jvm=" + jversion);        if (framework != null)            jvmProps.addElement("framework=" + framework);        if (usesystem != null)            jvmProps.addElement("usesystem=" + usesystem);        if (shutdownurl != null)            jvmProps.addElement("shutdownurl=" + shutdownurl);        if (upgradetest != null)            jvmProps.addElement("upgradetest=" + upgradetest);               if (outcopy != null)            jvmProps.addElement("outcopy=" + outcopy);        if (useoutput != null)            jvmProps.addElement("useoutput=" + useoutput);        if (verbose == true)            jvmProps.addElement("verbose=true");        if ( (reportstderr != null) && (reportstderr.length()>0) )            jvmProps.addElement("reportstderr=" + reportstderr);        if ( (jvmflags != null) && (jvmflags.length()>0) )        {            // We want to pass this down to RunTest so it will            // run an individual test with jvmflags like -nojit            jvmProps.addElement("jvmflags=" + jvmflags);        }        if ( (timeout != null) && (timeout.length()>0) )        {            if (useprocess)			{                jvmProps.addElement("timeout=" + timeout);                        }            else            {                org.apache.derbyTesting.functionTests.harness.RunTest.timeoutStr = timeout;            }        }		if (Boolean.getBoolean("listOnly"))			jvmProps.addElement("listOnly=true");        if (encryption != null)            jvmProps.addElement("encryption=" + encryption);        if (testEncryptionProvider != null)            jvmProps.addElement("testEncryptionProvider=" + testEncryptionProvider);        if (jdk12test != null)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -