1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
12 "git.arvados.org/arvados.git/sdk/go/arvados"
13 "git.arvados.org/arvados.git/sdk/go/arvadosclient"
14 "git.arvados.org/arvados.git/sdk/go/arvadostest"
15 "git.arvados.org/arvados.git/sdk/go/ctxlog"
16 "git.arvados.org/arvados.git/sdk/go/keepclient"
17 "github.com/arvados/cgofuse/fuse"
21 // Gocheck boilerplate
22 func Test(t *testing.T) {
26 var _ = Suite(&FSSuite{})
32 func (s *FSSuite) SetUpTest(c *C) {
33 client := arvados.NewClientFromEnv()
34 ac, err := arvadosclient.New(client)
36 kc, err := keepclient.MakeKeepClient(ac)
41 Logger: ctxlog.TestLogger(c),
46 func (s *FSSuite) TestFuseInterface(c *C) {
47 var _ fuse.FileSystemInterface = s.fs
50 func (s *FSSuite) TestOpendir(c *C) {
51 errc, fh := s.fs.Opendir("/by_id")
52 c.Check(errc, Equals, 0)
53 c.Check(fh, Not(Equals), uint64(0))
54 c.Check(fh, Not(Equals), invalidFH)
55 errc, fh = s.fs.Opendir("/bogus")
56 c.Check(errc, Equals, -fuse.ENOENT)
57 c.Check(fh, Equals, invalidFH)
60 func (s *FSSuite) TestMknod_ReadOnly(c *C) {
62 path := "/by_id/" + arvadostest.FooCollection + "/z"
63 errc := s.fs.Mknod(path, syscall.S_IFREG, 0)
64 c.Check(errc, Equals, -fuse.EROFS)
67 func (s *FSSuite) TestMknod(c *C) {
68 path := "/by_id/" + arvadostest.FooCollection + "/z"
69 _, err := s.fs.root.Stat(path)
70 c.Assert(err, Equals, os.ErrNotExist)
72 // Should return error if mode indicates unsupported file type
73 for _, mode := range []uint32{
79 errc := s.fs.Mknod(path, mode, 0)
80 c.Check(errc, Equals, -fuse.ENOSYS)
81 _, err := s.fs.root.Stat(path)
82 c.Check(err, Equals, os.ErrNotExist)
85 // Should create file and return 0 if mode indicates regular
87 errc := s.fs.Mknod(path, syscall.S_IFREG|0o644, 0)
88 c.Check(errc, Equals, 0)
89 _, err = s.fs.root.Stat(path)
92 // Special case: "Zero file type is equivalent to type
93 // S_IFREG." cf. mknod(2)
94 errc = s.fs.Mknod(path+"2", 0o644, 0)
95 c.Check(errc, Equals, 0)
96 _, err = s.fs.root.Stat(path + "2")
99 // Should return error if target exists
100 errc = s.fs.Mknod(path, syscall.S_IFREG|0o644, 0)
101 c.Check(errc, Equals, -fuse.EEXIST)