hotspot/test/gc/arguments/TestUnrecognizedVMOptionsHandling.java
author ccheung
Fri, 04 Oct 2013 21:00:43 -0700
changeset 20384 49bfb2ec8f8f
parent 18497 9ff60555fcd3
child 29678 dd2f3932c21e
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18497
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
     1
/*
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
     2
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
     3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
     4
*
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
     5
* This code is free software; you can redistribute it and/or modify it
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
     6
* under the terms of the GNU General Public License version 2 only, as
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
     7
* published by the Free Software Foundation.
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
     8
*
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
     9
* This code is distributed in the hope that it will be useful, but WITHOUT
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    11
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    12
* version 2 for more details (a copy is included in the LICENSE file that
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    13
* accompanied this code).
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    14
*
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    15
* You should have received a copy of the GNU General Public License version
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    16
* 2 along with this work; if not, write to the Free Software Foundation,
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    18
*
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    20
* or visit www.oracle.com if you need additional information or have any
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    21
* questions.
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    22
*/
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    23
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    24
/*
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    25
 * @test TestUnrecognizedVMOptionsHandling
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    26
 * @key gc
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    27
 * @bug 8017611
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    28
 * @summary Tests handling unrecognized VM options
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    29
 * @library /testlibrary
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    30
 * @run main/othervm TestUnrecognizedVMOptionsHandling
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    31
 */
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    32
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    33
import com.oracle.java.testlibrary.*;
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    34
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    35
public class TestUnrecognizedVMOptionsHandling {
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    36
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    37
  public static void main(String args[]) throws Exception {
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    38
    // The first two JAVA processes are expected to fail, but with a correct VM option suggestion
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    39
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    40
      "-XX:+PrintGc",
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    41
      "-version"
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    42
      );
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    43
    OutputAnalyzer outputWithError = new OutputAnalyzer(pb.start());
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    44
    outputWithError.shouldContain("Did you mean '(+/-)PrintGC'?");
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    45
    if (outputWithError.getExitValue() == 0) {
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    46
      throw new RuntimeException("Not expected to get exit value 0");
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    47
    }
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    48
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    49
    pb = ProcessTools.createJavaProcessBuilder(
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    50
      "-XX:MaxiumHeapSize=500m",
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    51
      "-version"
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    52
      );
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    53
    outputWithError = new OutputAnalyzer(pb.start());
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    54
    outputWithError.shouldContain("Did you mean 'MaxHeapSize=<value>'?");
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    55
    if (outputWithError.getExitValue() == 0) {
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    56
      throw new RuntimeException("Not expected to get exit value 0");
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    57
    }
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    58
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    59
    // The last JAVA process should run successfully for the purpose of sanity check
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    60
    pb = ProcessTools.createJavaProcessBuilder(
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    61
      "-XX:+PrintGC",
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    62
      "-version"
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    63
      );
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    64
    OutputAnalyzer outputWithNoError = new OutputAnalyzer(pb.start());
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    65
    outputWithNoError.shouldNotContain("Did you mean '(+/-)PrintGC'?");
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    66
    outputWithNoError.shouldHaveExitValue(0);
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    67
  }
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    68
}
9ff60555fcd3 8017611: Auto corrector for mistyped vm options
tamao
parents:
diff changeset
    69