com.oracle.java.testlibrary.Asserts Java Examples

The following examples show how to use com.oracle.java.testlibrary.Asserts. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SurvivorAlignmentTestMain.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a value parsed from a string with format
 * <integer><multiplier>.
 */
private static long parseSize(String sizeString) {
    Matcher matcher = SIZE_REGEX.matcher(sizeString);
    Asserts.assertTrue(matcher.matches(),
            "sizeString should have following format \"[0-9]+([MBK])?\"");
    long size = Long.valueOf(matcher.group("size"));

    if (matcher.group("multiplier") != null) {
        long K = 1024L;
        // fall through multipliers
        switch (matcher.group("multiplier").toLowerCase()) {
            case "g":
                size *= K;
            case "m":
                size *= K;
            case "k":
                size *= K;
        }
    }
    return size;
}
 
Example #2
Source File: TestMemoryMXBeansAndPoolsPresence.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    switch (args[0]) {
        case "G1":
            test(new GCBeanDescription("G1 Young Generation", new String[] {"G1 Eden Space", "G1 Survivor Space", "G1 Old Gen"}),
                 new GCBeanDescription("G1 Old Generation",   new String[] {"G1 Eden Space", "G1 Survivor Space", "G1 Old Gen"}));
            break;
        case "CMS":
            test(new GCBeanDescription("ParNew",              new String[] {"Par Eden Space", "Par Survivor Space"}),
                 new GCBeanDescription("ConcurrentMarkSweep", new String[] {"Par Eden Space", "Par Survivor Space", "CMS Old Gen"}));
            break;
        case "Parallel":
            test(new GCBeanDescription("PS Scavenge",         new String[] {"PS Eden Space", "PS Survivor Space"}),
                 new GCBeanDescription("PS MarkSweep",        new String[] {"PS Eden Space", "PS Survivor Space", "PS Old Gen"}));
            break;
        case "Serial":
            test(new GCBeanDescription("Copy",              new String[] {"Eden Space", "Survivor Space"}),
                 new GCBeanDescription("MarkSweepCompact",  new String[] {"Eden Space", "Survivor Space", "Tenured Gen"}));
            break;
        default:
            Asserts.assertTrue(false);
            break;

    }
}
 
Example #3
Source File: TestMutuallyExclusivePlatformPredicates.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies that all predicates defined in
 * {@link com.oracle.java.testlibrary.Platform} were either tested or
 * explicitly ignored.
 */
private static void verifyCoverage() {
    Set<String> allMethods = new HashSet<>();
    for (MethodGroup group : MethodGroup.values()) {
        allMethods.addAll(group.methodNames);
    }

    for (Method m : Platform.class.getMethods()) {
        if (m.getParameterCount() == 0
                && m.getReturnType() == boolean.class) {
            Asserts.assertTrue(allMethods.contains(m.getName()),
                    "All Platform's methods with signature '():Z' should "
                            + "be tested ");
        }
    }
}
 
Example #4
Source File: TestClassUnloadingDisabled.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    final WhiteBox wb = WhiteBox.getWhiteBox();
    // Fetch the dir where the test class and the class
    // to be loaded resides.
    String classDir = TestClassUnloadingDisabled.class.getProtectionDomain().getCodeSource().getLocation().getPath();
    String className = "ClassToLoadUnload";

    Asserts.assertFalse(wb.isClassAlive(className), "Should not be loaded yet");

    // The NoPDClassLoader handles loading classes in the test directory
    // and loads them without a protection domain, which in some cases
    // keeps the class live regardless of marking state.
    NoPDClassLoader nopd = new NoPDClassLoader(classDir);
    nopd.loadClass(className);

    Asserts.assertTrue(wb.isClassAlive(className), "Class should be loaded");

    // Clear the class-loader, class and object references to make
    // class unloading possible.
    nopd = null;

    System.gc();
    Asserts.assertTrue(wb.isClassAlive(className), "Class should not have ben unloaded");
}
 
Example #5
Source File: SurvivorAlignmentTestMain.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a value parsed from a string with format
 * &lt;integer&gt;&lt;multiplier&gt;.
 */
