8220672: [TESTBUG] TestCPUSets should check that cpuset does not exceed available cores
Making sure cpuset size does not exceed available cores Reviewed-by: dholmes, lmesnik
This commit is contained in:
parent
2ad2cce6e0
commit
37572de2a1
@ -79,7 +79,6 @@ gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java 8193639 solaris-all
|
|||||||
# :hotspot_runtime
|
# :hotspot_runtime
|
||||||
|
|
||||||
runtime/SharedArchiveFile/SASymbolTableTest.java 8193639 solaris-all
|
runtime/SharedArchiveFile/SASymbolTableTest.java 8193639 solaris-all
|
||||||
containers/docker/TestCPUSets.java 8220672 generic-all
|
|
||||||
runtime/jni/terminatedThread/TestTerminatedThread.java 8219652 aix-ppc64
|
runtime/jni/terminatedThread/TestTerminatedThread.java 8219652 aix-ppc64
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -44,7 +44,7 @@ import jdk.test.lib.Asserts;
|
|||||||
import jdk.test.lib.Platform;
|
import jdk.test.lib.Platform;
|
||||||
import jdk.test.lib.Utils;
|
import jdk.test.lib.Utils;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
|
import jtreg.SkippedException;
|
||||||
|
|
||||||
public class TestCPUSets {
|
public class TestCPUSets {
|
||||||
private static final String imageName = Common.imageName("cpusets");
|
private static final String imageName = Common.imageName("cpusets");
|
||||||
@ -54,6 +54,7 @@ public class TestCPUSets {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Common.prepareWhiteBox();
|
Common.prepareWhiteBox();
|
||||||
DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
|
DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
|
||||||
|
|
||||||
@ -72,19 +73,45 @@ public class TestCPUSets {
|
|||||||
String cpuSetStr = CPUSetsReader.readFromProcStatus(setType);
|
String cpuSetStr = CPUSetsReader.readFromProcStatus(setType);
|
||||||
|
|
||||||
if (cpuSetStr == null) {
|
if (cpuSetStr == null) {
|
||||||
System.out.printf("The %s test is skipped %n", setType);
|
String msg = String.format("The %s test is skipped: cpuSetStr is null %n", setType);
|
||||||
} else {
|
throw new SkippedException(msg);
|
||||||
List<Integer> cpuSet = CPUSetsReader.parseCpuSet(cpuSetStr);
|
}
|
||||||
|
|
||||||
// Test subset of one, full subset, and half of the subset
|
List<Integer> cpuSet = CPUSetsReader.parseCpuSet(cpuSetStr);
|
||||||
|
int availableProcessors = Runtime.getRuntime().availableProcessors();
|
||||||
|
|
||||||
|
// print diagnostic info
|
||||||
|
printSet(setType, cpuSet);
|
||||||
|
log("getNumCpus(): " + CPUSetsReader.getNumCpus());
|
||||||
|
log("Runtime.getRuntime().availableProcessors(): " + availableProcessors);
|
||||||
|
|
||||||
|
int maxSetSize = Math.min(cpuSet.size(), availableProcessors);
|
||||||
|
log("maxSetSize = " + maxSetSize);
|
||||||
|
|
||||||
|
// Test subset of one, full set, and half of the set
|
||||||
testCpuSet(CPUSetsReader.listToString(cpuSet, 1));
|
testCpuSet(CPUSetsReader.listToString(cpuSet, 1));
|
||||||
if (cpuSet.size() > 1) {
|
if (maxSetSize >= 2) {
|
||||||
testCpuSet(CPUSetsReader.listToString(cpuSet));
|
String cpuSetParam = CPUSetsReader.listToString(cpuSet, maxSetSize);
|
||||||
|
log("Testing with cpuSetParam = " + cpuSetParam);
|
||||||
|
testCpuSet(cpuSetParam);
|
||||||
}
|
}
|
||||||
if (cpuSet.size() > 2) {
|
if (maxSetSize >= 4) {
|
||||||
testCpuSet(CPUSetsReader.listToString(cpuSet, cpuSet.size()/2 ));
|
String cpuSetParam = CPUSetsReader.listToString(cpuSet, maxSetSize/2);
|
||||||
|
log("Testing with cpuSetParam = " + cpuSetParam);
|
||||||
|
testCpuSet(cpuSetParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void printSet(String setType, List<Integer> set) {
|
||||||
|
System.out.print("printSet(): " + setType + ": ");
|
||||||
|
set.forEach( i -> System.out.print(i + ", "));
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void log(String msg) {
|
||||||
|
System.out.println(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user