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 * @bug 4858522
27 * @summary Basic unit test of OperatingSystemMXBean.getTotalSwapSpaceSize()
28 * @author Steve Bohne
29 * @author Jaroslav Bachorik
30 *
31 * @library /lib/testlibrary
32 * @library /test/lib
33 *
34 * @build TestTotalSwap jdk.testlibrary.*
35 * @run main TestTotalSwap
36 */
37
38 /*
39 * This test tests the actual swap size on linux and solaris.
40 * The correct value should be checked manually:
41 * Solaris:
42 * 1. In a shell, enter the command: "swap -l"
43 * 2. The value (reported in blocks) is in the "blocks" column.
44 * Linux:
45 * 1. In a shell, enter the command: "cat /proc/meminfo"
46 * 2. The value (reported in bytes) is in "Swap" entry, "total" column.
47 * Windows NT/XP/2000:
48 * 1. Run Start->Accessories->System Tools->System Information.
49 * 2. The value (reported in Kbytes) is in the "Page File Space" entry
50 * Windows 98/ME:
51 * Unknown.
52 *
53 * Usage: GetTotalSwapSpaceSize <expected swap size | "sanity-only"> [trace]
54 */
55
56 import com.sun.management.OperatingSystemMXBean;
57 import java.lang.management.*;
58
59 import jdk.test.lib.Platform;
60 import jdk.testlibrary.ProcessTools;
61 import jdk.testlibrary.OutputAnalyzer;
62
63 public class TestTotalSwap {
64
65 private static final OperatingSystemMXBean mbean =
66 (com.sun.management.OperatingSystemMXBean)
67 ManagementFactory.getOperatingSystemMXBean();
68
69 // Careful with these values.
70 // Min size for pass dynamically determined below.
71 // zero if no swap space is configured.
72 private static long min_size_for_pass = 0;
73 private static final long MAX_SIZE_FOR_PASS = Long.MAX_VALUE;
74
75 public static void main(String args[]) throws Throwable {
76 // yocto might ignore the request to report swap size in bytes
77 boolean swapInKB = mbean.getVersion().contains("yocto");
78
79 long expected_swap_size = getSwapSizeFromOs();
80
81 long min_size = mbean.getFreeSwapSpaceSize();
|
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 * @bug 4858522
27 * @summary Basic unit test of OperatingSystemMXBean.getTotalSwapSpaceSize()
28 * @author Steve Bohne
29 * @author Jaroslav Bachorik
30 *
31 * @library /test/lib
32 *
33 * @run main TestTotalSwap
34 */
35
36 /*
37 * This test tests the actual swap size on linux and solaris.
38 * The correct value should be checked manually:
39 * Solaris:
40 * 1. In a shell, enter the command: "swap -l"
41 * 2. The value (reported in blocks) is in the "blocks" column.
42 * Linux:
43 * 1. In a shell, enter the command: "cat /proc/meminfo"
44 * 2. The value (reported in bytes) is in "Swap" entry, "total" column.
45 * Windows NT/XP/2000:
46 * 1. Run Start->Accessories->System Tools->System Information.
47 * 2. The value (reported in Kbytes) is in the "Page File Space" entry
48 * Windows 98/ME:
49 * Unknown.
50 *
51 * Usage: GetTotalSwapSpaceSize <expected swap size | "sanity-only"> [trace]
52 */
53
54 import com.sun.management.OperatingSystemMXBean;
55 import java.lang.management.*;
56
57 import jdk.test.lib.Platform;
58 import jdk.test.lib.process.ProcessTools;
59 import jdk.test.lib.process.OutputAnalyzer;
60
61 public class TestTotalSwap {
62
63 private static final OperatingSystemMXBean mbean =
64 (com.sun.management.OperatingSystemMXBean)
65 ManagementFactory.getOperatingSystemMXBean();
66
67 // Careful with these values.
68 // Min size for pass dynamically determined below.
69 // zero if no swap space is configured.
70 private static long min_size_for_pass = 0;
71 private static final long MAX_SIZE_FOR_PASS = Long.MAX_VALUE;
72
73 public static void main(String args[]) throws Throwable {
74 // yocto might ignore the request to report swap size in bytes
75 boolean swapInKB = mbean.getVersion().contains("yocto");
76
77 long expected_swap_size = getSwapSizeFromOs();
78
79 long min_size = mbean.getFreeSwapSpaceSize();
|