mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 17:44:40 +02:00
8196062: Enable docker container related tests for linux ppc64le
Also fix cgroup subsystem recognition Reviewed-by: goetz, dsamersoff, bobv
This commit is contained in:
parent
8abc2c38f7
commit
b68ed88ffb
4 changed files with 69 additions and 32 deletions
|
@ -122,35 +122,40 @@ template <typename T> int subsystem_file_contents(CgroupSubsystem* c,
|
||||||
char file[MAXPATHLEN+1];
|
char file[MAXPATHLEN+1];
|
||||||
char buf[MAXPATHLEN+1];
|
char buf[MAXPATHLEN+1];
|
||||||
|
|
||||||
if (c != NULL && c->subsystem_path() != NULL) {
|
if (c == NULL) {
|
||||||
strncpy(file, c->subsystem_path(), MAXPATHLEN);
|
log_debug(os, container)("subsystem_file_contents: CgroupSubsytem* is NULL");
|
||||||
file[MAXPATHLEN-1] = '\0';
|
return OSCONTAINER_ERROR;
|
||||||
int filelen = strlen(file);
|
}
|
||||||
if ((filelen + strlen(filename)) > (MAXPATHLEN-1)) {
|
if (c->subsystem_path() == NULL) {
|
||||||
log_debug(os, container)("File path too long %s, %s", file, filename);
|
log_debug(os, container)("subsystem_file_contents: subsystem path is NULL");
|
||||||
return OSCONTAINER_ERROR;
|
return OSCONTAINER_ERROR;
|
||||||
}
|
}
|
||||||
strncat(file, filename, MAXPATHLEN-filelen);
|
|
||||||
log_trace(os, container)("Path to %s is %s", filename, file);
|
strncpy(file, c->subsystem_path(), MAXPATHLEN);
|
||||||
fp = fopen(file, "r");
|
file[MAXPATHLEN-1] = '\0';
|
||||||
if (fp != NULL) {
|
int filelen = strlen(file);
|
||||||
p = fgets(buf, MAXPATHLEN, fp);
|
if ((filelen + strlen(filename)) > (MAXPATHLEN-1)) {
|
||||||
if (p != NULL) {
|
log_debug(os, container)("File path too long %s, %s", file, filename);
|
||||||
int matched = sscanf(p, scan_fmt, returnval);
|
return OSCONTAINER_ERROR;
|
||||||
if (matched == 1) {
|
}
|
||||||
fclose(fp);
|
strncat(file, filename, MAXPATHLEN-filelen);
|
||||||
return 0;
|
log_trace(os, container)("Path to %s is %s", filename, file);
|
||||||
} else {
|
fp = fopen(file, "r");
|
||||||
log_debug(os, container)("Type %s not found in file %s",
|
if (fp != NULL) {
|
||||||
scan_fmt , file);
|
p = fgets(buf, MAXPATHLEN, fp);
|
||||||
}
|
if (p != NULL) {
|
||||||
|
int matched = sscanf(p, scan_fmt, returnval);
|
||||||
|
if (matched == 1) {
|
||||||
|
fclose(fp);
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
log_debug(os, container)("Empty file %s", file);
|
log_debug(os, container)("Type %s not found in file %s", scan_fmt, file);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_debug(os, container)("Open of file %s failed, %s", file,
|
log_debug(os, container)("Empty file %s", file);
|
||||||
os::strerror(errno));
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log_debug(os, container)("Open of file %s failed, %s", file, os::strerror(errno));
|
||||||
}
|
}
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -273,7 +278,7 @@ void OSContainer::init() {
|
||||||
else {
|
else {
|
||||||
log_debug(os, container)("Incompatible str containing cgroup and cpuset: %s", p);
|
log_debug(os, container)("Incompatible str containing cgroup and cpuset: %s", p);
|
||||||
}
|
}
|
||||||
} else if (strstr(p, "cpu,cpuacct") != NULL) {
|
} else if (strstr(p, "cpu,cpuacct") != NULL || strstr(p, "cpuacct,cpu") != NULL) {
|
||||||
int matched = sscanf(p, "%d %d %d:%d %s %s",
|
int matched = sscanf(p, "%d %d %d:%d %s %s",
|
||||||
&mountid,
|
&mountid,
|
||||||
&parentid,
|
&parentid,
|
||||||
|
@ -322,8 +327,20 @@ void OSContainer::init() {
|
||||||
|
|
||||||
fclose(mntinfo);
|
fclose(mntinfo);
|
||||||
|
|
||||||
if (memory == NULL || cpuset == NULL || cpu == NULL || cpuacct == NULL) {
|
if (memory == NULL) {
|
||||||
log_debug(os, container)("Required cgroup subsystems not found");
|
log_debug(os, container)("Required cgroup memory subsystem not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cpuset == NULL) {
|
||||||
|
log_debug(os, container)("Required cgroup cpuset subsystem not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cpu == NULL) {
|
||||||
|
log_debug(os, container)("Required cgroup cpu subsystem not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cpuacct == NULL) {
|
||||||
|
log_debug(os, container)("Required cgroup cpuacct subsystem not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +391,7 @@ void OSContainer::init() {
|
||||||
memory->set_subsystem_path(base);
|
memory->set_subsystem_path(base);
|
||||||
} else if (strstr(controller, "cpuset") != NULL) {
|
} else if (strstr(controller, "cpuset") != NULL) {
|
||||||
cpuset->set_subsystem_path(base);
|
cpuset->set_subsystem_path(base);
|
||||||
} else if (strstr(controller, "cpu,cpuacct") != NULL) {
|
} else if (strstr(controller, "cpu,cpuacct") != NULL || strstr(controller, "cpuacct,cpu") != NULL) {
|
||||||
cpu->set_subsystem_path(base);
|
cpu->set_subsystem_path(base);
|
||||||
cpuacct->set_subsystem_path(base);
|
cpuacct->set_subsystem_path(base);
|
||||||
} else if (strstr(controller, "cpuacct") != NULL) {
|
} else if (strstr(controller, "cpuacct") != NULL) {
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
# test on x86_64 uses Oracle Linux but we do not have this for ppc64le
|
||||||
|
# so use some other Linux where OpenJDK works
|
||||||
|
# FROM oraclelinux:7.2
|
||||||
|
FROM ppc64le/ubuntu
|
||||||
|
|
||||||
|
COPY /jdk /jdk
|
||||||
|
|
||||||
|
ENV JAVA_HOME=/jdk
|
||||||
|
|
||||||
|
CMD ["/bin/bash"]
|
|
@ -352,9 +352,11 @@ public class VMProps implements Callable<Map<String, String>> {
|
||||||
* @return true if docker is supported in a given environment
|
* @return true if docker is supported in a given environment
|
||||||
*/
|
*/
|
||||||
protected String dockerSupport() {
|
protected String dockerSupport() {
|
||||||
// currently docker testing is only supported for Linux-x64
|
// currently docker testing is only supported for Linux-x64 and Linux-ppc64le
|
||||||
if (! ( Platform.isLinux() && Platform.isX64() ) )
|
String arch = System.getProperty("os.arch");
|
||||||
|
if (! (Platform.isLinux() && (Platform.isX64() || arch.equals("ppc64le")))) {
|
||||||
return "false";
|
return "false";
|
||||||
|
}
|
||||||
|
|
||||||
boolean isSupported;
|
boolean isSupported;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -34,6 +34,7 @@ import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
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 jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
|
@ -109,7 +110,9 @@ public class DockerTestUtils {
|
||||||
* The jdk will be placed under the "/jdk/" folder inside the docker file system.
|
* The jdk will be placed under the "/jdk/" folder inside the docker file system.
|
||||||
*
|
*
|
||||||
* @param imageName name of the image to be created, including version tag
|
* @param imageName name of the image to be created, including version tag
|
||||||
* @param dockerfile name of the dockerfile residing in the test source
|
* @param dockerfile name of the dockerfile residing in the test source;
|
||||||
|
* we check for a platform specific dockerfile as well
|
||||||
|
* and use this one in case it exists
|
||||||
* @param buildDirName name of the docker build/staging directory, which will
|
* @param buildDirName name of the docker build/staging directory, which will
|
||||||
* be created in the jtreg's scratch folder
|
* be created in the jtreg's scratch folder
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
@ -122,6 +125,11 @@ public class DockerTestUtils {
|
||||||
if (Files.exists(buildDir)) {
|
if (Files.exists(buildDir)) {
|
||||||
throw new RuntimeException("The docker build directory already exists: " + buildDir);
|
throw new RuntimeException("The docker build directory already exists: " + buildDir);
|
||||||
}
|
}
|
||||||
|
// check for the existance of a platform specific docker file as well
|
||||||
|
String platformSpecificDockerfile = dockerfile + "-" + Platform.getOsArch();
|
||||||
|
if (Files.exists(Paths.get(Utils.TEST_SRC, platformSpecificDockerfile))) {
|
||||||
|
dockerfile = platformSpecificDockerfile;
|
||||||
|
}
|
||||||
|
|
||||||
Path jdkSrcDir = Paths.get(Utils.TEST_JDK);
|
Path jdkSrcDir = Paths.get(Utils.TEST_JDK);
|
||||||
Path jdkDstDir = buildDir.resolve("jdk");
|
Path jdkDstDir = buildDir.resolve("jdk");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue