@@ -187,42 +187,46 @@ func main() {
187
187
func TestElfBindNow (t * testing.T ) {
188
188
t .Parallel ()
189
189
testenv .MustHaveGoBuild (t )
190
- testenv .MustInternalLink (t , false )
191
190
192
191
const (
193
- prog = `package main; func main() {}`
194
- prog_C = `package main; import "C"; func main() {}`
192
+ prog = `package main; func main() {}`
193
+ progC = `package main; import "C"; func main() {}`
195
194
)
196
195
197
196
tests := []struct {
198
- name string
199
- args []string
200
- prog string
201
- wantDf1Now bool
202
- wantDf1Pie bool
203
- wantDfBindNow bool
197
+ name string
198
+ args []string
199
+ prog string
200
+ mustHaveCGO bool
201
+ mustHaveBuildModePIE bool
202
+ wantDf1Now bool
203
+ wantDf1Pie bool
204
+ wantDfBindNow bool
204
205
}{
205
206
{name : "default" , prog : prog },
206
207
{
207
- name : "pie" ,
208
- args : []string {"-buildmode=pie" , "-ldflags" , "-linkmode=internal" },
209
- prog : prog ,
210
- wantDf1Pie : true ,
208
+ name : "pie" ,
209
+ args : []string {"-buildmode=pie" , "-ldflags" , "-linkmode=internal" },
210
+ mustHaveBuildModePIE : true ,
211
+ prog : prog ,
212
+ wantDf1Pie : true ,
211
213
},
212
214
{
213
215
name : "bindnow" ,
214
216
args : []string {"-ldflags" , "-bindnow -linkmode=internal" },
215
- prog : prog_C ,
217
+ prog : progC ,
218
+ mustHaveCGO : true ,
216
219
wantDf1Now : true ,
217
220
wantDfBindNow : true ,
218
221
},
219
222
{
220
- name : "bindnow-pie" ,
221
- args : []string {"-buildmode=pie" , "-ldflags" , "-bindnow -linkmode=internal" },
222
- prog : prog ,
223
- wantDf1Now : true ,
224
- wantDf1Pie : true ,
225
- wantDfBindNow : true ,
223
+ name : "bindnow-pie" ,
224
+ args : []string {"-buildmode=pie" , "-ldflags" , "-bindnow -linkmode=internal" },
225
+ prog : prog ,
226
+ mustHaveBuildModePIE : true ,
227
+ wantDf1Now : true ,
228
+ wantDf1Pie : true ,
229
+ wantDfBindNow : true ,
226
230
},
227
231
}
228
232
@@ -238,6 +242,14 @@ func TestElfBindNow(t *testing.T) {
238
242
239
243
for _ , test := range tests {
240
244
t .Run (test .name , func (t * testing.T ) {
245
+ testenv .MustInternalLink (t , test .mustHaveCGO )
246
+ if test .mustHaveCGO {
247
+ testenv .MustHaveCGO (t )
248
+ }
249
+ if test .mustHaveBuildModePIE {
250
+ testenv .MustHaveBuildMode (t , "pie" )
251
+ }
252
+
241
253
var (
242
254
gotDfBindNow , gotDf1Now , gotDf1Pie bool
243
255
0 commit comments