test/java/nio/Buffer/LimitDirectMemory.sh

Print this page




  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 # @test
  27 # @bug 4627316 6743526
  28 # @summary Test option to limit direct memory allocation
  29 #
  30 # @build LimitDirectMemory
  31 # @run shell LimitDirectMemory.sh
  32 
  33 TMP1=tmp_$$
  34 
  35 runTest() {
  36   echo "Testing: $*"
  37   ${TESTJAVA}/bin/java ${TESTVMOPTS} $*
  38   if [ $? -eq 0 ]
  39   then echo "--- passed as expected"
  40   else
  41     echo "--- failed"
  42     exit 1
  43   fi
  44 }
  45 
  46 
  47 launchFail() {
  48   echo "Testing: -XX:MaxDirectMemorySize=$* -cp ${TESTCLASSES} \
  49      LimitDirectMemory true DEFAULT DEFAULT+1M"
  50   ${TESTJAVA}/bin/java ${TESTVMOPTS} -XX:MaxDirectMemorySize=$* -cp ${TESTCLASSES} \
  51      LimitDirectMemory true DEFAULT DEFAULT+1M > ${TMP1} 2>&1
  52   cat ${TMP1}
  53   cat ${TMP1} | grep -s "Unrecognized VM option: \'MaxDirectMemorySize="
  54   if [ $? -ne 0 ]
  55     then echo "--- failed as expected"
  56   else
  57     echo "--- failed"
  58     exit 1
  59   fi
  60 }
  61 
  62 # $java LimitDirectMemory throwp fill_direct_memory size_per_buffer
  63 
  64 # Memory is properly limited using multiple buffers.
  65 runTest -XX:MaxDirectMemorySize=10 -cp ${TESTCLASSES} LimitDirectMemory true 10 1
  66 runTest -XX:MaxDirectMemorySize=1k -cp ${TESTCLASSES} LimitDirectMemory true 1k 100
  67 runTest -XX:MaxDirectMemorySize=10m -cp ${TESTCLASSES} LimitDirectMemory true 10m 10m
  68 
  69 # We can increase the amount of available memory.
  70 runTest -XX:MaxDirectMemorySize=65M -cp ${TESTCLASSES} \




  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 # @test
  27 # @bug 4627316 6743526
  28 # @summary Test option to limit direct memory allocation
  29 #
  30 # @build LimitDirectMemory
  31 # @run shell LimitDirectMemory.sh
  32 
  33 TMP1=tmp_$$
  34 
  35 runTest() {
  36   echo "Testing: $*"
  37   ${TESTJAVA}/bin/java ${TESTVMOPTS} ${TESTJAVAOPTS} $*
  38   if [ $? -eq 0 ]
  39   then echo "--- passed as expected"
  40   else
  41     echo "--- failed"
  42     exit 1
  43   fi
  44 }
  45 
  46 
  47 launchFail() {
  48   echo "Testing: -XX:MaxDirectMemorySize=$* -cp ${TESTCLASSES} \
  49      LimitDirectMemory true DEFAULT DEFAULT+1M"
  50   ${TESTJAVA}/bin/java ${TESTVMOPTS} ${TESTJAVAOPTS} -XX:MaxDirectMemorySize=$* -cp ${TESTCLASSES} \
  51      LimitDirectMemory true DEFAULT DEFAULT+1M > ${TMP1} 2>&1
  52   cat ${TMP1}
  53   cat ${TMP1} | grep -s "Unrecognized VM option: \'MaxDirectMemorySize="
  54   if [ $? -ne 0 ]
  55     then echo "--- failed as expected"
  56   else
  57     echo "--- failed"
  58     exit 1
  59   fi
  60 }
  61 
  62 # $java LimitDirectMemory throwp fill_direct_memory size_per_buffer
  63 
  64 # Memory is properly limited using multiple buffers.
  65 runTest -XX:MaxDirectMemorySize=10 -cp ${TESTCLASSES} LimitDirectMemory true 10 1
  66 runTest -XX:MaxDirectMemorySize=1k -cp ${TESTCLASSES} LimitDirectMemory true 1k 100
  67 runTest -XX:MaxDirectMemorySize=10m -cp ${TESTCLASSES} LimitDirectMemory true 10m 10m
  68 
  69 # We can increase the amount of available memory.
  70 runTest -XX:MaxDirectMemorySize=65M -cp ${TESTCLASSES} \