@@ -14,8 +14,8 @@ import (
1414 "strings"
1515 "testing"
1616
17+ gbbgolang "github.com/u-root/gobusybox/src/pkg/golang"
1718 "github.com/u-root/u-root/pkg/cp"
18- "github.com/u-root/u-root/pkg/golang"
1919 "github.com/u-root/u-root/pkg/qemu"
2020 "github.com/u-root/u-root/pkg/testutil"
2121 "github.com/u-root/u-root/pkg/uio"
@@ -40,11 +40,6 @@ type Options struct {
4040 // possible.
4141 QEMUOpts qemu.Options
4242
43- // DontSetEnv doesn't set the BuildOpts.Env and uses the user-supplied one.
44- //
45- // TODO: make uroot.Opts.Env a pointer?
46- DontSetEnv bool
47-
4843 // Name is the test's name.
4944 //
5045 // If name is left empty, the calling function's function name will be
@@ -270,7 +265,7 @@ func QEMU(o *Options) (*qemu.Options, error) {
270265 // Set the initramfs.
271266 if len (o .QEMUOpts .Initramfs ) == 0 {
272267 o .QEMUOpts .Initramfs = filepath .Join (o .TmpDir , "initramfs.cpio" )
273- if err := ChooseTestInitramfs (o .DontSetEnv , o . BuildOpts , o .Uinit , o .QEMUOpts .Initramfs ); err != nil {
268+ if err := ChooseTestInitramfs (o .BuildOpts , o .Uinit , o .QEMUOpts .Initramfs ); err != nil {
274269 return nil , err
275270 }
276271 }
@@ -312,7 +307,7 @@ func QEMU(o *Options) (*qemu.Options, error) {
312307// Default to the override initramfs if one is specified in the UROOT_INITRAMFS
313308// environment variable. Else, build an initramfs with the given parameters.
314309// If no uinit was provided, the generic one is used.
315- func ChooseTestInitramfs (dontSetEnv bool , o uroot.Opts , uinit , outputFile string ) error {
310+ func ChooseTestInitramfs (o uroot.Opts , uinit , outputFile string ) error {
316311 override := os .Getenv ("UROOT_INITRAMFS" )
317312 if len (override ) > 0 {
318313 log .Printf ("Overriding with initramfs %q" , override )
@@ -324,7 +319,7 @@ func ChooseTestInitramfs(dontSetEnv bool, o uroot.Opts, uinit, outputFile string
324319 uinit = "github.com/u-root/u-root/integration/testcmd/generic/uinit"
325320 }
326321
327- _ , err := CreateTestInitramfs (dontSetEnv , o , uinit , outputFile )
322+ _ , err := CreateTestInitramfs (o , uinit , outputFile )
328323 return err
329324}
330325
@@ -333,12 +328,12 @@ func ChooseTestInitramfs(dontSetEnv bool, o uroot.Opts, uinit, outputFile string
333328// one will be created.
334329// The output file name is returned. It is the caller's responsibility to remove
335330// the initramfs file after use.
336- func CreateTestInitramfs (dontSetEnv bool , o uroot.Opts , uinit , outputFile string ) (string , error ) {
337- if ! dontSetEnv {
338- env := golang .Default ()
331+ func CreateTestInitramfs (o uroot.Opts , uinit , outputFile string ) (string , error ) {
332+ if o . Env == nil {
333+ env := gbbgolang .Default ()
339334 env .CgoEnabled = false
340335 env .GOARCH = TestArch ()
341- o .Env = env
336+ o .Env = & env
342337 }
343338
344339 if o .UrootSource == "" {
0 commit comments