private static long parseSize(String sizeString) {
    Matcher matcher = SIZE_REGEX.matcher(sizeString);
    Asserts.assertTrue(matcher.matches(),
            "sizeString should have following format \"[0-9]+([MBK])?\"");
    long size = Long.valueOf(matcher.group("size"));

    if (matcher.group("multiplier") != null) {
        long K = 1024L;
        // fall through multipliers
        switch (matcher.group("multiplier").toLowerCase()) {
            case "g":
                size *= K;
            case "m":
                size *= K;
            case "k":
                size *= K;
        }
    }
    return size;
}
 
Example #6
Source File: TestMemoryMXBeansAndPoolsPresence.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    switch (args[0]) {
        case "G1":
            test(new GCBeanDescription("G1 Young Generation", new String[] {"G1 Eden Space", "G1 Survivor Space", "G1 Old Gen"}),
                 new GCBeanDescription("G1 Old Generation",   new String[] {"G1 Eden Space", "G1 Survivor Space", "G1 Old Gen"}));
            break;
        case "CMS":
            test(new GCBeanDescription("ParNew",              new String[] {"Par Eden Space", "Par Survivor Space"}),
                 new GCBeanDescription("ConcurrentMarkSweep", new String[] {"Par Eden Space", "Par Survivor Space", "CMS Old Gen"}));
            break;
        case "Parallel":
            test(new GCBeanDescription("PS Scavenge",         new String[] {"PS Eden Space", "PS Survivor Space"}),
                 new GCBeanDescription("PS MarkSweep",        new String[] {"PS Eden Space", "PS Survivor Space", "PS Old Gen"}));
            break;
        case "Serial":
            test(new GCBeanDescription("Copy",              new String[] {"Eden Space", "Survivor Space"}),
                 new GCBeanDescription("MarkSweepCompact",  new String[] {"Eden Space", "Survivor Space", "Tenured Gen"}));
            break;
        default:
            Asserts.assertTrue(false);
            break;

    }
}
 
Example #7
Source File: TestMutuallyExclusivePlatformPredicates.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies that all predicates defined in
 * {@link com.oracle.java.testlibrary.Platform} were either tested or
 * explicitly ignored.
 */
private static void verifyCoverage() {
    Set<String> allMethods = new HashSet<>();
    for (MethodGroup group : MethodGroup.values()) {
        allMethods.addAll(group.methodNames);
    }

    for (Method m : Platform.class.getMethods()) {
        if (m.getParameterCount() == 0
                && m.getReturnType() == boolean.class) {
            Asserts.assertTrue(allMethods.contains(m.getName()),
                    "All Platform's methods with signature '():Z' should "
                            + "be tested ");
        }
    }
}
 
Example #8
Source File: TestCPUSets.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void checkResult(List<String> lines, String lineMarker, String value) {
    boolean lineMarkerFound = false;

    for (String line : lines) {
        if (line.contains(lineMarker)) {
            lineMarkerFound = true;
            String[] parts = line.split(":");
            System.out.println("DEBUG: line = " + line);
            System.out.println("DEBUG: parts.length = " + parts.length);

            Asserts.assertEquals(parts.length, 2);
            String set = parts[1].replaceAll("\\s","");
            String actual = CPUSetsReader.listToString(CPUSetsReader.parseCpuSet(set));
            Asserts.assertEquals(actual, value);
            break;
        }
    }
    Asserts.assertTrue(lineMarkerFound);
}
 
Example #9
Source File: TestOldGenCollectionUsage.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void allocateOldObjects() {
    List<byte[]> deadOldObjects = new ArrayList<>();
    // Allocates buffer and promotes it to the old gen. Mix live and dead old
    // objects
    for (int i = 0; i < ALLOCATION_COUNT; ++i) {
        liveOldObjects.add(new byte[ALLOCATION_SIZE * 5]);
        deadOldObjects.add(new byte[ALLOCATION_SIZE * 5]);
    }

    // Do two young collections, MaxTenuringThreshold=1 will force promotion.
    // G1HeapRegionSize=1m guarantees that old gen regions will be filled.
    WB.youngGC();
    WB.youngGC();
    // Check it is promoted & keep alive
    Asserts.assertTrue(WB.isObjectInOldGen(liveOldObjects),
                       "List of the objects is suppose to be in OldGen");
    Asserts.assertTrue(WB.isObjectInOldGen(deadOldObjects),
                       "List of the objects is suppose to be in OldGen");
}
 
