--- old/test/runtime/SharedArchiveFile/SpaceUtilizationCheck.java 2017-07-27 12:12:35.020134200 -0700 +++ new/test/runtime/SharedArchiveFile/SpaceUtilizationCheck.java 2017-07-27 12:12:34.900129557 -0700 @@ -41,6 +41,7 @@ import java.util.regex.Pattern; import java.util.regex.Matcher; import java.util.ArrayList; +import java.util.Hashtable; import java.lang.Integer; public class SpaceUtilizationCheck { @@ -62,20 +63,28 @@ static void test(String... extra_options) throws Exception { OutputAnalyzer output = CDSTestUtils.createArchive(extra_options); CDSTestUtils.checkDump(output); - Pattern pattern = Pattern.compile("^.. space: *([0-9]+).* out of *([0-9]+) bytes .* at 0x([0-9a0-f]+)"); + Pattern pattern = Pattern.compile("^(..) space: *([0-9]+).* out of *([0-9]+) bytes .* at 0x([0-9a0-f]+)"); WhiteBox wb = WhiteBox.getWhiteBox(); long reserve_alignment = wb.metaspaceReserveAlignment(); System.out.println("Metaspace::reserve_alignment() = " + reserve_alignment); long last_region = -1; + Hashtable checked = new Hashtable<>(); for (String line : output.getStdout().split("\n")) { if (line.contains(" space:") && !line.contains("st space:")) { Matcher matcher = pattern.matcher(line); if (matcher.find()) { - System.out.println("Checking: " + line); - long used = Long.parseLong(matcher.group(1)); - long capacity = Long.parseLong(matcher.group(2)); - long address = Long.parseLong(matcher.group(3), 16); + String name = matcher.group(1); + if (name.equals("s0") || name.equals("s1")) { + // String regions are listed at the end and they may not be fully occupied. + break; + } else { + System.out.println("Checking " + name + " in : " + line); + checked.put(name, name); + } + long used = Long.parseLong(matcher.group(2)); + long capacity = Long.parseLong(matcher.group(3)); + long address = Long.parseLong(matcher.group(4), 16); long unused = capacity - used; if (unused < 0) { throw new RuntimeException("Unused space (" + unused + ") less than 0"); @@ -93,5 +102,8 @@ } } } + if (checked.size() != 5) { + throw new RuntimeException("Must have 5 consecutive, fully utilized regions"); + } } }