1// Copyright 2023 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5package main 6 7import ( 8 "internal/platform" 9 "testing" 10) 11 12// TestSupported tests that dist and the main tools agree on 13// which build modes are supported for a given target. We do things 14// this way because the dist tool needs to be buildable directly by 15// the bootstrap compiler, and as such can't import internal packages. 16func TestSupported(t *testing.T) { 17 defer func(a, o string) { 18 goarch = a 19 goos = o 20 }(goarch, goos) 21 22 var modes = []string{ 23 // we assume that "exe" and "archive" always work 24 "pie", 25 "c-archive", 26 "c-shared", 27 "shared", 28 "plugin", 29 } 30 31 for _, a := range okgoarch { 32 goarch = a 33 for _, o := range okgoos { 34 if _, ok := cgoEnabled[o+"/"+a]; !ok { 35 continue 36 } 37 goos = o 38 for _, mode := range modes { 39 var dt tester 40 dist := dt.supportedBuildmode(mode) 41 std := platform.BuildModeSupported("gc", mode, o, a) 42 if dist != std { 43 t.Errorf("discrepancy for %s-%s %s: dist says %t, standard library says %t", o, a, mode, dist, std) 44 } 45 } 46 } 47 } 48} 49