test/java/util/logging/AnonLoggerWeakRefLeak.sh

Print this page




  42 
  43 TEST_NAME="AnonLoggerWeakRefLeak"
  44 TARGET_CLASS="java\.lang\.ref\.WeakReference"
  45 
  46 
  47 # MAIN begins here
  48 #
  49 
  50 seconds=
  51 if [ "$#" -gt 0 ]; then
  52     seconds="$1"
  53 fi
  54 
  55 # see if this version of jmap supports the '-histo:live' option
  56 jmap_option="-histo:live"
  57 set +e
  58 "${JMAP}" 2>&1 | grep ':live' > /dev/null 2>&1
  59 status="$?"
  60 set -e
  61 if [ "$status" != 0 ]; then
  62     echo "INFO: switching jmap option from '$jmap_option'\c"
  63     jmap_option="-histo"
  64     echo " to '$jmap_option'."

























  65 fi
  66 
  67 # Start application and use TEST_NAME.port for coordination
  68 startApplication "$TEST_NAME" "$TEST_NAME.port" $seconds
  69 
  70 finished_early=false
  71 
  72 decreasing_cnt=0
  73 increasing_cnt=0
  74 loop_cnt=0
  75 prev_instance_cnt=0
  76 
  77 MAX_JMAP_TRY_CNT=10
  78 jmap_retry_cnt=0
  79 loop_cnt_on_retry=0
  80 
  81 while true; do
  82     # see if the target process has finished its run and bail if it has
  83     set +e
  84     grep "^INFO: final loop count = " "$appOutput" > /dev/null 2>&1




  42 
  43 TEST_NAME="AnonLoggerWeakRefLeak"
  44 TARGET_CLASS="java\.lang\.ref\.WeakReference"
  45 
  46 
  47 # MAIN begins here
  48 #
  49 
  50 seconds=
  51 if [ "$#" -gt 0 ]; then
  52     seconds="$1"
  53 fi
  54 
  55 # see if this version of jmap supports the '-histo:live' option
  56 jmap_option="-histo:live"
  57 set +e
  58 "${JMAP}" 2>&1 | grep ':live' > /dev/null 2>&1
  59 status="$?"
  60 set -e
  61 if [ "$status" != 0 ]; then
  62     # usage message doesn't show ':live' option
  63 
  64     if $isWindows; then
  65         # If SA isn't present, then jmap gives a different usage message
  66         # that doesn't show the ':live' option. However, that's a bug that
  67         # is covered by 6971851 so we try using the option just to be sure.
  68         # For some reason, this problem has only been seen on OpenJDK6 on
  69         # Windows. Not sure why.
  70         set +e
  71         # Note: Don't copy this code to try probing process 0 on Linux; it
  72         # will kill the process group in strange ways.
  73         "${JMAP}" "$jmap_option" 0 2>&1 | grep 'Usage' > /dev/null 2>&1
  74         status="$?"
  75         set -e
  76         if [ "$status" = 0 ]; then
  77             # Usage message generated so flag the problem.
  78             status=1
  79         else
  80             # No usage message so clear the flag.
  81             status=0
  82         fi
  83     fi
  84 
  85     if [ "$status" != 0 ]; then
  86         echo "ERROR: 'jmap $jmap_option' is not supported so this test"
  87         echo "ERROR: cannot work reliably. Aborting!"
  88         exit 2
  89     fi
  90 fi
  91 
  92 # Start application and use TEST_NAME.port for coordination
  93 startApplication "$TEST_NAME" "$TEST_NAME.port" $seconds
  94 
  95 finished_early=false
  96 
  97 decreasing_cnt=0
  98 increasing_cnt=0
  99 loop_cnt=0
 100 prev_instance_cnt=0
 101 
 102 MAX_JMAP_TRY_CNT=10
 103 jmap_retry_cnt=0
 104 loop_cnt_on_retry=0
 105 
 106 while true; do
 107     # see if the target process has finished its run and bail if it has
 108     set +e
 109     grep "^INFO: final loop count = " "$appOutput" > /dev/null 2>&1