Example #10
Source File: TestOldGenCollectionUsage.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void provokeMixedGC() {
    waitTillCMCFinished(0);
    WB.g1StartConcMarkCycle();
    waitTillCMCFinished(0);
    WB.youngGC();

    System.out.println("Allocating new objects to provoke mixed GC");
    // Provoke a mixed collection. G1MixedGCLiveThresholdPercent=100
    // guarantees that full old gen regions will be included.
    for (int i = 0; i < (ALLOCATION_COUNT * 20); i++) {
        try {
            newObjects.add(new byte[ALLOCATION_SIZE]);
        } catch (OutOfMemoryError e) {
            newObjects.clear();
            WB.youngGC();
            WB.youngGC();
            System.out.println("OutOfMemoryError is reported, stop allocating new objects");
            break;
        }
    }
    // check that liveOldObjects still alive
    Asserts.assertTrue(WB.isObjectInOldGen(liveOldObjects),
                       "List of the objects is suppose to be in OldGen");
}
 
Example #11
Source File: ArrayScenario.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected ArrayScenario(String name, ProfilingType profilingType,
                        TypeHierarchy<? extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
    super(name, profilingType, hierarchy);
    final int x = 20;
    final int y = 10;

    TypeHierarchy.I prof = hierarchy.getM();
    TypeHierarchy.I confl = hierarchy.getN();

    this.array = (TypeHierarchy.I[]) Array.newInstance(hierarchy.getClassM(), y);
    Arrays.fill(array, prof);

    this.matrix = (TypeHierarchy.I[][]) Array.newInstance(hierarchy.getClassM(), x, y);
    for (int i = 0; i < x; i++) {
        this.matrix[i] = this.array;
    }

    Asserts.assertEquals(array.length, matrix[0].length, "Invariant");
}
 
Example #12
Source File: TestCPUSets.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void checkResult(List<String> lines, String lineMarker, String value) {
    boolean lineMarkerFound = false;

    for (String line : lines) {
        if (line.contains(lineMarker)) {
            lineMarkerFound = true;
            String[] parts = line.split(":");
            System.out.println("DEBUG: line = " + line);
            System.out.println("DEBUG: parts.length = " + parts.length);

            Asserts.assertEquals(parts.length, 2);
            String set = parts[1].replaceAll("\\s","");
            String actual = CPUSetsReader.listToString(CPUSetsReader.parseCpuSet(set));
            Asserts.assertEquals(actual, value);
            break;
        }
    }
    Asserts.assertTrue(lineMarkerFound);
}
 
Example #13
Source File: TestMutuallyExclusivePlatformPredicates.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies that all predicates defined in
 * {@link com.oracle.java.testlibrary.Platform} were either tested or
 * explicitly ignored.
 */
private static void verifyCoverage() {
    Set<String> allMethods = new HashSet<>();
    for (MethodGroup group : MethodGroup.values()) {
        allMethods.addAll(group.methodNames);
    }

    for (Method m : Platform.class.getMethods()) {
        if (m.getParameterCount() == 0
                && m.getReturnType() == boolean.class) {
            Asserts.assertTrue(allMethods.contains(m.getName()),
                    "All Platform's methods with signature '():Z' should "
                            + "be tested ");
        }
    }
}
 
Example #14
Source File: TestOldGenCollectionUsage.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void provokeMixedGC() {
    waitTillCMCFinished(0);
    WB.g1StartConcMarkCycle();
    waitTillCMCFinished(0);
    WB.youngGC();

    System.out.println("Allocating new objects to provoke mixed GC");
    // Provoke a mixed collection. G1MixedGCLiveThresholdPercent=100
    // guarantees that full old gen regions will be included.
    for (int i = 0; i < (ALLOCATION_COUNT * 20); i++) {
        try {
            newObjects.add(new byte[ALLOCATION_SIZE]);
        } catch (OutOfMemoryError e) {
            newObjects.clear();
            WB.youngGC();
            WB.youngGC();
            System.out.println("OutOfMemoryError is reported, stop allocating new objects");
            break;
        }
    }
    // check that liveOldObjects still alive
    Asserts.assertTrue(WB.isObjectInOldGen(liveOldObjects),
                       "List of the objects is suppose to be in OldGen");
}
 
