J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | # |
| 2 | # Copyright 2005 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 20 | # CA 95054 USA or visit www.sun.com if you need additional information or |
| 21 | # have any questions. |
| 22 | # |
| 23 | |
| 24 | # |
| 25 | # @test |
| 26 | # @summary Tests MM getTotalSwapSpaceSize() api. |
| 27 | # @author Swamy V |
| 28 | # @bug 6252770 |
| 29 | # |
| 30 | # @run build GetTotalSwapSpaceSize |
| 31 | # @run shell TestTotalSwap.sh |
| 32 | # |
| 33 | |
| 34 | # |
| 35 | # This test tests the actual swap size on linux and solaris. |
| 36 | # On windows this is just a sanity check and correct size should |
| 37 | # be checked manually: |
| 38 | # |
| 39 | # Windows NT/XP/2000: |
| 40 | # 1. Run Start->Accessories->System Tools->System Information. |
| 41 | # 2. The value (reported in Kbytes) is in the "Page File Space" entry |
| 42 | # Windows 98/ME: |
| 43 | # Unknown. |
| 44 | # |
| 45 | |
| 46 | |
| 47 | #set -x |
| 48 | |
| 49 | #Set appropriate jdk |
| 50 | # |
| 51 | |
| 52 | if [ ! -z "${TESTJAVA}" ] ; then |
| 53 | jdk="$TESTJAVA" |
| 54 | else |
| 55 | echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test." |
| 56 | exit 1 |
| 57 | fi |
| 58 | |
| 59 | runOne() |
| 60 | { |
| 61 | echo "runOne $@" |
| 62 | $TESTJAVA/bin/java -classpath $TESTCLASSES $@ || exit 3 |
| 63 | } |
| 64 | |
| 65 | solaris_swap_size() |
| 66 | { |
| 67 | total_swap=0 |
| 68 | for i in `/usr/sbin/swap -l | awk '{print $4}' | grep -v blocks` |
| 69 | do |
| 70 | # swap -l returns size in blocks of 512 bytes. |
| 71 | total_swap=`expr $i \* 512 + $total_swap` |
| 72 | done |
| 73 | } |
| 74 | |
| 75 | # Test GetTotalSwapSpaceSize if we are running on Unix |
| 76 | total_swap=0 |
| 77 | case `uname -s` in |
| 78 | SunOS ) |
| 79 | solaris_swap_size |
| 80 | runOne GetTotalSwapSpaceSize $total_swap |
| 81 | ;; |
| 82 | Linux ) |
| 83 | total_swap=`free -b | grep -i swap | awk '{print $2}'` |
| 84 | runOne GetTotalSwapSpaceSize $total_swap |
| 85 | ;; |
| 86 | * ) |
| 87 | runOne GetTotalSwapSpaceSize "sanity-only" |
| 88 | ;; |
| 89 | esac |
| 90 | |
| 91 | exit 0 |
| 92 | |