< prev index next >

test/runtime/SharedArchiveFile/SpaceUtilizationCheck.java

Print this page

*** 39,48 **** --- 39,49 ---- import sun.hotspot.WhiteBox; 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 { // [1] Each region must have strictly less than // WhiteBox.metaspaceReserveAlignment() bytes of unused space.
*** 60,83 **** } 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]+)"); WhiteBox wb = WhiteBox.getWhiteBox(); long reserve_alignment = wb.metaspaceReserveAlignment(); System.out.println("Metaspace::reserve_alignment() = " + reserve_alignment); long last_region = -1; 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); long unused = capacity - used; if (unused < 0) { throw new RuntimeException("Unused space (" + unused + ") less than 0"); } if (unused > reserve_alignment) { --- 61,92 ---- } 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]+)"); WhiteBox wb = WhiteBox.getWhiteBox(); long reserve_alignment = wb.metaspaceReserveAlignment(); System.out.println("Metaspace::reserve_alignment() = " + reserve_alignment); long last_region = -1; + Hashtable<String,String> 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()) { ! 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"); } if (unused > reserve_alignment) {
*** 91,97 **** --- 100,109 ---- } last_region = address + capacity; } } } + if (checked.size() != 5) { + throw new RuntimeException("Must have 5 consecutive, fully utilized regions"); + } } }
< prev index next >