github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/pkg/uroot/builder/gbb_test.go (about) 1 // Copyright 2021 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 builder 6 7 import ( 8 "testing" 9 10 gbbgolang "github.com/u-root/gobusybox/src/pkg/golang" 11 "github.com/mvdan/u-root-coreutils/pkg/ulog/ulogtest" 12 "github.com/mvdan/u-root-coreutils/pkg/uroot/initramfs" 13 ) 14 15 func TestGBBBuild(t *testing.T) { 16 dir := t.TempDir() 17 18 opts := Opts{ 19 Env: gbbgolang.Default(), 20 Packages: []string{ 21 "../test/foo", 22 "../../../cmds/core/elvish", 23 }, 24 TempDir: dir, 25 BinaryDir: "bbin", 26 BuildOpts: &gbbgolang.BuildOpts{}, 27 } 28 af := initramfs.NewFiles() 29 var gbb GBBBuilder 30 if err := gbb.Build(ulogtest.Logger{TB: t}, af, opts); err != nil { 31 t.Fatalf("Build(%v, %v); %v != nil", af, opts, err) 32 } 33 34 mustContain := []string{ 35 "bbin/elvish", 36 "bbin/foo", 37 "bbin/bb", 38 } 39 for _, name := range mustContain { 40 if !af.Contains(name) { 41 t.Errorf("expected files to include %q; archive: %v", name, af) 42 } 43 } 44 }