diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 19:25:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 19:25:22 +0000 |
commit | f6ad4dcef54c5ce997a4bad5a6d86de229015700 (patch) | |
tree | 7cfa4e31ace5c2bd95c72b154d15af494b2bcbef /src/cmd/dist/supported_test.go | |
parent | Initial commit. (diff) | |
download | golang-1.22-f6ad4dcef54c5ce997a4bad5a6d86de229015700.tar.xz golang-1.22-f6ad4dcef54c5ce997a4bad5a6d86de229015700.zip |
Adding upstream version 1.22.1.upstream/1.22.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/cmd/dist/supported_test.go')
-rw-r--r-- | src/cmd/dist/supported_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/cmd/dist/supported_test.go b/src/cmd/dist/supported_test.go new file mode 100644 index 0000000..27c0b92 --- /dev/null +++ b/src/cmd/dist/supported_test.go @@ -0,0 +1,48 @@ +// Copyright 2023 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. + +package main + +import ( + "internal/platform" + "testing" +) + +// TestSupportedBuildModes tests that dist and the main tools agree on +// which build modes are supported for a given target. We do things +// this way because the dist tool needs to be buildable directly by +// the bootstrap compiler, and as such can't import internal packages. +func TestSupported(t *testing.T) { + defer func(a, o string) { + goarch = a + goos = o + }(goarch, goos) + + var modes = []string{ + // we assume that "exe" and "archive" always work + "pie", + "c-archive", + "c-shared", + "shared", + "plugin", + } + + for _, a := range okgoarch { + goarch = a + for _, o := range okgoos { + if _, ok := cgoEnabled[o+"/"+a]; !ok { + continue + } + goos = o + for _, mode := range modes { + var dt tester + dist := dt.supportedBuildmode(mode) + std := platform.BuildModeSupported("gc", mode, o, a) + if dist != std { + t.Errorf("discrepancy for %s-%s %s: dist says %t, standard library says %t", o, a, mode, dist, std) + } + } + } + } +} |