1/*
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24/*
25 * @test Testexecstack.java
26 * @bug 7107135
27 * @bug 8021296
28 * @bug 8025519
29 * @summary Stack guard pages lost after loading library with executable stack.
30 * @requires (os.family == "linux")
31 * @library /test/lib
32 * @modules java.base/jdk.internal.misc
33 * @compile Test.java
34 * @compile TestMT.java
35 * @run driver Testexecstack
36 */
37
38import jdk.test.lib.process.OutputAnalyzer;
39import jdk.test.lib.process.ProcessTools;
40
41public class Testexecstack {
42
43    public static void main(String[] args) throws Throwable {
44
45        // Get the library path property
46        String libpath = System.getProperty("java.library.path");
47
48        // Create a new java process for the Test Java/JNI test without
49        // an executeable stack
50        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
51            "-Djava.library.path=" + libpath + ":.", "Test", "test-rw");
52
53        // Start the process and check the output
54        OutputAnalyzer output = new OutputAnalyzer(pb.start());
55        output.shouldHaveExitValue(0);
56
57        // Create a new java process for the Test Java/JNI test with an
58        // executable stack
59        pb = ProcessTools.createJavaProcessBuilder(
60            "-Djava.library.path=" + libpath + ":.", "Test", "test-rwx");
61
62        // Start the process and check the output
63        output = new OutputAnalyzer(pb.start());
64        output.shouldHaveExitValue(0);
65
66        // Create a new java process for the TestMT Java/JNI test with an
67        // executable stack
68        pb = ProcessTools.createJavaProcessBuilder(
69            "-Djava.library.path=" + libpath + ":.", "TestMT", "test-rwx");
70
71        // Start the process and check the output
72        output = new OutputAnalyzer(pb.start());
73        output.shouldHaveExitValue(0);
74    }
75}
76