JDK-7180649 : TEST_BUG: (bf) test java/nio/Buffer/LimitDirectMemory.sh has incorrect logic for invalid test cases
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2012-06-29
  • Updated: 2017-08-12
  • Resolved: 2017-08-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbd_minorResolved
Related Reports
Duplicate :  
Description
test java/nio/Buffer/LimitDirectMemory.sh tests the use of the -XX:MaxDirectMemorySize flag with the VM. Some invocations are expected to be invalid due to invalid parameter settings ie:

# Various bad values fail to launch the VM.
launchFail foo
launchFail 10kmt
launchFail -1

First bug: -1 is actually the default value for this flag, it is not an illegal value - it means "use the default". This error was not noticed because the "launch" still fails due to bug 2.

Second bug: launchfail is defined as:

launchFail() {
  echo "Testing: -XX:MaxDirectMemorySize=$* -cp ${TESTCLASSES} \
     LimitDirectMemory true DEFAULT DEFAULT+1M"
  ${TESTJAVA}/bin/java -XX:MaxDirectMemorySize=$* -cp ${TESTCLASSES} \
     LimitDirectMemory true DEFAULT DEFAULT+1M > ${TMP1} 2>&1
  cat ${TMP1}
  cat ${TMP1} | grep -s "Unrecognized VM option: \'MaxDirectMemorySize="
  if [ $? -ne 0 ]
    then echo "--- failed as expected"
  else
    echo "--- failed"
    exit 1
  fi
}

There are two problems here:

1. If the grep succeeds the test passes, so we should be checking for $? == 0. Instead we report failure for all invocations that don't output the message. This turns out to be all invocations because ...
2. The error message output by the VM does not match the string being grep'd for.

Expected: 

Unrecognized VM option: 'MaxDirectMemorySize=

Actual:

Unrecognized VM option 'MaxDirectMemorySize=

Note there is no colon. The format of this message has likely changed between VM versions.

Comments
With the fix for JDK-8181126 this test was migrated to pure java in jdk10
12-08-2017