Skip to content

Commit

Permalink
internal/regtest: skip TestE2E if telemetry is disabled on platform
Browse files Browse the repository at this point in the history
Also add a stub version of the countertest package similar to the one
in counter_disabled.go so that countertest can compile on platforms
where telemetry disabled.

Fixes golang/go#65544

Change-Id: I46272034a4d80fe3c79fd5bfd9073eb5ef3b6010
Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/562076
Reviewed-by: Robert Findley <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
matloob committed Feb 7, 2024
1 parent 1f276f0 commit 45a088d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
9 changes: 6 additions & 3 deletions counter/countertest/countertest.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build go1.19 && !openbsd && !js && !wasip1 && !solaris && !android && !386

// countertest provides testing utilities for counters.
// This package cannot be used except for testing.
package countertest
Expand All @@ -11,7 +13,8 @@ import (
"path/filepath"
"sync"

"golang.org/x/telemetry/internal/counter"
"golang.org/x/telemetry/counter"
ic "golang.org/x/telemetry/internal/counter"
"golang.org/x/telemetry/internal/telemetry"
)

Expand Down Expand Up @@ -49,13 +52,13 @@ func ReadCounter(c *counter.Counter) (count uint64, _ error) {
if !isOpen() {
return 0, fmt.Errorf("unmet requirement - Open must be called")
}
return counter.Read(c)
return ic.Read(c)
}

// ReadStackCounter reads the given StackCounter.
func ReadStackCounter(c *counter.StackCounter) (stackCounts map[string]uint64, _ error) {
if !isOpen() {
return nil, fmt.Errorf("unmet requirement - Open must be called")
}
return counter.ReadStack(c)
return ic.ReadStack(c)
}
13 changes: 13 additions & 0 deletions counter/countertest/countertest_disabled.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !go1.19 || openbsd || js || wasip1 || solaris || android || 386

package countertest

import "golang.org/x/telemetry/counter"

func Open(telemetryDir string) {}
func ReadCounter(c *counter.Counter) (count uint64, _ error) {}
func ReadStackCounter(c *counter.StackCounter) (stackCounts map[string]uint64, _ error) {}
1 change: 1 addition & 0 deletions internal/regtest/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func TestE2E_off(t *testing.T) {

func TestE2E(t *testing.T) {
testenv.MustHaveExec(t)
testenv.SkipIfUnsupportedPlatform(t)
programIncCounters := NewProgram(t, "prog", programIncCounters)
telemetryDir := t.TempDir()
goVers, progVers, progName := ProgInfo(t)
Expand Down
7 changes: 5 additions & 2 deletions internal/upload/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ func NewUploader(config *telemetry.UploadConfig) *Uploader {
// disabledOnPlatform indicates whether telemetry is disabled
// due to bugs in the current platform.
const disabledOnPlatform = false ||
// The following platforms could potentially be supported in the future:
runtime.GOOS == "openbsd" || // #60614
runtime.GOOS == "js" || // #60971
runtime.GOOS == "wasip1" || // #60971
runtime.GOOS == "solaris" || // #60968 #60970
runtime.GOOS == "android" || // #60967
// These platforms fundamentally can't be supported:
runtime.GOOS == "js" || // #60971
runtime.GOOS == "wasip1" || // #60971
// Work is in progress to support 386:
runtime.GOARCH == "386" // #60615 #60692 #60965 #60967

// Run generates and uploads reports
Expand Down

0 comments on commit 45a088d

Please sign in to comment.