1 21 22 package org.apache.derbyTesting.functionTests.harness; 23 24 import org.apache.derby.tools.sysinfo; 25 import java.io.File ; 26 import java.io.InputStream ; 27 import java.io.InputStreamReader ; 28 import java.io.BufferedReader ; 29 import java.io.FileReader ; 30 import java.io.FileInputStream ; 31 import java.io.FileOutputStream ; 32 import java.io.BufferedOutputStream ; 33 import java.io.BufferedWriter ; 34 import java.io.FileWriter ; 35 import java.io.PrintWriter ; 36 import java.io.IOException ; 37 import java.io.FileNotFoundException ; 38 import java.lang.ClassNotFoundException ; 39 import java.sql.Timestamp ; 40 import java.util.Enumeration ; 41 import java.util.Properties ; 42 import java.util.Vector ; 43 import java.util.StringTokenizer ; 44 45 public class RunSuite 46 { 47 48 static final boolean verbose=true; 49 50 static String suites; static Vector suitesToRun; 53 static String jvmName = ""; 55 static String javaCmd = "java"; 56 static String jvmflags = ""; static String javaVersion; 58 static String classpath; 59 static String classpathServer; 60 static String testJavaFlags = ""; static String testSpecialProps = ""; 62 static String userdir; 63 static String framework; 64 static String runwithibmjvm; 65 static String excludeJCC; 66 static boolean useprocess = true; 67 static boolean skipsed = false; 68 static String systemdiff = "false"; 69 static String topSuiteName = ""; 70 static String outputdir; static String outcopy = "false"; static String canondir; static String bootcp; static String serverJvm; static String hostName; static String testEncoding; static String ijdefaultResourcePackage; static String debug; static String timeout; static String shutdownurl; static String reportstderr; static Properties suiteProperties; 83 static Properties specialProperties; 84 85 static PrintWriter pwOut = null; static File outDir; static File runDir; static File outFile; 91 public static void main(String [] args) throws Exception 92 { 93 if ((System.getProperty("java.vm.name") != null) && System.getProperty("java.vm.name").equals("J9")) 94 { 95 javaCmd = "j9"; 96 String javaHome = System.getProperty("java.home"); 97 } 98 String j9config = System.getProperty("com.ibm.oti.configuration"); 99 if (j9config != null) 100 if (j9config.equals("foun10")) 101 jvmName="j9_foundation"; 102 else if (j9config.equals("max")) 103 jvmName="j9_13"; 104 105 String suiteName = args[0]; 106 if ( suiteName == null ) 107 { 108 System.out.println("No suite name argument."); 109 System.exit(1); 110 } 111 topSuiteName = suiteName; 112 System.out.println("Top suite: " + suiteName); 113 114 suitesToRun = new Vector (); 116 117 suiteProperties = getSuiteProperties(suiteName, true); 119 120 getSystemProperties(); 124 125 specialProperties = 129 SpecialFlags.getSpecialProperties(suiteProperties); 130 131 setOutput(suiteName); 133 134 String startTime = CurrentTime.getTime(); 136 137 pwOut.println("******* Start Suite: " + suiteName + 138 " " + startTime + " *******"); 139 140 if (useprocess) { 143 SysInfoLog sysLog= new SysInfoLog(); 144 sysLog.exec(jvmName, javaCmd, classpath, framework, pwOut, useprocess); 145 } 146 147 getSuitesList(suiteName, true); 148 149 String endTime = CurrentTime.getTime(); 151 pwOut.println("******* End Suite: " + suiteName + 152 " " + endTime + " *******"); 153 pwOut.close(); 154 155 String genrep = System.getProperty("genrep"); 156 boolean isGenrep = true; 157 if (genrep!=null) isGenrep = "true".equalsIgnoreCase(genrep); 158 if (isGenrep) 159 { 160 String [] genargs = new String [6]; 161 genargs[0] = args[0]; 162 genargs[1] = jvmName; 163 genargs[2] = javaCmd; 164 genargs[3] = classpath; 165 genargs[4] = framework; 166 if (useprocess) 167 genargs[5] = "true"; 168 else 169 genargs[5] = "false"; 170 GenerateReport.main(genargs); 171 } 172 } 173 174 static void getSuitesList(String topparent, boolean isTop) 175 throws Exception , ClassNotFoundException , IOException 176 { 177 Properties p; 179 if ( (suites == null) || (suites.length()==0) ) 180 { 181 if (verbose) System.out.println("Suite to run: " + topparent+":"+topparent); 183 suitesToRun.addElement(topparent+":"+topparent); 184 if (verbose) System.out.println("Now do RunList"); 186 RunList rl = new RunList(suitesToRun, runDir, outDir, pwOut, 188 suiteProperties, specialProperties, topparent); 189 suitesToRun.removeAllElements(); 190 } 191 else 192 { 193 isTop = false; 194 StringTokenizer st = new StringTokenizer (suites); 196 String subparent = ""; 197 while (st.hasMoreTokens()) 198 { 199 subparent = st.nextToken(); 200 p = getSuiteProperties(subparent, isTop); 201 if ( (p.getProperty("suites") == null) || (subparent.equals(topparent)) ) 202 { 203 suitesToRun.addElement(topparent+":"+subparent); 204 if (verbose) System.out.println("Now do RunList"); 207 RunList rl = new RunList(suitesToRun, runDir, outDir, pwOut, 209 suiteProperties, specialProperties, topparent); 210 suitesToRun.removeAllElements(); 211 } 212 else { 214 String sublist = p.getProperty("suites"); 215 BuildSuitesVector(subparent, sublist); 217 if (verbose) System.out.println("Now do RunList"); 219 RunList rl = new RunList(suitesToRun, runDir, outDir, pwOut, 221 suiteProperties, specialProperties, subparent); 222 suitesToRun.removeAllElements(); 223 } 224 } 225 } 226 } 227 228 static void BuildSuitesVector(String parent, String subsuites) 229 throws ClassNotFoundException , IOException 230 { 231 Properties p; 232 StringTokenizer st = new StringTokenizer (subsuites); 233 String child = ""; 234 while (st.hasMoreTokens()) 235 { 236 child = st.nextToken(); 237 if (child.equals(parent)) 238 { 239 suitesToRun.addElement(parent+":"+child); 240 } 242 else 243 { 244 p = getSuiteProperties(child, false); 245 if ( p.getProperty("suites") == null ) 246 { 247 suitesToRun.addElement(parent+":"+child); 248 } 250 else 251 { 252 String moresuites = p.getProperty("suites"); 253 BuildSuitesVector(child, moresuites); 254 } 255 } 256 } 257 } 258 259 260 static Properties getSuiteProperties(String suiteName, boolean isTop) 261 throws ClassNotFoundException , IOException 262 { 263 String suiteProps = "suites" + '/' + suiteName + ".properties"; 266 userdir = System.getProperty("user.dir"); 267 268 InputStream is = RunTest.loadTestResource(suiteProps); 269 if (is == null) 270 { 271 suiteProps = userdir + '/' + suiteName + ".properties"; 273 is = RunTest.loadTestResource(suiteProps); 274 } 275 Properties p = new Properties (); 276 if (is == null) 277 return p; 278 279 p.load(is); 280 if (isTop == true) 283 { 284 String tmpjvmName=jvmName; 285 jvmName = p.getProperty("jvm"); 286 if ( (jvmName == null) || (jvmName.length()==0) ) 287 { 288 javaVersion = System.getProperty("java.version"); 289 } 290 else 291 javaVersion = jvmName; 292 293 String javavmVersion; 295 if (System.getProperty("java.vm.name").equals("J9")) 296 javavmVersion = (System.getProperty("java.vm.version")); 297 else 298 javavmVersion = javaVersion; 299 300 JavaVersionHolder jvh = new JavaVersionHolder(javavmVersion); 301 String majorVersion = jvh.getMajorVersion(); 302 String minorVersion = jvh.getMinorVersion(); 303 int iminor = jvh.getMinorNumber(); 304 int imajor = jvh.getMajorNumber(); 305 306 if ( (iminor < 2) && (imajor < 2) ) 307 jvmName = "currentjvm"; 308 else 309 jvmName = "jdk" + majorVersion + minorVersion; 310 if ( tmpjvmName != null) 311 jvmName= tmpjvmName; 312 javaCmd = p.getProperty("javaCmd"); 313 jvmflags = p.getProperty("jvmflags"); 314 testJavaFlags = p.getProperty("testJavaFlags"); 315 testSpecialProps = p.getProperty("testSpecialProps"); 316 classpath = p.getProperty("classpath"); 317 classpathServer = p.getProperty("classpathServer"); 318 framework = p.getProperty("framework"); 319 String usepr = p.getProperty("useprocess"); 320 if (usepr != null) 321 { 322 usepr = usepr.toLowerCase(); 323 if (usepr.equals("false")) 324 useprocess = false; 325 else 326 useprocess = true; 327 } 328 else 329 useprocess = true; 330 331 String nosed = p.getProperty("skipsed"); 332 if (nosed != null) 333 { 334 nosed = nosed.toLowerCase(); 335 if (nosed.equals("true")) 336 skipsed = true; 337 else 338 skipsed = false; 339 } 340 else 341 skipsed = false; 342 343 outputdir = p.getProperty("outputdir"); 344 canondir = p.getProperty("canondir"); 345 bootcp = p.getProperty("bootcp"); 346 hostName = p.getProperty("hostName"); 347 serverJvm = p.getProperty("serverJvm"); 348 systemdiff = p.getProperty("systemdiff"); 349 ijdefaultResourcePackage = p.getProperty("ij.defaultResourcePackage"); 350 outcopy = p.getProperty("outcopy"); 351 debug = p.getProperty("verbose"); 352 reportstderr = p.getProperty("reportstderr"); 353 timeout = p.getProperty("timeout"); 354 shutdownurl = p.getProperty("shutdownurl"); 355 testEncoding = p.getProperty("derbyTesting.encoding"); 356 } 357 suites = p.getProperty("suites"); 358 return p; 359 } 360 361 private static void getSystemProperties() 362 { 363 Properties sp = System.getProperties(); 366 String searchCP = sp.getProperty("ij.searchClassPath"); 367 if (searchCP != null) 368 suiteProperties.put("ij.searchClassPath", searchCP); 369 String frm = sp.getProperty("framework"); 370 if ( (frm != null) && (!frm.equals("embedded")) ) 371 { 372 framework = frm; 373 suiteProperties.put("framework", framework); 374 } 375 String j = sp.getProperty("jvm"); 376 if (j != null) 377 suiteProperties.put("jversion", j); 378 379 String jcmd = sp.getProperty("javaCmd"); 380 if ((System.getProperty("java.vm.name") != null) && System.getProperty("java.vm.name").equals("J9")) 381 jcmd = "j9"; 382 if (jcmd != null) 383 { 384 javaCmd = jcmd; 385 suiteProperties.put("javaCmd", javaCmd); 386 } 387 String jflags = sp.getProperty("jvmflags"); 391 if (jvmflags != null) 392 { 393 if (jflags != null) 394 suiteProperties.put("jvmflags", (jvmflags + "^" + jflags)); 395 else 396 suiteProperties.put("jvmflags", jvmflags); 397 } 398 else 399 { 400 if (jflags != null) 401 suiteProperties.put("jvmflags", jflags); 402 } 403 String testflags = sp.getProperty("testJavaFlags"); 404 if (testflags != null) 405 { 406 if (testJavaFlags == null) 407 testJavaFlags = testflags; 408 else testJavaFlags = testJavaFlags + "^" + testflags; 410 suiteProperties.put("testJavaFlags", testJavaFlags); 411 } 412 String testprops = sp.getProperty("testSpecialProps"); 413 if (testprops != null) 414 { 415 if (testSpecialProps == null) 416 testSpecialProps = testprops; 417 else testSpecialProps = testSpecialProps + "^" + testprops; 419 suiteProperties.put("testSpecialProps", testSpecialProps); 420 } 421 String clpth = sp.getProperty("classpath"); 422 if (clpth != null) 423 { 424 classpath = clpth; 425 suiteProperties.put("classpath", classpath); 426 } 427 String clsrv = sp.getProperty("classpathServer"); 428 if ( (clsrv != null) && (!clsrv.startsWith("${")) ) 429 { 430 classpathServer = clsrv; 431 suiteProperties.put("classpathServer", clsrv); 432 } 433 String usesys = sp.getProperty("usesystem"); 434 if (usesys != null) 435 suiteProperties.put("usesystem", usesys); 436 String jarf = sp.getProperty("jarfile"); 437 if (jarf != null) 438 suiteProperties.put("jarfile", jarf); 439 String upgtest = sp.getProperty("upgradetest"); 440 if (upgtest != null) 441 suiteProperties.put("upgradetest", upgtest); 442 String rep = sp.getProperty("replication"); 443 if (rep != null) 444 suiteProperties.put("replication", rep); 445 String encrypt = sp.getProperty("encryption"); 446 if (encrypt != null) 447 suiteProperties.put("encryption", encrypt); 448 String encryptAlgorithm = sp.getProperty("testEncryptionAlgorithm"); 449 if (encryptAlgorithm != null) 450 suiteProperties.put("testEncryptionAlgorithm", encryptAlgorithm); 451 String jdk12test = sp.getProperty("jdk12test"); 452 if (jdk12test != null) 453 suiteProperties.put("jdk12test", jdk12test); 454 String jdk12ex = sp.getProperty("jdk12exttest"); 455 if (jdk12ex != null) 456 suiteProperties.put("jdk12exttest", jdk12ex); 457 String runwithibmjvm = sp.getProperty("runwithibmjvm"); 458 if (runwithibmjvm != null) 459 suiteProperties.put("runwithibmjvm", runwithibmjvm); 460 String excludeJCC = sp.getProperty("excludeJCC"); 461 if (excludeJCC != null) 462 suiteProperties.put("excludeJCC", excludeJCC); 463 String keep = sp.getProperty("keepfiles"); 464 if (keep != null) 465 suiteProperties.put("keepfiles", keep); 466 String outd = sp.getProperty("outputdir"); 467 if (outd != null) 468 { 469 outputdir = outd; 470 suiteProperties.put("outputdir", outputdir); 471 } 472 String canond = sp.getProperty("canondir"); 473 if (canond != null) 474 { 475 canondir = canond; 476 suiteProperties.put("canondir", canondir); 477 } 478 String j9bootcp = sp.getProperty("bootcp"); 479 if (j9bootcp != null) 480 { 481 bootcp = j9bootcp; 482 suiteProperties.put("bootcp", bootcp); 483 } 484 String hostname = sp.getProperty("hostName"); 485 if (hostname != null) 486 suiteProperties.put("hostName", hostname); 487 String serverJvm = sp.getProperty("serverJvm"); 488 if (serverJvm != null) 489 suiteProperties.put("serverJvm", serverJvm); 490 String cmlTestEncoding = sp.getProperty("derbyTesting.encoding"); 491 if (cmlTestEncoding != null) 492 suiteProperties.put("derbyTesting.encoding", cmlTestEncoding); 493 String upgradejarpath = sp.getProperty("derbyTesting.jar.path"); 494 if (upgradejarpath != null) 495 suiteProperties.put("derbyTesting.jar.path", upgradejarpath); 496 String testout = sp.getProperty("testoutname"); 497 if (testout != null) 498 suiteProperties.put("testoutname", testout); String mtdir = sp.getProperty("mtestdir"); if (mtdir != null) 501 suiteProperties.put("mtestdir", mtdir); 502 String usepr = sp.getProperty("useprocess"); 503 if (usepr != null) 504 { 505 usepr = usepr.toLowerCase(); 507 if (usepr.equals("false")) 508 { 509 useprocess = false; 510 suiteProperties.put("useprocess", usepr); 511 } 512 } 513 514 String nosed = sp.getProperty("skipsed"); 515 if (nosed != null) 516 { 517 nosed = nosed.toLowerCase(); 519 if (nosed.equals("true")) 520 { 521 skipsed = true; 522 suiteProperties.put("skipsed", nosed); 523 } 524 } 525 526 String sysdiff = sp.getProperty("systemdiff"); 527 if (sysdiff != null) 528 { 529 sysdiff = sysdiff.toLowerCase(); 531 if (sysdiff.equals("true")) 532 suiteProperties.put("systemdiff", "true"); 533 } 534 String defrespckg = sp.getProperty("ij.defaultResourcePackage"); 535 if (defrespckg != null) 536 suiteProperties.put("ij.defaultResourcePackage", defrespckg); 537 String outcpy = sp.getProperty("outcopy"); 538 if (outcpy != null) 539 suiteProperties.put("outcopy", outcpy); 540 String topsuite = sp.getProperty("suitename"); 541 if (topsuite != null) 542 suiteProperties.put("suitename", topsuite); 543 else 544 suiteProperties.put("suitename", topSuiteName); 545 String dbug = sp.getProperty("verbose"); 546 if (dbug != null) 547 suiteProperties.put("verbose", dbug); 548 String reporterr = sp.getProperty("reportstderr"); 549 if (reporterr != null) 550 suiteProperties.put("reportstderr", reporterr); 551 String tout = sp.getProperty("timeout"); 552 if (tout != null) 553 suiteProperties.put("timeout", tout); 554 } 555 556 private static void setOutput(String suiteName) 557 throws ClassNotFoundException , FileNotFoundException , IOException 558 { 559 boolean status = false; 560 File tmpoutDir; 562 if ( (outputdir == null) || (outputdir.length()==0) ) 563 { 564 tmpoutDir = 565 new File ((new File (userdir)).getCanonicalPath()); 566 } 567 else 568 { 569 tmpoutDir = 570 new File ((new File (outputdir)).getCanonicalPath()); 571 } 572 outDir = tmpoutDir; 573 outDir.mkdir(); 574 575 runDir = 578 new File ((new File (userdir)).getCanonicalPath()); 579 580 suiteProperties.put("outputdir", outDir.getCanonicalPath()); 582 583 outFile = new File (outDir, suiteName + ".sum"); 585 if (outFile.exists()) 586 status = outFile.delete(); 587 588 File passFile = new File (outDir, suiteName + ".pass"); 590 if (passFile.exists()) 591 status = passFile.delete(); 592 593 File failFile = new File (outDir, suiteName + ".fail"); 595 if (failFile.exists()) 596 status = failFile.delete(); 597 598 pwOut = new PrintWriter 600 (new BufferedWriter (new FileWriter (outFile.getPath()), 4096), true); 601 } 602 } 603 | Popular Tags |