Example #15
Source File: TestEagerReclaimHumongousRegions.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-XX:+UseG1GC",
        "-Xms128M",
        "-Xmx128M",
        "-Xmn16M",
        "-XX:+PrintGC",
        ReclaimRegionFast.class.getName());

    Pattern p = Pattern.compile("Full GC");

    OutputAnalyzer output = new OutputAnalyzer(pb.start());

    int found = 0;
    Matcher m = p.matcher(output.getStdout());
    while (m.find()) { found++; }
    System.out.println("Issued " + found + " Full GCs");
    Asserts.assertLT(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim seems to not work at all");

    output.shouldHaveExitValue(0);
}
 
Example #16
Source File: TestMutuallyExclusivePlatformPredicates.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies that all predicates defined in
 * {@link com.oracle.java.testlibrary.Platform} were either tested or
 * explicitly ignored.
 */
private static void verifyCoverage() {
    Set<String> allMethods = new HashSet<>();
    for (MethodGroup group : MethodGroup.values()) {
        allMethods.addAll(group.methodNames);
    }

    for (Method m : Platform.class.getMethods()) {
        if (m.getParameterCount() == 0
                && m.getReturnType() == boolean.class) {
            Asserts.assertTrue(allMethods.contains(m.getName()),
                    "All Platform's methods with signature '():Z' should "
                            + "be tested ");
        }
    }
}
 
Example #17
Source File: ArrayScenario.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected ArrayScenario(String name, ProfilingType profilingType,
                        TypeHierarchy<? extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
    super(name, profilingType, hierarchy);
    final int x = 20;
    final int y = 10;

    TypeHierarchy.I prof = hierarchy.getM();
    TypeHierarchy.I confl = hierarchy.getN();

    this.array = (TypeHierarchy.I[]) Array.newInstance(hierarchy.getClassM(), y);
    Arrays.fill(array, prof);

    this.matrix = (TypeHierarchy.I[][]) Array.newInstance(hierarchy.getClassM(), x, y);
    for (int i = 0; i < x; i++) {
        this.matrix[i] = this.array;
    }

    Asserts.assertEquals(array.length, matrix[0].length, "Invariant");
}
 
Example #18
Source File: TestEagerReclaimHumongousRegions.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-XX:+UseG1GC",
        "-Xms128M",
        "-Xmx128M",
        "-Xmn16M",
        "-XX:+PrintGC",
        ReclaimRegionFast.class.getName());

    Pattern p = Pattern.compile("Full GC");

    OutputAnalyzer output = new OutputAnalyzer(pb.start());

    int found = 0;
    Matcher m = p.matcher(output.getStdout());
    while (m.find()) { found++; }
    System.out.println("Issued " + found + " Full GCs");
    Asserts.assertLT(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim seems to not work at all");

    output.shouldHaveExitValue(0);
}
 
Example #19
Source File: BmiIntrinsicBase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected int countCpuInstructions(byte[] nativeCode) {
    int count = 0;
    int patternSize = Math.min(instrMask.length, instrPattern.length);
    boolean found;
    Asserts.assertGreaterThan(patternSize, 0);
    for (int i = 0, n = nativeCode.length - patternSize; i < n; i++) {
        found = true;
        for (int j = 0; j < patternSize; j++) {
            if ((nativeCode[i + j] & instrMask[j]) != instrPattern[j]) {
                found = false;
                break;
            }
        }
        if (found) {
            ++count;
            i += patternSize - 1;
        }
    }
    return count;
}
 
