hotspot/test/runtime/CommandLine/ConfigFileParsing.java
author ctornqvi
Thu, 16 May 2013 15:31:00 +0200
changeset 17598 f78d22d3c6c2
parent 16457 hotspot/test/runtime/7158804/Test7158804.sh@92af83361777
child 29678 dd2f3932c21e
permissions -rw-r--r--
8008169: test/runtime/7158804/Test7158804.sh has bad copyright header Summary: Re-wrote test in Java in addition to fixing the Copyright notice. Also reviewed by leonid.mesnik@oracle.com Reviewed-by: coleenp, ctornqvi Contributed-by: Mikhailo Seledtsov <mikhailo.seledtsov@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17598
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
     1
/*
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
     4
 *
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
     7
 * published by the Free Software Foundation.
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
     8
 *
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    13
 * accompanied this code).
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    14
 *
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    18
 *
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    21
 * questions.
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    22
 */
14139
339b184759f9 7158804: Improve config file parsing
kamg
parents:
diff changeset
    23
17598
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    24
/*
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    25
 * @test ConfigFileParsing
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    26
 * @bug 7158804
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    27
 * @summary Improve config file parsing
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    28
 * @library /testlibrary
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    29
 */
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    30
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    31
import java.io.PrintWriter;
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    32
import com.oracle.java.testlibrary.*;
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    33
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    34
public class ConfigFileParsing {
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    35
  public static void main(String[] args) throws Exception {
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    36
    String testFileName = ".hotspotrc";
14139
339b184759f9 7158804: Improve config file parsing
kamg
parents:
diff changeset
    37
17598
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    38
    // Create really long invalid option
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    39
    String reallyLongInvalidOption = "";
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    40
    for (int i=0; i<5000; i++)
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    41
      reallyLongInvalidOption+='a';
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    42
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    43
    // Populate the options file with really long string
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    44
    PrintWriter pw = new PrintWriter(testFileName);
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    45
    pw.println("-XX:+" + reallyLongInvalidOption);
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    46
    pw.close();
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    47
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    48
    // start VM
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    49
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    50
        "-XX:+IgnoreUnrecognizedVMOptions", "-XX:Flags=.hotspotrc", "-version");
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    51
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    52
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    53
    output.shouldHaveExitValue(0);
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    54
  }
f78d22d3c6c2 8008169: test/runtime/7158804/Test7158804.sh has bad copyright header
ctornqvi
parents: 16457
diff changeset
    55
}