From 586e5cfa3b5957148f75c57a3acc3f2be49f4bff Mon Sep 17 00:00:00 2001 From: aarzilli Date: Wed, 3 Jan 2024 09:21:31 +0100 Subject: [PATCH] TeamCity: speed up ppc64le CI The builder is currently spending 15 to 20 minutes installing gcc and upgrading packages every time we run the tests. Because of this the build fails sometimes by running out of time. This change reduces that to 5 minutes by: * switching from curl to wget (which seems to have fewer dependencies) * not installing gcc on ppc64le * skipping tests that depend on gcc or other binutils --- _scripts/test_linux.sh | 18 +++++++++++------- pkg/proc/proc_linux_test.go | 9 +++++++++ pkg/proc/proc_test.go | 2 ++ service/dap/server_test.go | 1 + service/test/integration2_test.go | 3 +++ 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/_scripts/test_linux.sh b/_scripts/test_linux.sh index a0db51eef6..b19bf6bdf3 100755 --- a/_scripts/test_linux.sh +++ b/_scripts/test_linux.sh @@ -2,12 +2,16 @@ set -e set -x -apt-get -qq update -apt-get install -y gcc curl jq lsof - version=$1 arch=$2 +apt-get -qq update +if [ "$arch" = "ppc64le" ]; then + apt-get install --no-upgrade -y wget jq +else + apt-get install --no-upgrade -y gcc wget jq lsof +fi + if [ "$arch" != "ppc64le" ]; then apt-get install -y dwz @@ -17,7 +21,7 @@ fi function getgo { export GOROOT=/usr/local/go/$1 if [ ! -d "$GOROOT" ]; then - curl -sO https://dl.google.com/go/"$1".linux-"${arch}".tar.gz + wget -q https://dl.google.com/go/"$1".linux-"${arch}".tar.gz mkdir -p /usr/local/go tar -C /usr/local/go -xzf "$1".linux-"${arch}".tar.gz mv -f /usr/local/go/go "$GOROOT" @@ -26,7 +30,7 @@ function getgo { if [ "$version" = "gotip" ]; then echo Building Go from tip - getgo $(curl https://go.dev/VERSION?m=text | head -1) + getgo $(wget -q -O - https://go.dev/VERSION?m=text | head -1) export GOROOT_BOOTSTRAP=$GOROOT export GOROOT=/usr/local/go/go-tip apt-get install -y git @@ -37,9 +41,9 @@ if [ "$version" = "gotip" ]; then else echo Finding latest patch version for $version echo "Go $version on $arch" - version=$(curl 'https://go.dev/dl/?mode=json&include=all' | jq '.[].version' --raw-output | egrep ^$version'($|\.|beta|rc)' | sort -rV | head -1) + version=$(wget -q -O - 'https://go.dev/dl/?mode=json&include=all' | jq '.[].version' --raw-output | egrep ^$version'($|\.|beta|rc)' | sort -rV | head -1) if [ "x$version" = "x" ]; then - version=$(curl 'https://go.dev/dl/?mode=json&include=all' | jq '.[].version' --raw-output | egrep ^$version'($|\.)' | sort -rV | head -1) + version=$(wget -q -O - 'https://go.dev/dl/?mode=json&include=all' | jq '.[].version' --raw-output | egrep ^$version'($|\.)' | sort -rV | head -1) fi getgo $version fi diff --git a/pkg/proc/proc_linux_test.go b/pkg/proc/proc_linux_test.go index 36398936e4..a86c7bf59e 100644 --- a/pkg/proc/proc_linux_test.go +++ b/pkg/proc/proc_linux_test.go @@ -14,7 +14,15 @@ import ( protest "github.com/go-delve/delve/pkg/proc/test" ) +func mustHaveObjcopy(t *testing.T) { + t.Helper() + if objcopyPath, _ := exec.LookPath("objcopy"); objcopyPath == "" { + t.Skip("no objcopy in path") + } +} + func TestLoadingExternalDebugInfo(t *testing.T) { + mustHaveObjcopy(t) fixture := protest.BuildFixture("locationsprog", 0) defer os.Remove(fixture.Path) stripAndCopyDebugInfo(fixture, t) @@ -26,6 +34,7 @@ func TestLoadingExternalDebugInfo(t *testing.T) { } func TestGnuDebuglink(t *testing.T) { + mustHaveObjcopy(t) // build math.go and make a copy of the executable fixture := protest.BuildFixture("math", 0) buf, err := os.ReadFile(fixture.Path) diff --git a/pkg/proc/proc_test.go b/pkg/proc/proc_test.go index d39d516b35..f1485cddf7 100644 --- a/pkg/proc/proc_test.go +++ b/pkg/proc/proc_test.go @@ -4449,6 +4449,7 @@ func findSource(source string, sources []string) bool { } func TestListImages(t *testing.T) { + protest.MustHaveCgo(t) pluginFixtures := protest.WithPlugins(t, protest.AllNonOptimized, "plugin1/", "plugin2/") withTestProcessArgs("plugintest", t, ".", []string{pluginFixtures[0].Path, pluginFixtures[1].Path}, protest.AllNonOptimized, func(p *proc.Target, grp *proc.TargetGroup, fixture protest.Fixture) { @@ -4596,6 +4597,7 @@ func TestCallConcurrent(t *testing.T) { } func TestPluginStepping(t *testing.T) { + protest.MustHaveCgo(t) pluginFixtures := protest.WithPlugins(t, protest.AllNonOptimized, "plugin1/", "plugin2/") testseq2Args(".", []string{pluginFixtures[0].Path, pluginFixtures[1].Path}, protest.AllNonOptimized, t, "plugintest2", "", []seqTest{ diff --git a/service/dap/server_test.go b/service/dap/server_test.go index 3a5200dd8e..4031ebd1cb 100644 --- a/service/dap/server_test.go +++ b/service/dap/server_test.go @@ -7489,6 +7489,7 @@ func TestFindInstructions(t *testing.T) { func TestDisassembleCgo(t *testing.T) { // Test that disassembling a program containing cgo code does not create problems. // See issue #3040 + protest.MustHaveCgo(t) runTestBuildFlags(t, "cgodisass", func(client *daptest.Client, fixture protest.Fixture) { runDebugSessionWithBPs(t, client, "launch", // Launch diff --git a/service/test/integration2_test.go b/service/test/integration2_test.go index e2161fa026..7159529dd6 100644 --- a/service/test/integration2_test.go +++ b/service/test/integration2_test.go @@ -2789,6 +2789,9 @@ func TestNonGoDebug(t *testing.T) { if runtime.GOOS != "linux" { t.Skip() } + if objcopyPath, _ := exec.LookPath("cc"); objcopyPath == "" { + t.Skip("no C compiler in path") + } dir := protest.FindFixturesDir() path := protest.TempFile("testc") cmd := exec.Command("cc", "-g", "-o", path, filepath.Join(dir, "test.c"))