gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/bb/bb_test.go (about)

     1  // Copyright 2018 the u-root 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  
     5  package bb
     6  
     7  import (
     8  	"io/ioutil"
     9  	"os"
    10  	"os/exec"
    11  	"path/filepath"
    12  	"testing"
    13  
    14  	"github.com/u-root/u-root/pkg/golang"
    15  )
    16  
    17  func TestPackageRewriteFile(t *testing.T) {
    18  	dir, err := ioutil.TempDir("", "u-root")
    19  	if err != nil {
    20  		t.Fatal(err)
    21  	}
    22  	defer os.RemoveAll(dir)
    23  
    24  	bin := filepath.Join(dir, "foo")
    25  	if err := BuildBusybox(golang.Default(), []string{"github.com/u-root/u-root/pkg/uroot/test/foo"}, false, bin); err != nil {
    26  		t.Fatal(err)
    27  	}
    28  
    29  	cmd := exec.Command(bin)
    30  	o, err := cmd.CombinedOutput()
    31  	if err != nil {
    32  		t.Fatalf("foo failed: %v %v", string(o), err)
    33  	}
    34  }