Expand runtimes test suite to include Go, Java, PHP, and Python.

This change adds functionality for running more languages using
the runtimes test suite. It divides the languages into separate
test functions, which each call the helper testLang function in the
runtimes_test.go file. This allows them to be run individually
or as a group.

PiperOrigin-RevId: 261791935
This commit is contained in:
Samantha Sample 2019-08-05 16:09:58 -07:00 committed by gVisor bot
parent 960a5e5536
commit 23e740433d
1 changed files with 31 additions and 3 deletions

View File

@ -22,8 +22,16 @@ import (
"gvisor.dev/gvisor/runsc/test/testutil" "gvisor.dev/gvisor/runsc/test/testutil"
) )
func TestNodeJS(t *testing.T) { // Wait time for each test to run.
const img = "gcr.io/gvisor-proctor/nodejs" const timeout = 180 * time.Second
// Helper function to execute the docker container associated with the
// language passed. Captures the output of the list function and executes
// each test individually, supplying any errors recieved.
func testLang(t *testing.T, lang string) {
t.Helper()
img := "gcr.io/gvisor-presubmit/" + lang
if err := testutil.Pull(img); err != nil { if err := testutil.Pull(img); err != nil {
t.Fatalf("docker pull failed: %v", err) t.Fatalf("docker pull failed: %v", err)
} }
@ -49,7 +57,7 @@ func TestNodeJS(t *testing.T) {
} }
defer d.CleanUp() defer d.CleanUp()
status, err := d.Wait(60 * time.Second) status, err := d.Wait(timeout)
if err != nil { if err != nil {
t.Fatalf("docker test %q failed to wait: %v", tc, err) t.Fatalf("docker test %q failed to wait: %v", tc, err)
} }
@ -65,3 +73,23 @@ func TestNodeJS(t *testing.T) {
}) })
} }
} }
func TestGo(t *testing.T) {
testLang(t, "go")
}
func TestJava(t *testing.T) {
testLang(t, "java")
}
func TestNodejs(t *testing.T) {
testLang(t, "nodejs")
}
func TestPhp(t *testing.T) {
testLang(t, "php")
}
func TestPython(t *testing.T) {
testLang(t, "python")
}