--- a/jdk/test/tools/launcher/Arrrghs.java Wed Jan 14 21:35:52 2015 +0300
+++ b/jdk/test/tools/launcher/Arrrghs.java Wed Jan 14 12:09:38 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,12 +30,10 @@
* @run main/othervm Arrrghs
*/
-import java.io.BufferedReader;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -48,9 +46,6 @@
private Arrrghs(){}
/**
* This class provides various tests for arguments processing.
- * A group of tests to ensure that arguments are passed correctly to
- * a child java process upon a re-exec, this typically happens when
- * a version other than the one being executed is requested by the user.
*
* History: these set of tests were part of Arrrghs.sh. The MKS shell
* implementations were notoriously buggy. Implementing these tests purely
@@ -58,12 +53,6 @@
*
*/
- // The version string to force a re-exec
- final static String VersionStr = "-version:1.1+";
-
- // The Cookie or the pattern we match in the debug output.
- final static String Cookie = "ReExec Args: ";
-
/*
* SIGH, On Windows all strings are quoted, we need to unwrap it
*/
@@ -78,122 +67,6 @@
return in;
}
- /*
- * This method detects the cookie in the output stream of the process.
- */
- private boolean detectCookie(InputStream istream,
- String expectedArguments) throws IOException {
- BufferedReader rd = new BufferedReader(new InputStreamReader(istream));
- boolean retval = false;
-
- String in = rd.readLine();
- while (in != null) {
- if (debug) System.out.println(in);
- if (in.startsWith(Cookie)) {
- String detectedArgument = removeExtraQuotes(in.substring(Cookie.length()));
- if (expectedArguments.equals(detectedArgument)) {
- retval = true;
- } else {
- System.out.println("Error: Expected Arguments\t:'" +
- expectedArguments + "'");
- System.out.println(" Detected Arguments\t:'" +
- detectedArgument + "'");
- }
- // Return the value asap if not in debug mode.
- if (!debug) {
- rd.close();
- istream.close();
- return retval;
- }
- }
- in = rd.readLine();
- }
- return retval;
- }
-
- private boolean doReExecTest0(ProcessBuilder pb, String expectedArguments) {
- boolean retval = false;
- try {
- pb.redirectErrorStream(true);
- Process p = pb.start();
- retval = detectCookie(p.getInputStream(), expectedArguments);
- p.waitFor();
- p.destroy();
- } catch (Exception ex) {
- ex.printStackTrace();
- throw new RuntimeException(ex.getMessage());
- }
- return retval;
- }
-
- /**
- * This method returns true if the expected and detected arguments are the same.
- * Quoting could cause dissimilar testArguments and expected arguments.
- */
- int doReExecTest(String testArguments, String expectedPattern) {
- ProcessBuilder pb = new ProcessBuilder(javaCmd,
- VersionStr, testArguments);
-
- Map<String, String> env = pb.environment();
- env.put(JLDEBUG_KEY, "true");
- return doReExecTest0(pb, testArguments) ? 0 : 1;
- }
-
- /**
- * A convenience method for identical test pattern and expected arguments
- */
- int doReExecTest(String testPattern) {
- return doReExecTest(testPattern, testPattern);
- }
-
- @Test
- void testQuoteParsingThroughReExec() {
- /*
- * Tests for 6214916
- * These tests require that a JVM (any JVM) be installed in the system registry.
- * If none is installed, skip this test.
- */
- TestResult tr = doExec(javaCmd, VersionStr, "-version");
- if (!tr.isOK()) {
- System.err.println("Warning:Argument Passing Tests were skipped, " +
- "no java found in system registry.");
- return;
- }
-
- // Basic test
- testExitValue += doReExecTest("-a -b -c -d");
-
- // Basic test with many spaces
- testExitValue += doReExecTest("-a -b -c -d");
-
- // Quoted whitespace does matter ?
- testExitValue += doReExecTest("-a \"\"-b -c\"\" -d");
-
-
- // Escaped quotes outside of quotes as literals
- testExitValue += doReExecTest("-a \\\"-b -c\\\" -d");
-
- // Check for escaped quotes inside of quotes as literal
- testExitValue += doReExecTest("-a \"-b \\\"stuff\\\"\" -c -d");
-
- // A quote preceeded by an odd number of slashes is a literal quote
- testExitValue += doReExecTest("-a -b\\\\\\\" -c -d");
-
- // A quote preceeded by an even number of slashes is a literal quote
- // see 6214916.
- testExitValue += doReExecTest("-a -b\\\\\\\\\" -c -d");
-
- // Make sure that whitespace doesn't interfere with the removal of the
- // appropriate tokens. (space-tab-space preceeds -jre-restict-search).
- testExitValue += doReExecTest("-a -b \t -jre-restrict-search -c -d", "-a -b -c -d");
-
- // Make sure that the mJRE tokens being stripped, aren't stripped if
- // they happen to appear as arguments to the main class.
- testExitValue += doReExecTest("foo -version:1.1+");
-
- System.out.println("Completed arguments quoting tests with "
- + testExitValue + " errors");
- }
// the pattern we hope to see in the output
static final Pattern ArgPattern = Pattern.compile("\\s*argv\\[[0-9]*\\].*=.*");