1 # |
|
2 # Copyright (c) 2005, 2012, 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 |
|
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 ${TESTVMOPTS} -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 Darwin ) |
|
87 # $ sysctl -n vm.swapusage |
|
88 # total = 8192.00M used = 7471.11M free = 720.89M (encrypted) |
|
89 swap=`/usr/sbin/sysctl -n vm.swapusage | awk '{ print $3 }' | awk -F . '{ print $1 }'` || exit 2 |
|
90 total_swap=`expr $swap \* 1024 \* 1024` || exit 2 |
|
91 runOne GetTotalSwapSpaceSize $total_swap |
|
92 ;; |
|
93 * ) |
|
94 runOne GetTotalSwapSpaceSize "sanity-only" |
|
95 ;; |
|
96 esac |
|
97 |
|
98 exit 0 |
|
99 |
|