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 /testlibrary
  32  * @build jdk.test.lib.*
  33  * @compile Test.java
  34  * @compile TestMT.java
  35  * @run driver Testexecstack
  36  */
  37 
  38 import jdk.test.lib.*;
  39 
  40 public class Testexecstack {
  41 
  42     public static void main(String[] args) throws Throwable {
  43 
  44         // Get the library path property
  45         String libpath = System.getProperty("java.library.path");
  46 
  47         // Create a new java process for the Test Java/JNI test without
  48         // an executeable stack
  49         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  50             "-Djava.library.path=" + libpath + ":.", "Test", "test-rw");
  51 
  52         // Start the process and check the output
  53         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  54         output.shouldHaveExitValue(0);
  55 
  56         // Create a new java process for the Test Java/JNI test with an
  57         // executable stack
  58         pb = ProcessTools.createJavaProcessBuilder(
  59             "-Djava.library.path=" + libpath + ":.", "Test", "test-rwx");
  60 
  61         // Start the process and check the output
  62         output = new OutputAnalyzer(pb.start());
  63         output.shouldHaveExitValue(0);
  64 
  65         // Create a new java process for the TestMT Java/JNI test with an
  66         // executable stack
  67         pb = ProcessTools.createJavaProcessBuilder(
  68             "-Djava.library.path=" + libpath + ":.", "TestMT", "test-rwx");
  69 
  70         // Start the process and check the output
  71         output = new OutputAnalyzer(pb.start());
  72         output.shouldHaveExitValue(0);
  73     }
  74 }