github.com/apptainer/singularity@v3.1.1+incompatible/internal/pkg/build/sources/conveyorPacker_debootstrap_test.go (about) 1 // Copyright (c) 2018, Sylabs Inc. All rights reserved. 2 // This software is licensed under a 3-clause BSD license. Please consult the 3 // LICENSE.md file distributed with the sources of this project regarding your 4 // rights to use or distribute this software. 5 6 package sources_test 7 8 import ( 9 "os/exec" 10 "testing" 11 12 "github.com/sylabs/singularity/internal/pkg/build/sources" 13 "github.com/sylabs/singularity/internal/pkg/test" 14 "github.com/sylabs/singularity/pkg/build/types" 15 ) 16 17 func TestDebootstrapConveyor(t *testing.T) { 18 19 if testing.Short() { 20 t.SkipNow() 21 } 22 23 if _, err := exec.LookPath("debootstrap"); err != nil { 24 t.Skip("skipping test, debootstrap not installed") 25 } 26 27 test.EnsurePrivilege(t) 28 29 b, err := types.NewBundle("", "sbuild-debootstrap") 30 if err != nil { 31 return 32 } 33 34 b.Recipe.Header = map[string]string{ 35 "bootstrap": "debootstrap", 36 "osversion": "bionic", 37 "mirrorurl": "http://us.archive.ubuntu.com/ubuntu/", 38 "include": "apt python ", 39 } 40 41 cp := sources.DebootstrapConveyorPacker{} 42 43 err = cp.Get(b) 44 // clean up tmpfs since assembler isnt called 45 defer cp.CleanUp() 46 if err != nil { 47 t.Fatalf("Debootstrap Get failed: %v", err) 48 } 49 } 50 51 func TestDebootstrapPacker(t *testing.T) { 52 53 if _, err := exec.LookPath("debootstrap"); err != nil { 54 t.Skip("skipping test, debootstrap not installed") 55 } 56 57 test.EnsurePrivilege(t) 58 59 b, err := types.NewBundle("", "sbuild-debootstrap") 60 if err != nil { 61 return 62 } 63 64 b.Recipe.Header = map[string]string{ 65 "bootstrap": "debootstrap", 66 "osversion": "bionic", 67 "mirrorurl": "http://us.archive.ubuntu.com/ubuntu/", 68 "include": "apt python ", 69 } 70 71 cp := sources.DebootstrapConveyorPacker{} 72 73 err = cp.Get(b) 74 // clean up tmpfs since assembler isnt called 75 defer cp.CleanUp() 76 if err != nil { 77 t.Fatalf("Debootstrap Get failed: %v", err) 78 } 79 80 _, err = cp.Pack() 81 if err != nil { 82 t.Fatalf("Debootstrap Pack failed: %v", err) 83 } 84 }