Example #20
Source File: TestObjectClone.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    TestObjectClone[] params1 = {a, a, a, a, a, a, a, a, a, a, a,
                      a, a, a, a, a, a, a, a, a, a, a,
                      a, a, a, a, a, a, a, a, a, a, a,
                      b, c, d};

    for (int i = 0; i < 15000; i++) {
        f(params1[i % params1.length]);
    }

    Asserts.assertTrue(f(a) != a);
    Asserts.assertTrue(f(b) == b);
    Asserts.assertTrue(f(c) == c);
    Asserts.assertTrue(f(d) == d);

    try {
        f(null);
        throw new AssertionError("");
    } catch (NullPointerException e) { /* expected */ }

    System.out.println("TEST PASSED");
}
 
Example #21
Source File: TestObjectClone.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    TestObjectClone[] params1 = {a, a, a, a, a, a, a, a, a, a, a,
                      a, a, a, a, a, a, a, a, a, a, a,
                      a, a, a, a, a, a, a, a, a, a, a,
                      b, c, d};

    for (int i = 0; i < 15000; i++) {
        f(params1[i % params1.length]);
    }

    Asserts.assertTrue(f(a) != a);
    Asserts.assertTrue(f(b) == b);
    Asserts.assertTrue(f(c) == c);
    Asserts.assertTrue(f(d) == d);

    try {
        f(null);
        throw new AssertionError("");
    } catch (NullPointerException e) { /* expected */ }

    System.out.println("TEST PASSED");
}
 
Example #22
Source File: BmiIntrinsicBase.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected int countCpuInstructions(byte[] nativeCode) {
    int count = 0;
    int patternSize = Math.min(instrMask.length, instrPattern.length);
    boolean found;
    Asserts.assertGreaterThan(patternSize, 0);
    for (int i = 0, n = nativeCode.length - patternSize; i < n; i++) {
        found = true;
        for (int j = 0; j < patternSize; j++) {
            if ((nativeCode[i + j] & instrMask[j]) != instrPattern[j]) {
                found = false;
                break;
            }
        }
        if (found) {
            ++count;
            i += patternSize - 1;
        }
    }
    return count;
}
 
Example #23
Source File: TestEagerReclaimHumongousRegions.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-XX:+UseG1GC",
        "-Xms128M",
        "-Xmx128M",
        "-Xmn16M",
        "-XX:+PrintGC",
        ReclaimRegionFast.class.getName());

    Pattern p = Pattern.compile("Full GC");

    OutputAnalyzer output = new OutputAnalyzer(pb.start());

    int found = 0;
    Matcher m = p.matcher(output.getStdout());
    while (m.find()) { found++; }
    System.out.println("Issued " + found + " Full GCs");
    Asserts.assertLT(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim seems to not work at all");

    output.shouldHaveExitValue(0);
}
 
Example #24
Source File: ArrayScenario.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected ArrayScenario(String name, ProfilingType profilingType,
                        TypeHierarchy<? extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
    super(name, profilingType, hierarchy);
    final int x = 20;
    final int y = 10;

    TypeHierarchy.I prof = hierarchy.getM();
    TypeHierarchy.I confl = hierarchy.getN();

    this.array = (TypeHierarchy.I[]) Array.newInstance(hierarchy.getClassM(), y);
    Arrays.fill(array, prof);

    this.matrix = (TypeHierarchy.I[][]) Array.newInstance(hierarchy.getClassM(), x, y);
    for (int i = 0; i < x; i++) {
        this.matrix[i] = this.array;
    }

    Asserts.assertEquals(array.length, matrix[0].length, "Invariant");
}
 
Example #25
Source File: ArrayScenario.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected ArrayScenario(String name, ProfilingType profilingType,
                        TypeHierarchy<? extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
    super(name, profilingType, hierarchy);
    final int x = 20;
    final int y = 10;

    TypeHierarchy.I prof = hierarchy.getM();
    TypeHierarchy.I confl = hierarchy.getN();

    this.array = (TypeHierarchy.I[]) Array.newInstance(hierarchy.getClassM(), y);
    Arrays.fill(array, prof);

    this.matrix = (TypeHierarchy.I[][]) Array.newInstance(hierarchy.getClassM(), x, y);
    for (int i = 0; i < x; i++) {
        this.matrix[i] = this.array;
    }

    Asserts.assertEquals(array.length, matrix[0].length, "Invariant");
}
 
