8085919: OperatingSystemMXBean/TestTotalSwap.java failure : Total Swap Space figures mismatch
authorjbachorik
Tue, 04 Aug 2015 15:16:23 +0200
changeset 32216 653e7ee1fea8
parent 32103 252be3ad6800
child 32218 c4a59b9f5c12
child 32219 e613f4863973
8085919: OperatingSystemMXBean/TestTotalSwap.java failure : Total Swap Space figures mismatch Reviewed-by: dholmes
jdk/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java	Mon Aug 03 15:31:29 2015 +0200
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java	Tue Aug 04 15:16:23 2015 +0200
@@ -73,6 +73,8 @@
     private static final long MAX_SIZE_FOR_PASS = Long.MAX_VALUE;
 
     public static void main(String args[]) throws Throwable {
+        // yocto might ignore the request to report swap size in bytes
+        boolean swapInKB = mbean.getVersion().contains("yocto");
 
         long expected_swap_size = getSwapSizeFromOs();
 
@@ -87,10 +89,13 @@
 
         if (expected_swap_size > -1) {
             if (size != expected_swap_size) {
-                throw new RuntimeException("Expected total swap size      : " +
-                                           expected_swap_size +
-                                           " but getTotalSwapSpaceSize returned: " +
-                                           size);
+                // try the expected size in kiloBytes
+                if (!(swapInKB && expected_swap_size * 1024 == size)) {
+                    throw new RuntimeException("Expected total swap size      : " +
+                                               expected_swap_size +
+                                               " but getTotalSwapSpaceSize returned: " +
+                                               size);
+                }
             }
         }