MCPcopy Index your code
hub / github.com/kopia/kopia / TestSparseCopy

Function TestSparseCopy

internal/sparsefile/sparsefile_test.go:15–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestSparseCopy(t *testing.T) {
16 t.Parallel()
17
18 if runtime.GOOS == "windows" {
19 t.Skip("sparse files are not supported on windows")
20 }
21
22 dir := t.TempDir()
23
24 blk, err := stat.GetBlockSize(dir)
25 require.NoError(t, err)
26
27 type chunk struct {
28 slice []byte
29 off uint64
30 rep uint64
31 }
32
33 cases := []struct {
34 name string
35 size uint64
36 data []chunk
37 }{
38 {
39 name: "null",
40 size: 0,
41 },
42 {
43 name: "empty",
44 size: blk,
45 data: []chunk{
46 {slice: []byte{0}, off: 0, rep: blk},
47 },
48 },
49 {
50 name: "hole",
51 size: 2 * blk,
52 data: []chunk{
53 {slice: []byte{1}, off: blk, rep: blk},
54 },
55 },
56 {
57 name: "mix",
58 size: 2 * blk,
59 data: []chunk{
60 {slice: []byte{1}, off: 3, rep: blk - 10},
61 {slice: []byte{1}, off: 2*blk - 10, rep: 10},
62 },
63 },
64 }
65
66 for _, c := range cases {
67 src := filepath.Join(dir, "src"+c.name)
68 dst := filepath.Join(dir, "dst"+c.name)
69
70 sf, err := os.Create(src)
71 if err != nil {
72 t.Fatal(err)

Callers

nothing calls this directly

Calls 5

GetBlockSizeFunction · 0.92
RepeatMethod · 0.80
FatalfMethod · 0.80
EqualMethod · 0.80
CopyFunction · 0.70

Tested by

no test coverage detected