def _try_unknown(t, c, path): ops = c.use_obj(path) + [c.getattr([1000])] res = c.compound(ops) check(res, msg="GETTATTR with unknown attr") attrs = fattr2dict(res.resarray[-1].arm.arm.obj_attributes) if attrs: t.fail("GETTATTR with unknown attr returned %s" % str(attrs))
def _try_empty(t, c, path): ops = c.use_obj(path) + [c.getattr([])] res = c.compound(ops) check(res, msg="GETTATTR with empty attr list") attrs = fattr2dict(res.resarray[-1].arm.arm.obj_attributes) if attrs: t.fail("GETTATTR with empty attr list returned %s" % str(attrs))
def _try_long(env, path): c = env.c1 all = [attr.bitnum for attr in env.attr_info if not attr.writeonly] ops = c.use_obj(path) + [c.getattr(all)] res = c.compound(ops) check(res, msg="Asking for all legal attributes") # Force unpack of data to make sure no corruption attrs = fattr2dict(res.resarray[-1].arm.arm.obj_attributes)
def _try_mandatory(t, env, path): c = env.c1 mandatory = [attr.bitnum for attr in env.attr_info if attr.mandatory] ops = c.use_obj(path) ops += [c.getattr(mandatory)] res = c.compound(ops) check(res) attrs = fattr2dict(res.resarray[-1].arm.arm.obj_attributes) unsupp = [] for attr in mandatory: if attr not in attrs: attrname = get_bitnumattr_dict()[attr] unsupp += [attrname] if unsupp: t.fail("Mandatory attribute(s) %s not supported" % 'and'.join(unsupp))
def testFSLocations(t, env): """GETATTR on FSLocations FLAGS: getattr fslocations all DEPEND: LOOKFILE CODE: GATT8 """ c = env.c1 ops = c.use_obj(env.opts.usefile) ops += [c.getattr([FATTR4_FS_LOCATIONS])] res = c.compound(ops) checklist(res, [NFS4_OK, NFS4ERR_ATTRNOTSUPP], "GETATTR(fs_locations)") if res.status == NFS4ERR_ATTRNOTSUPP: t.fail_support("fs_locations not a supported attribute") raw_attrs = res.resarray[-1].arm.arm.obj_attributes d = fattr2dict(raw_attrs) print d #################################################### def xxxtestMountedOnFileid(self): """GETATTR(FATTR4_MOUNTED_ON_FILEID) This DOES NOT work on standard test tree. It assumes that pseudofs root / and pseudo fs node /unix exist, and that /unix is a mountpoint of an exported file system. The fsid of "/" should differ from the fsid of "/unix", and the mounted_on_fileid should != the filed with both the Getattr of "/unix" and the Readdir of "/". """ request = [FATTR4_MOUNTED_ON_FILEID, FATTR4_FILEID, FATTR4_FSID] lookupops = [self.ncl.lookup_op("unix")] ops = [self.ncl.putrootfh_op()] ops.append(self.ncl.getattr(request)) ops += lookupops ops.append(self.ncl.getattr(request)) res = self.ncl.do_ops(ops) self.assert_OK(res) obj = res.resarray[-3].arm.arm.obj_attributes d = nfs4lib.fattr2dict(obj) print print "From Getattr / - ", d obj = res.resarray[-1].arm.arm.obj_attributes d = nfs4lib.fattr2dict(obj) print print "From Getattr /unix - ", d ops = [self.ncl.putrootfh_op()] attrmask = nfs4lib.list2attrmask(request) ops.append(self.ncl.readdir(attr_request=attrmask)) res = self.ncl.do_ops(ops) self.assert_OK(res) # Find 'user' (note this assumes dir listing is small enough that # the whole listing was returned) reply = res.resarray[-1].arm.arm.reply entry = reply.entries[0] while 1: if entry.name == "unix": break if not entry.nextentry: self.fail("Could not find mountpoint /unix") entry = entry.nextentry[0] d2 = nfs4lib.fattr2dict(entry.attrs) print "From Readdir / - ", d2
def testFSLocations(t, env): """GETATTR on FSLocations FLAGS: getattr fslocations all DEPEND: LOOKFILE CODE: GATT8 """ c = env.c1 ops = c.use_obj(env.opts.usefile) ops += [c.getattr([FATTR4_FS_LOCATIONS])] res = c.compound(ops) checklist(res, [NFS4_OK, NFS4ERR_ATTRNOTSUPP], "GETATTR(fs_locations)") if res.status == NFS4ERR_ATTRNOTSUPP: t.fail_support("fs_locations not a supported attribute") raw_attrs = res.resarray[-1].arm.arm.obj_attributes d = fattr2dict(raw_attrs) print d #################################################### def xxxtestMountedOnFileid(self): """GETATTR(FATTR4_MOUNTED_ON_FILEID) This DOES NOT work on standard test tree. It assumes that pseudofs root / and pseudo fs node /unix exist, and that /unix is a mountpoint of an exported file system. The fsid of "/" should differ from the fsid of "/unix", and the mounted_on_fileid should != the filed with both the Getattr of "/unix" and the Readdir of "/". """ request = [FATTR4_MOUNTED_ON_FILEID, FATTR4_FILEID, FATTR4_FSID] lookupops = [self.ncl.lookup_op("unix")] ops = [self.ncl.putrootfh_op()] ops.append(self.ncl.getattr(request)) ops += lookupops ops.append(self.ncl.getattr(request)) res = self.ncl.do_ops(ops) self.assert_OK(res) obj = res.resarray[-3].arm.arm.obj_attributes d = nfs4lib.fattr2dict(obj) print print "From Getattr / - ",d obj = res.resarray[-1].arm.arm.obj_attributes d = nfs4lib.fattr2dict(obj) print print "From Getattr /unix - ",d ops = [self.ncl.putrootfh_op()] attrmask = nfs4lib.list2attrmask(request) ops.append(self.ncl.readdir(attr_request=attrmask)) res = self.ncl.do_ops(ops) self.assert_OK(res) # Find 'user' (note this assumes dir listing is small enough that # the whole listing was returned) reply = res.resarray[-1].arm.arm.reply entry = reply.entries[0] while 1: if entry.name=="unix": break if not entry.nextentry: self.fail("Could not find mountpoint /unix") entry = entry.nextentry[0] d2 = nfs4lib.fattr2dict(entry.attrs) print "From Readdir / - ",d2