Example #26
Source File: TestMemoryMXBeansAndPoolsPresence.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void test(GCBeanDescription... expectedBeans) {
    List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans();

    List<GarbageCollectorMXBean> gcBeans = ManagementFactory.getGarbageCollectorMXBeans();
    Asserts.assertEQ(expectedBeans.length, gcBeans.size());

    for (GCBeanDescription desc : expectedBeans) {
        List<GarbageCollectorMXBean> beans = gcBeans.stream()
                                                    .filter(b -> b.getName().equals(desc.name))
                                                    .collect(Collectors.toList());
        Asserts.assertEQ(beans.size(), 1);

        GarbageCollectorMXBean bean = beans.get(0);
        Asserts.assertEQ(desc.name, bean.getName());

        String[] pools = bean.getMemoryPoolNames();
        Asserts.assertEQ(desc.poolNames.length, pools.length);
        for (int i = 0; i < desc.poolNames.length; i++) {
            Asserts.assertEQ(desc.poolNames[i], pools[i]);
        }
    }
}
 
Example #27
Source File: AbortProvoker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get instance of specified AbortProvoker, inflate associated monitor
 * if needed and then invoke forceAbort method in a loop.
 *
 * Usage:
 * AbortProvoker &lt;AbortType name&gt; [&lt;inflate monitor&gt
 * [&lt;iterations&gt; [ &lt;delay&gt;]]]
 *
 *  Default parameters are:
 *  <ul>
 *  <li>inflate monitor = <b>true</b></li>
 *  <li>iterations = {@code AbortProvoker.DEFAULT_ITERATIONS}</li>
 *  <li>delay = <b>0</b></li>
 *  </ul>
 */
public static void main(String args[]) throws Throwable {
    Asserts.assertGT(args.length, 0, "At least one argument is required.");

    AbortType abortType = AbortType.lookup(Integer.valueOf(args[0]));
    boolean monitorShouldBeInflated = true;
    long iterations = AbortProvoker.DEFAULT_ITERATIONS;

    if (args.length > 1) {
        monitorShouldBeInflated = Boolean.valueOf(args[1]);

        if (args.length > 2) {
            iterations = Long.valueOf(args[2]);

            if (args.length > 3) {
                Thread.sleep(Integer.valueOf(args[3]));
            }
        }
    }

    AbortProvoker provoker = abortType.provoker();

    if (monitorShouldBeInflated) {
        provoker.inflateMonitor();
    }

    for (long i = 0; i < iterations; i++) {
        AbortProvoker.verifyMonitorState(provoker, monitorShouldBeInflated);
        provoker.forceAbort();
    }
}
 
Example #28
Source File: TestCheckJDK.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {
    String vmInstallDir = System.getProperty("java.home");

    Files.walk(Paths.get(vmInstallDir)).filter(Files::isRegularFile).forEach(TestCheckJDK::checkExecStack);

    Asserts.assertTrue(testPassed,
        "The tested VM contains libs that don't have the noexecstack " +
        "bit set. They must be linked with -z,noexecstack.");
}
 
Example #29
Source File: ClassIdentity.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void check(Integer result, T orig) {
    if (orig.getClass() == TypeHierarchy.A.class) {
        Asserts.assertEquals(result, orig.m(),
                "Results are not equal for TypeHierarchy.A.class");
    } else {
        Asserts.assertEquals(result, TypeHierarchy.TEMP, "Result differs from expected");
    }
}
 
Example #30
Source File: TestMutuallyExclusivePlatformPredicates.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verifies that one and only one predicate method defined in
 * {@link com.oracle.java.testlibrary.Platform}, whose name included into
 * methodGroup will return {@code true}.
 * @param methodGroup The group of methods that should be tested.
 */
private static void verifyPredicates(MethodGroup methodGroup) {
    System.out.println("Verifying method group: " + methodGroup.name());
    long truePredicatesCount = methodGroup.methodNames.stream()
            .filter(TestMutuallyExclusivePlatformPredicates
                    ::evaluatePredicate)
            .count();

    Asserts.assertEQ(truePredicatesCount, 1L, String.format(
            "Only one predicate from group %s should be evaluated to true "
                    + "(Actually %d predicates were evaluated to true).",
            methodGroup.name(), truePredicatesCount));
}