hotspot/test/runtime/logging/ThreadLoggingTest.java
author stuefe
Mon, 29 Feb 2016 08:50:57 +0100
changeset 36379 0c596dc28ed7
child 36851 03e2f4d0a421
permissions -rw-r--r--
8150619: Improve thread based logging introduced with 8149036 Reviewed-by: coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36379
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
     1
/*
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
     3
 * Copyright (c) 2016, SAP SE and/or its affiliates. All rights reserved.
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
     5
 *
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
     8
 * published by the Free Software Foundation.
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
     9
 *
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    14
 * accompanied this code).
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    15
 *
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    19
 *
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    22
 * questions.
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    23
 */
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    24
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    25
/*
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    26
 * @test
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    27
 * @bug 8149036 8150619
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    28
 * @summary os+thread output should contain logging calls for thread start stop attaches detaches
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    29
 * @library /testlibrary
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    30
 * @modules java.base/sun.misc
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    31
 *          java.management
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    32
 * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    33
 * @run driver ThreadLoggingTest
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    34
 * @author Thomas Stuefe (SAP)
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    35
 */
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    36
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    37
import java.io.File;
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    38
import java.util.Map;
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    39
import jdk.test.lib.OutputAnalyzer;
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    40
import jdk.test.lib.ProcessTools;
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    41
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    42
public class ThreadLoggingTest {
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    43
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    44
    static void analyzeOutputForInfoLevel(OutputAnalyzer output) throws Exception {
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    45
        output.shouldContain("Thread started");
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    46
        output.shouldContain("Thread is alive");
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    47
        output.shouldContain("Thread finished");
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    48
        output.shouldHaveExitValue(0);
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    49
    }
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    50
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    51
    static void analyzeOutputForDebugLevel(OutputAnalyzer output) throws Exception {
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    52
        analyzeOutputForInfoLevel(output);
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    53
        output.shouldContain("stack dimensions");
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    54
        output.shouldContain("stack guard pages");
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    55
    }
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    56
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    57
    public static void main(String[] args) throws Exception {
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    58
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    59
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+thread", "-version");
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    60
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    61
        analyzeOutputForInfoLevel(output);
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    62
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    63
        pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+thread=debug", "-version");
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    64
        output = new OutputAnalyzer(pb.start());
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    65
        analyzeOutputForDebugLevel(output);
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    66
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    67
    }
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    68
0c596dc28ed7 8150619: Improve thread based logging introduced with 8149036
stuefe
parents:
diff changeset
    69
}