github.com/0xKiwi/rules_go@v0.24.3/tests/core/go_binary/static_test.go (about) 1 // Copyright 2019 The Bazel Authors. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // +build linux 16 17 package static_cgo_test 18 19 import ( 20 "debug/elf" 21 "testing" 22 23 "github.com/bazelbuild/rules_go/go/tools/bazel" 24 ) 25 26 func TestStatic(t *testing.T) { 27 for _, name := range []string{"static_bin", "static_cgo_bin", "static_pure_bin"} { 28 t.Run(name, func(t *testing.T) { 29 path, ok := bazel.FindBinary("tests/core/go_binary", name) 30 if !ok { 31 t.Fatal("could not find static_cgo_bin") 32 } 33 f, err := elf.Open(path) 34 if err != nil { 35 t.Fatal(err) 36 } 37 defer f.Close() 38 for _, prog := range f.Progs { 39 if prog.Type == elf.PT_INTERP { 40 t.Fatalf("binary %s has PT_INTERP segment, indicating dynamic linkage", path) 41 } 42 } 43 }) 44 } 45 }