diff options
author | Samantha Sample <samsample@google.com> | 2019-07-29 14:15:51 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-07-29 14:17:11 -0700 |
commit | 8e8b6096116eb490b438a53061195f737d4eca8b (patch) | |
tree | ee0af6ddec5c18483fe2bc783382b62760e751ee /test/runtimes/java | |
parent | 09be87bbee1e4338b488f22199d0f079ffec8d0e (diff) |
Move runtimes tests to appropriate directory.
PiperOrigin-RevId: 260577765
Diffstat (limited to 'test/runtimes/java')
-rw-r--r-- | test/runtimes/java/BUILD | 8 | ||||
-rw-r--r-- | test/runtimes/java/Dockerfile | 52 | ||||
-rw-r--r-- | test/runtimes/java/proctor-java.go | 110 |
3 files changed, 170 insertions, 0 deletions
diff --git a/test/runtimes/java/BUILD b/test/runtimes/java/BUILD new file mode 100644 index 000000000..7e2808ece --- /dev/null +++ b/test/runtimes/java/BUILD @@ -0,0 +1,8 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary") + +package(licenses = ["notice"]) + +go_binary( + name = "proctor-java", + srcs = ["proctor-java.go"], +) diff --git a/test/runtimes/java/Dockerfile b/test/runtimes/java/Dockerfile new file mode 100644 index 000000000..e162d7218 --- /dev/null +++ b/test/runtimes/java/Dockerfile @@ -0,0 +1,52 @@ +FROM ubuntu:bionic +# This hash is associated with a specific JDK release and needed for ensuring +# the same version is downloaded every time. +ENV LANG_HASH=af47e0398606 +ENV LANG_VER=11u-dev +ENV LANG_NAME=Java + +RUN apt-get update && apt-get install -y \ + autoconf \ + build-essential \ + curl\ + file \ + libasound2-dev \ + libcups2-dev \ + libfontconfig1-dev \ + libx11-dev \ + libxext-dev \ + libxrandr-dev \ + libxrender-dev \ + libxt-dev \ + libxtst-dev \ + make \ + unzip \ + zip + +WORKDIR /root +RUN curl -o go.tar.gz https://dl.google.com/go/go1.12.6.linux-amd64.tar.gz +RUN tar -zxf go.tar.gz + +# Use curl instead of ADD to prevent redownload every time. +RUN curl -o jdk.tar.gz http://hg.openjdk.java.net/jdk-updates/jdk${LANG_VER}/archive/${LANG_HASH}.tar.gz +# Download Java version N-1 to be used as the Boot JDK to build Java version N. +RUN curl -o bootjdk.tar.gz https://download.java.net/openjdk/jdk10/ri/openjdk-10+44_linux-x64_bin_ri.tar.gz + +RUN tar -zxf jdk.tar.gz +RUN tar -zxf bootjdk.tar.gz + +# Specify the JDK to be used by jtreg. +ENV JT_JAVA=/root/jdk${LANG_VER}-${LANG_HASH}/build/linux-x86_64-normal-server-release/jdk +ENV LANG_DIR=/root/jdk${LANG_VER}-${LANG_HASH} + +WORKDIR ${LANG_DIR} + +RUN curl -o jtreg.tar.gz https://ci.adoptopenjdk.net/view/Dependencies/job/jtreg/lastSuccessfulBuild/artifact/jtreg-4.2.0-tip.tar.gz +RUN tar -xzf jtreg.tar.gz +RUN bash configure --with-boot-jdk=/root/jdk-10 --with-jtreg=${LANG_DIR}/jtreg +RUN make clean +RUN make images + +COPY proctor-java.go ${LANG_DIR} + +ENTRYPOINT ["/root/go/bin/go", "run", "proctor-java.go"] diff --git a/test/runtimes/java/proctor-java.go b/test/runtimes/java/proctor-java.go new file mode 100644 index 000000000..0177f421d --- /dev/null +++ b/test/runtimes/java/proctor-java.go @@ -0,0 +1,110 @@ +// Copyright 2019 The gVisor Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Binary proctor-java is a utility that facilitates language testing for Java. +package main + +import ( + "flag" + "fmt" + "log" + "os" + "os/exec" + "path/filepath" + "regexp" + "strings" +) + +var ( + list = flag.Bool("list", false, "list all available tests") + test = flag.String("test", "", "run a single test from the list of available tests") + version = flag.Bool("v", false, "print out the version of node that is installed") + + dir = os.Getenv("LANG_DIR") + jtreg = filepath.Join(dir, "jtreg/bin/jtreg") + exclDirs = regexp.MustCompile(`(^(sun\/security)|(java\/util\/stream)|(java\/time)| )`) +) + +func main() { + flag.Parse() + + if *list && *test != "" { + flag.PrintDefaults() + os.Exit(1) + } + if *list { + tests, err := listTests() + if err != nil { + log.Fatalf("Failed to list tests: %v", err) + } + for _, test := range tests { + fmt.Println(test) + } + return + } + if *version { + fmt.Println("Java version: ", os.Getenv("LANG_VER"), " is installed.") + return + } + if *test != "" { + runTest(*test) + return + } + runAllTests() +} + +func listTests() ([]string, error) { + args := []string{ + "-dir:test/jdk", + "-ignore:quiet", + "-a", + "-listtests", + ":jdk_core", + ":jdk_svc", + ":jdk_sound", + ":jdk_imageio", + } + cmd := exec.Command(jtreg, args...) + cmd.Stderr = os.Stderr + out, err := cmd.Output() + if err != nil { + return nil, fmt.Errorf("jtreg -listtests : %v", err) + } + var testSlice []string + for _, test := range strings.Split(string(out), "\n") { + if !exclDirs.MatchString(test) { + testSlice = append(testSlice, test) + } + } + return testSlice, nil +} + +func runTest(test string) { + args := []string{"-dir:test/jdk/", test} + cmd := exec.Command(jtreg, args...) + cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr + if err := cmd.Run(); err != nil { + log.Fatalf("Failed to run: %v", err) + } +} + +func runAllTests() { + tests, err := listTests() + if err != nil { + log.Fatalf("Failed to list tests: %v", err) + } + for _, test := range tests { + runTest(test) + } +} |