mirror of
https://github.com/restic/restic.git
synced 2026-10-13 05:27:13 +00:00
1 parent
a7786c67f1
commit
cb5694d136
5 files changed
+46
-3
No files matched your search
@@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -216,6 +217,37 @@ func testTopUIDGID(t *testing.T, cfg Config, repo restic.Repository, uid, gid ui
|
||||
rtest.Equals(t, uint32(0), attr.Gid)
|
||||
}
|
||||
|
||||
// Test reporting of fuse.Attr.Blocks in multiples of 512.
|
||||
func TestBlocks(t *testing.T) {
|
||||
root := &Root{}
|
||||
|
||||
for _, c := range []struct {
|
||||
size, blocks uint64
|
||||
}{
|
||||
{0, 0},
|
||||
{1, 1},
|
||||
{511, 1},
|
||||
{512, 1},
|
||||
{513, 2},
|
||||
{1024, 2},
|
||||
{1025, 3},
|
||||
{41253, 81},
|
||||
} {
|
||||
target := strings.Repeat("x", int(c.size))
|
||||
|
||||
for _, n := range []fs.Node{
|
||||
&file{root: root, node: &restic.Node{Size: uint64(c.size)}},
|
||||
&link{root: root, node: &restic.Node{LinkTarget: target}},
|
||||
&snapshotLink{root: root, snapshot: &restic.Snapshot{}, target: target},
|
||||
} {
|
||||
var a fuse.Attr
|
||||
err := n.Attr(context.TODO(), &a)
|
||||
rtest.OK(t, err)
|
||||
rtest.Equals(t, c.blocks, a.Blocks)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInodeFromNode(t *testing.T) {
|
||||
node := &restic.Node{Name: "foo.txt", Type: "chardev", Links: 2}
|
||||
ino1 := inodeFromNode(1, node)
|
||||
|
||||
Reference in new issue
Block a user