| 1 | //go:build !windows |
| 2 | // +build !windows |
| 3 | |
| 4 | package fsutilscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/ |
| 5 | |
| 6 | import ( |
| 7 | "contextscip-go gomod github.com/golang/go/src go1.21 context/" |
| 8 | "osscip-go gomod github.com/golang/go/src go1.21 os/" |
| 9 | "path/filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/" |
| 10 | "syscallscip-go gomod github.com/golang/go/src go1.21 syscall/" |
| 11 | "testingscip-go gomod github.com/golang/go/src go1.21 testing/" |
| 12 | "timescip-go gomod github.com/golang/go/src go1.21 time/" |
| 13 | |
| 14 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/" |
| 15 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/" |
| 16 | "golang.org/x/sys/unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/" |
| 17 | ) |
| 18 | |
| 19 | func TestWalkerWriterAsyncscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestWalkerWriterAsync().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 20 | d, err := tmpDirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/tmpDir().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{ |
| 21 | "ADD foo dir", |
| 22 | "ADD foo/foo1 file data1", |
| 23 | "ADD foo/foo2 file data2", |
| 24 | "ADD foo/foo3 file data3", |
| 25 | "ADD foo/foo4 file >foo/foo3", |
| 26 | "ADD foo5 file data5", |
| 27 | })) |
| 28 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 29 | defer osscip-go gomod github.com/golang/go/src go1.21 os/.RemoveAllscip-go gomod github.com/golang/go/src go1.21 os/RemoveAll().(d) |
| 30 | |
| 31 | dest := t.TempDirscip-go gomod github.com/golang/go/src go1.21 testing/common#TempDir().() |
| 32 | |
| 33 | dw, err := NewDiskWriterscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/NewDiskWriter().(contextscip-go gomod github.com/golang/go/src go1.21 context/.TODOscip-go gomod github.com/golang/go/src go1.21 context/TODO().(), dest, DiskWriterOptscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DiskWriterOpt#{ |
| 34 | AsyncDataCbscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DiskWriterOpt#AsyncDataCb.: newWriteToFuncscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/newWriteToFunc().(d, 300*timescip-go gomod github.com/golang/go/src go1.21 time/.Millisecondscip-go gomod github.com/golang/go/src go1.21 time/Millisecond.), |
| 35 | }) |
| 36 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 37 | |
| 38 | st := timescip-go gomod github.com/golang/go/src go1.21 time/.Nowscip-go gomod github.com/golang/go/src go1.21 time/Now().() |
| 39 | |
| 40 | err = Walkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Walk().(contextscip-go gomod github.com/golang/go/src go1.21 context/.Backgroundscip-go gomod github.com/golang/go/src go1.21 context/Background().(), d, nil, readAsAddscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/readAsAdd().(dw.HandleChangescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DiskWriter#HandleChange().)) |
| 41 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 42 | |
| 43 | err = dw.Waitscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DiskWriter#Wait().(contextscip-go gomod github.com/golang/go/src go1.21 context/.TODOscip-go gomod github.com/golang/go/src go1.21 context/TODO().()) |
| 44 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 45 | |
| 46 | dt, err := osscip-go gomod github.com/golang/go/src go1.21 os/.ReadFilescip-go gomod github.com/golang/go/src go1.21 os/ReadFile().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(dest, "foo/foo3")) |
| 47 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 48 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, "data3", string(dt)) |
| 49 | |
| 50 | dt, err = osscip-go gomod github.com/golang/go/src go1.21 os/.ReadFilescip-go gomod github.com/golang/go/src go1.21 os/ReadFile().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(dest, "foo/foo4")) |
| 51 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 52 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, "data3", string(dt)) |
| 53 | |
| 54 | fi1, err := osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(dest, "foo/foo3")) |
| 55 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 56 | fi2, err := osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(dest, "foo/foo4")) |
| 57 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 58 | stat1, ok1 := fi1.Sysscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Sys().().(*syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.Stat_tscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#) |
| 59 | stat2, ok2 := fi2.Sysscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Sys().().(*syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.Stat_tscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#) |
| 60 | if ok1 && ok2 { |
| 61 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, stat1.Inoscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#Ino., stat2.Inoscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#Ino.) |
| 62 | } |
| 63 | |
| 64 | dt, err = osscip-go gomod github.com/golang/go/src go1.21 os/.ReadFilescip-go gomod github.com/golang/go/src go1.21 os/ReadFile().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(dest, "foo5")) |
| 65 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 66 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, "data5", string(dt)) |
| 67 | |
| 68 | duration := timescip-go gomod github.com/golang/go/src go1.21 time/.Sincescip-go gomod github.com/golang/go/src go1.21 time/Since().(st) |
| 69 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/True().(t, duration < 500*timescip-go gomod github.com/golang/go/src go1.21 time/.Millisecondscip-go gomod github.com/golang/go/src go1.21 time/Millisecond.) |
| 70 | } |
| 71 | |
| 72 | func TestWalkerWriterDevicesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestWalkerWriterDevices().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) { |
| 73 | requiresRootscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/requiresRoot().(t) |
| 74 | |
| 75 | d, err := tmpDirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/tmpDir().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{ |
| 76 | "ADD foo dir", |
| 77 | "ADD foo/foo1 file data1", |
| 78 | })) |
| 79 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 80 | |
| 81 | err = unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/.Mknodscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/Mknod().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(d, "foo/block"), syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.S_IFBLKscip-go gomod github.com/golang/go/src go1.21 syscall/S_IFBLK.|0600, mkdevscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/mkdev().(2, 3)) |
| 82 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 83 | |
| 84 | err = unixscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/.Mknodscip-go gomod golang.org/x/sys v0.11.0 `golang.org/x/sys/unix`/Mknod().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(d, "foo/char"), syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.S_IFCHRscip-go gomod github.com/golang/go/src go1.21 syscall/S_IFCHR.|0400, mkdevscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/mkdev().(1, 9)) |
| 85 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 86 | |
| 87 | dest := t.TempDirscip-go gomod github.com/golang/go/src go1.21 testing/common#TempDir().() |
| 88 | |
| 89 | dw, err := NewDiskWriterscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/NewDiskWriter().(contextscip-go gomod github.com/golang/go/src go1.21 context/.TODOscip-go gomod github.com/golang/go/src go1.21 context/TODO().(), dest, DiskWriterOptscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DiskWriterOpt#{ |
| 90 | SyncDataCbscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DiskWriterOpt#SyncDataCb.: newWriteToFuncscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/newWriteToFunc().(d, 0), |
| 91 | }) |
| 92 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 93 | |
| 94 | err = Walkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Walk().(contextscip-go gomod github.com/golang/go/src go1.21 context/.Backgroundscip-go gomod github.com/golang/go/src go1.21 context/Background().(), d, nil, readAsAddscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/readAsAdd().(dw.HandleChangescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DiskWriter#HandleChange().)) |
| 95 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 96 | |
| 97 | err = dw.Waitscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DiskWriter#Wait().(contextscip-go gomod github.com/golang/go/src go1.21 context/.TODOscip-go gomod github.com/golang/go/src go1.21 context/TODO().()) |
| 98 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 99 | |
| 100 | fi, err := osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(dest, "foo/char")) |
| 101 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 102 | |
| 103 | stat, ok := fi.Sysscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Sys().().(*syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.Stat_tscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#) |
| 104 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/True().(t, ok) |
| 105 | |
| 106 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, uint64(1), stat.Rdevscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#Rdev.>>8) |
| 107 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, uint64(9), stat.Rdevscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#Rdev.&0xff) |
| 108 | |
| 109 | fi, err = osscip-go gomod github.com/golang/go/src go1.21 os/.Lstatscip-go gomod github.com/golang/go/src go1.21 os/Lstat().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(dest, "foo/block")) |
| 110 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 111 | |
| 112 | stat, ok = fi.Sysscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Sys().().(*syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.Stat_tscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#) |
| 113 | requirescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/require`/True().(t, ok) |
| 114 | |
| 115 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, uint64(2), stat.Rdevscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#Rdev.>>8) |
| 116 | assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Equal().(t, uint64(3), stat.Rdevscip-go gomod github.com/golang/go/src go1.21 syscall/Stat_t#Rdev.&0xff) |
| 117 | } |