Debian Codegraph @

test/nfstest_xattr

raw
1 #!/usr/bin/env python3
2 #===============================================================================
3 # Copyright 2022 NetApp, Inc. All Rights Reserved,
4 # contribution by Jorge Mora <[email protected]>
5 #
6 # This program is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 2 of the License, or (at your option) any later
9 # version.
10 #
11 # This program is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 #===============================================================================
15 import os
16 import re
17 import errno
18 import traceback
19 import nfstest_config as c
20 from baseobj import BaseObj
21 from formatstr import crc32
22 from packet.nfs.nfs4_const import *
23 from nfstest.test_util import TestUtil
24
25 # Module constants
26 __author__ = "Jorge Mora (%s)" % c.NFSTEST_AUTHOR_EMAIL
27 __copyright__ = "Copyright (C) 2022 NetApp, Inc."
28 __license__ = "GPL v2"
29 __version__ = "1.1"
30
31 USAGE = """%prog --server <server> [options]
32
33 Extended Attributes tests
34 =========================
35 Verify correct functionality of extended attributes
36
37 Extended attributes are name:value pairs associated permanently with files
38 and directories, similar to the environment strings associated with a
39 process. An attribute may be defined or undefined. If it is defined, its
40 value may be empty or non-empty. Extended attributes are extensions to the
41 normal attributes which are associated with all inodes in the system. They
42 are often used to provide additional functionality to a filesystem.
43
44 Tests are divided into five groups: getxattr, setxattr, removexattr,
45 listxattr and cinfo. The getxattr tests verify the retrieval of extended
46 attribute values. The setxattr tests verify the creation or modification
47 of extended attributes. The removexattr tests verify the removal of
48 extended attributes. The listxattr tests verify the listing of extended
49 attributes. And finally, the cinfo tests verify the change info returned
50 by the server is correct when the file is either modified or not from a
51 different client.
52
53 Furthermore, when a different client is holding a read delegation, verify
54 the delegation is recalled only when creating, modifying or removing an
55 extended attribute. On the other hand, verify the read delegation is not
56 recalled when listing attributes or retrieving their values.
57
58 Negative testing is included like retrieval or removal of an extended
59 attribute name which does not exist. Creating an attribute which already
60 exists should fail while using XATTR_CREATE flag. Trying to modify an
61 attribute which does not exist should fail if using XATTR_REPLACE flag.
62
63 Examples:
64 The only required option is --server
65 $ %prog --server 192.168.0.11
66
67 Notes:
68 The user id in the local host and the host specified by --client must
69 have access to run commands as root using the 'sudo' command without
70 the need for a password.
71
72 The user id must be able to 'ssh' to remote host without the need for
73 a password.
74
75 Valid only for NFS version 4.2 and above."""
76
77 # Test script ID
78 SCRIPT_ID = "XATTR"
79
80 # Test group flags
81 GROUP_GETXATTR = (1 << 0)
82 GROUP_SETXATTR = (1 << 1)
83 GROUP_REMOVEXATTR = (1 << 2)
84 GROUP_LISTXATTRS = (1 << 3)
85 GROUP_CINFO = (1 << 4)
86 GROUP_LIMIT = (1 << 5)
87 GROUP_NOXATTRS = (1 << 6)
88 GROUP_MANYXATTRS = (1 << 7)
89 GROUP_NODELEG = (1 << 8)
90 GROUP_DELEG = (1 << 9)
91 GROUP_NOMODIFY = (1 << 10)
92 GROUP_MODIFY = (1 << 11)
93
94 TESTNAMES_ALL = [
95 ( "ngetxattr01", GROUP_GETXATTR|GROUP_NODELEG ),
96 ( "ngetxattr02", GROUP_GETXATTR|GROUP_NODELEG ),
97 ( "dgetxattr01", GROUP_GETXATTR|GROUP_DELEG ),
98 ( "dgetxattr02", GROUP_GETXATTR|GROUP_DELEG ),
99 ( "nsetxattr01", GROUP_SETXATTR|GROUP_NODELEG ),
100 ( "nsetxattr02", GROUP_SETXATTR|GROUP_NODELEG ),
101 ( "nsetxattr03", GROUP_SETXATTR|GROUP_NODELEG ),
102 ( "nsetxattr04", GROUP_SETXATTR|GROUP_NODELEG ),
103 ( "nsetxattr05", GROUP_SETXATTR|GROUP_NODELEG ),
104 ( "nsetxattr06", GROUP_SETXATTR|GROUP_NODELEG ),
105 ( "dsetxattr01", GROUP_SETXATTR|GROUP_DELEG ),
106 ( "dsetxattr02", GROUP_SETXATTR|GROUP_DELEG ),
107 ( "dsetxattr03", GROUP_SETXATTR|GROUP_DELEG ),
108 ( "dsetxattr04", GROUP_SETXATTR|GROUP_DELEG ),
109 ( "dsetxattr05", GROUP_SETXATTR|GROUP_DELEG ),
110 ( "dsetxattr06", GROUP_SETXATTR|GROUP_DELEG ),
111 ( "nremovexattr01", GROUP_REMOVEXATTR|GROUP_NODELEG ),
112 ( "nremovexattr02", GROUP_REMOVEXATTR|GROUP_NODELEG ),
113 ( "dremovexattr01", GROUP_REMOVEXATTR|GROUP_DELEG ),
114 ( "dremovexattr02", GROUP_REMOVEXATTR|GROUP_DELEG ),
115 ( "nlistxattr01", GROUP_LISTXATTRS|GROUP_NODELEG|GROUP_NOXATTRS ),
116 ( "nlistxattr02", GROUP_LISTXATTRS|GROUP_NODELEG ),
117 ( "nlistxattr03", GROUP_LISTXATTRS|GROUP_NODELEG|GROUP_MANYXATTRS ),
118 ( "dlistxattr01", GROUP_LISTXATTRS|GROUP_DELEG|GROUP_NOXATTRS ),
119 ( "dlistxattr02", GROUP_LISTXATTRS|GROUP_DELEG ),
120 ( "dlistxattr03", GROUP_LISTXATTRS|GROUP_DELEG|GROUP_MANYXATTRS ),
121 ( "ncinfo01", GROUP_CINFO|GROUP_NOMODIFY ),
122 ( "ncinfo02", GROUP_CINFO|GROUP_NOMODIFY ),
123 ( "ncinfo03", GROUP_CINFO|GROUP_NOMODIFY ),
124 ( "ncinfo04", GROUP_CINFO|GROUP_NOMODIFY ),
125 ( "mcinfo01", GROUP_CINFO|GROUP_MODIFY ),
126 ( "mcinfo02", GROUP_CINFO|GROUP_MODIFY ),
127 ( "mcinfo03", GROUP_CINFO|GROUP_MODIFY ),
128 ( "mcinfo04", GROUP_CINFO|GROUP_MODIFY ),
129 ]
130
131 TESTNAMES_DICT = dict(TESTNAMES_ALL)
132
133 def group_test(tname, group):
134 """Return True if test belongs to the given group"""
135 testgroup = TESTNAMES_DICT.get(tname)
136 if testgroup is not None and (testgroup & group) == group:
137 return True
138 return False
139
140 def group_list(group):
141 """Return a list of all tests belonging to the given group"""
142 return [x[0] for x in TESTNAMES_ALL if group_test(x[0], group)]
143
144 TESTNAMES_GETXATTR = group_list(GROUP_GETXATTR)
145 TESTNAMES_NGETXATTR = group_list(GROUP_GETXATTR|GROUP_NODELEG)
146 TESTNAMES_DGETXATTR = group_list(GROUP_GETXATTR|GROUP_DELEG)
147 TESTNAMES_SETXATTR = group_list(GROUP_SETXATTR)
148 TESTNAMES_NSETXATTR = group_list(GROUP_SETXATTR|GROUP_NODELEG)
149 TESTNAMES_DSETXATTR = group_list(GROUP_SETXATTR|GROUP_DELEG)
150 TESTNAMES_REMOVEXATTR = group_list(GROUP_REMOVEXATTR)
151 TESTNAMES_NREMOVEXATTR = group_list(GROUP_REMOVEXATTR|GROUP_NODELEG)
152 TESTNAMES_DREMOVEXATTR = group_list(GROUP_REMOVEXATTR|GROUP_DELEG)
153 TESTNAMES_LISTXATTRS = group_list(GROUP_LISTXATTRS)
154 TESTNAMES_NLISTXATTRS = group_list(GROUP_LISTXATTRS|GROUP_NODELEG)
155 TESTNAMES_DLISTXATTRS = group_list(GROUP_LISTXATTRS|GROUP_DELEG)
156 TESTNAMES_CINFO = group_list(GROUP_CINFO)
157 TESTNAMES_NCINFO = group_list(GROUP_CINFO|GROUP_NOMODIFY)
158 TESTNAMES_MCINFO = group_list(GROUP_CINFO|GROUP_MODIFY)
159
160 # Include the test groups in the list of test names
161 # so they are displayed in the help
162 TESTNAMES = TESTNAMES_GETXATTR + \
163 TESTNAMES_SETXATTR + \
164 TESTNAMES_REMOVEXATTR + \
165 TESTNAMES_LISTXATTRS + \
166 TESTNAMES_CINFO + \
167 ["getxattr", "ngetxattr", "dgetxattr"] + \
168 ["setxattr", "nsetxattr", "dsetxattr"] + \
169 ["removexattr", "nremovexattr", "dremovexattr"] + \
170 ["listxattr", "nlistxattr", "dlistxattr"] + \
171 ["cinfo", "ncinfo", "mcinfo"]
172
173 TESTGROUPS = {
174 "getxattr": {
175 "tests": TESTNAMES_GETXATTR,
176 "desc": "Run all GETXATTR tests: ",
177 },
178 "ngetxattr": {
179 "tests": TESTNAMES_NGETXATTR,
180 "desc": "Run all GETXATTR tests when no open on second client: ",
181 },
182 "dgetxattr": {
183 "tests": TESTNAMES_DGETXATTR,
184 "desc": "Run all GETXATTR tests when delegation is granted on second client: ",
185 },
186 "setxattr": {
187 "tests": TESTNAMES_SETXATTR,
188 "desc": "Run all SETXATTR tests: ",
189 },
190 "nsetxattr": {
191 "tests": TESTNAMES_NSETXATTR,
192 "desc": "Run all SETXATTR tests when no open on second client: ",
193 },
194 "dsetxattr": {
195 "tests": TESTNAMES_DSETXATTR,
196 "desc": "Run all SETXATTR tests when delegation is granted on second client: ",
197 },
198 "removexattr": {
199 "tests": TESTNAMES_REMOVEXATTR,
200 "desc": "Run all REMOVEXATTR tests: ",
201 },
202 "nremovexattr": {
203 "tests": TESTNAMES_NREMOVEXATTR,
204 "desc": "Run all REMOVEXATTR tests when no open on second client: ",
205 },
206 "dremovexattr": {
207 "tests": TESTNAMES_DREMOVEXATTR,
208 "desc": "Run all REMOVEXATTR tests when delegation is granted on second client: ",
209 },
210 "listxattr": {
211 "tests": TESTNAMES_LISTXATTRS,
212 "desc": "Run all LISTXATTRS tests: ",
213 },
214 "nlistxattr": {
215 "tests": TESTNAMES_NLISTXATTRS,
216 "desc": "Run all LISTXATTRS tests when no open on second client: ",
217 },
218 "dlistxattr": {
219 "tests": TESTNAMES_DLISTXATTRS,
220 "desc": "Run all LISTXATTRS tests when delegation is granted on second client: ",
221 },
222 "cinfo": {
223 "tests": TESTNAMES_CINFO,
224 "desc": "Run all CINFO tests: ",
225 },
226 "ncinfo": {
227 "tests": TESTNAMES_NCINFO,
228 "desc": "Run all CINFO tests when no open on second client: ",
229 },
230 "mcinfo": {
231 "tests": TESTNAMES_MCINFO,
232 "desc": "Run all CINFO tests when file is modified on second client: ",
233 },
234 }
235
236 stype_map = {
237 0 : SETXATTR4_EITHER,
238 os.XATTR_CREATE : SETXATTR4_CREATE,
239 os.XATTR_REPLACE : SETXATTR4_REPLACE,
240 }
241
242 class XATTRTest(TestUtil):
243 """XATTRTest object
244
245 XATTRTest() -> New test object
246
247 Usage:
248 x = XATTRTest(testnames=["intra01", "intra02", "intra03", ...])
249
250 # Run all the tests
251 x.run_tests()
252 x.exit()
253 """
254 def __init__(self, **kwargs):
255 """Constructor
256
257 Initialize object's private data.
258 """
259 # Instantiate base object constructor
260 TestUtil.__init__(self, **kwargs)
261 self.opts.version = "%prog " + __version__
262 # Tests are valid for NFSv4.2 and beyond
263 self.opts.set_defaults(nfsversion=4.2)
264 hhelp = "Number of extended attributes to create for listxattr tests " \
265 "with many attributes [default: %default]"
266 self.test_opgroup.add_option("--num-xattrs", type="int", default=20, help=hhelp)
267 hhelp = "Remote NFS client and options used for delegation tests. " \
268 "Clients are separated by a ',' and each client definition is " \
269 "a list of arguments separated by a ':' given in the following " \
270 "order if positional arguments is used (see examples): " \
271 "clientname:server:export:nfsversion:port:proto:sec:mtpoint " \
272 "[default: '%default']"
273 self.test_opgroup.add_option("--client", default='nfsversion=3:proto=tcp:port=2049', help=hhelp)
274 hhelp = "Comma separated list of valid NFS versions to use in the " \
275 "--client option. An NFS version from this list, which is " \
276 "different than that given by --nfsversion, is selected and " \
277 "included in the --client option [default: %default]"
278 self.test_opgroup.add_option("--client-nfsvers", default="4.0,4.1", help=hhelp)
279
280 self.scan_options()
281
282 self.xattrbase = "user.xattr"
283 self.xattrdidx = {}
284 self.dgfileidx = 1
285 self.removeidx = 2
286 self.mxattridx = 0
287
288 self.xattrname = ""
289 self.xattr_values = {}
290 self.name_fh = {}
291
292 # Disable createtraces option but save it first for tests that do not
293 # check the NFS packets to verify the assertion
294 self._createtraces = self.createtraces
295 self.createtraces = False
296
297 # Process the --client option
298 client_list = self.process_client_option(remote=None)
299 if self.client_nfsvers is not None:
300 nfsvers_list = self.str_list(self.client_nfsvers)
301 for client_args in client_list:
302 if self.proto[-1] == "6" and len(client_args.get("proto")) and client_args["proto"][-1] != 6:
303 client_args["proto"] += "6"
304 for nfsver in nfsvers_list:
305 if nfsver != self.nfsversion:
306 client_args["nfsversion"] = nfsver
307 break
308 else:
309 self.opts.error("At least one NFS version in --client-nfsvers '%s' " \
310 "must be different then --nfsversion %s" % \
311 (self.client_nfsvers, self.nfsversion))
312
313 # Start remote procedure server(s) remotely
314 try:
315 self.clientobj = None
316 for client_args in client_list:
317 client_name = client_args.pop("client", "")
318 self.create_host(client_name, **client_args)
319 self.create_rexec(client_name)
320 except:
321 self.test(False, traceback.format_exc())
322
323 def get_findex(self):
324 """Return index for last file created with create_file()"""
325 return (len(self.files) - 1)
326
327 def setup(self):
328 """Setup test environment"""
329 self.dprint('DBG7', "SETUP starts")
330 self.kofileidx = 0 # Index so open owner sticks around
331 self.noxattridx = 0 # Index for file with no extended attributes
332 self.xattridx = 1 # Index for file with extended attributes
333
334 run_tests = set(self.testlist)
335 deleg_list = set(group_list(GROUP_DELEG))
336 deleg_tests = run_tests & deleg_list
337 nodeleg_tests = run_tests - deleg_list
338
339 nremove = 0
340 nmxattr = 0
341 for tname in self.testlist:
342 if group_test(tname, GROUP_REMOVEXATTR|GROUP_NODELEG):
343 nremove += 1
344 elif group_test(tname, GROUP_MANYXATTRS|GROUP_NODELEG):
345 nmxattr = 1
346
347 try:
348 self.trace_start()
349 self.mount()
350
351 if deleg_tests:
352 # Create file so open owner sticks around
353 self.create_file()
354 self.kofileidx = self.get_findex()
355
356 if nodeleg_tests:
357 # Create files for non-deleg tests
358 self.create_file()
359 self.noxattridx = self.get_findex()
360 self.create_file()
361 self.xattridx = self.get_findex()
362 for i in range(1 + nremove):
363 self.set_xattr(self.filename, indent=4)
364
365 if nmxattr:
366 self.create_file()
367 self.mxattridx = self.get_findex()
368 for i in range(self.num_xattrs):
369 self.set_xattr(self.filename, indent=4)
370
371 # File index for deleg tests
372 self.dgfileidx = self.get_findex() + 1
373
374 for tname in self.testlist:
375 if group_test(tname, GROUP_DELEG):
376 # Need a different file for each test having a delegation
377 self.create_file()
378 if group_test(tname, GROUP_MANYXATTRS):
379 nxattrs = self.num_xattrs
380 elif group_test(tname, GROUP_NOXATTRS):
381 nxattrs = 0
382 elif group_test(tname, GROUP_REMOVEXATTR):
383 # Make sure there is one xattr left after the remove
384 nxattrs = 2
385 else:
386 nxattrs = 1
387 for i in range(nxattrs):
388 self.set_xattr(self.filename, indent=4)
389 finally:
390 self.umount()
391 self.trace_stop()
392 self.trace_open()
393 self.pktt.close()
394
395 self.dprint('DBG7', "SETUP done")
396
397 def set_xattr(self, filename, name=None, value=None, stype=0, indent=0, xmsg=""):
398 """Create extended attribute on the file"""
399 absfile = self.abspath(filename)
400 if name is None:
401 # No name given so create a unique name
402 idx = self.xattrdidx.setdefault(filename, 1)
403 name = "%s%02d" % (self.xattrbase, idx)
404 self.xattrdidx[filename] += 1
405 else:
406 # Use an arbitrary attribute index for named xattrs so the
407 # contents are different for all attributes
408 idx = 4096 + self.xattrdidx.setdefault(filename, 1)
409 self.xattrname = name
410 if value is None:
411 # Contents for the extended attribute are based on the index
412 value = self.data_pattern((idx-1)*32, 32)
413
414 self.xattr_values[name] = value
415
416 # Create extended attribute
417 indentstr = " " * indent
418 self.dprint('DBG1', "%sSet extended attribute [%s] for %r%s" % (indentstr, name, absfile, xmsg))
419 os.setxattr(absfile, name, value, flags=stype)
420 return name
421
422 def get_deleg_remote(self, filename):
423 """Get a read delegation on the remote client."""
424 fdko = None
425 absfile = self.clientobj.abspath(filename)
426 if self.clientobj and self.clientobj.nfs_version < 4:
427 # There are no delegations in NFSv3 so there is no need
428 # to open a file so the open owner sticks around
429 self.dprint("DBG2", "Open file on the remote client [%s]" % absfile)
430 else:
431 # Open file so open owner sticks around so a delegation
432 # is granted when opening the file under test
433 fdko = self.rexecobj.run(os.open, self.clientobj.abspath(self.files[self.kofileidx]), os.O_RDONLY)
434 self.dprint("DBG2", "Get a read delegation on the remote client [%s]" % absfile)
435 # Open the file under test
436 fdrd = self.rexecobj.run(os.open, absfile, os.O_RDONLY)
437 self.dprint("DBG4", "Close %s on the remote client" % absfile)
438 self.rexecobj.run(os.close, fdrd)
439 if fdko is not None:
440 self.rexecobj.run(os.close, fdko)
441
442 def get_filehandles(self):
443 """Create mapping of file handles to file names"""
444 self.name_fh = {}
445 matchstr = self.match_nfs_version(self.nfs_version)
446 matchstr += "nfs.argop in %s" % ((OP_LOOKUP, OP_OPEN, OP_PUTROOTFH),)
447 self.pktt.clear_xid_list()
448 while self.pktt.match(matchstr, reply=True, rewind=False):
449 pkt = self.pktt.pkt
450 if pkt.rpc.type == 1 and pkt.nfs.status == NFS4_OK:
451 pkt_call = self.pktt.pkt_call
452 fh = getattr(self.getop(pkt, OP_GETFH), "fh", None)
453 if pkt_call.NFSop.op == OP_PUTROOTFH:
454 self.name_fh["/"] = fh
455 else:
456 self.name_fh[pkt_call.NFSop.name] = fh
457 self.pktt.rewind()
458
459 def get_assertion(self, failure, error, amsg=""):
460 """Return correct fail message when expecting an error"""
461 errstr = errno.errorcode.get(failure, "success")
462 errnostr = errno.errorcode.get(error, error)
463 # Assertion expression
464 expr = (failure == error)
465 # Set proper fail message
466 if error and failure:
467 fmsg = ", but got %s" % errnostr
468 elif error and not failure:
469 fmsg = ", expecting success but got %s" % errnostr
470 elif failure:
471 fmsg = ", but it succeeded"
472 else:
473 fmsg = ""
474
475 if failure:
476 # If expecting a failure, change the assertion message
477 amsg = "fail with %s" % errstr
478 return expr, amsg, fmsg
479
480 def verify_xattr_call(self, pkt, opcode, opstr, fh, ename=None, stype=0, cookie=0):
481 """Verify Packet Call"""
482 callobj = pkt.NFSop
483 ename = self.xattrname if ename is None else ename
484
485 self.test(pkt, "%s call should be sent to server" % opstr)
486 expr = (fh == callobj.fh)
487 fmsg = ", expecting 0x%08x but got 0x%08x" % (crc32(fh), crc32(callobj.fh))
488 self.test(expr, "%s call should be sent with correct file handle" % opstr, failmsg=fmsg)
489
490 if opcode == OP_LISTXATTRS:
491 expr = (callobj.cookie == cookie)
492 fmsg = ", expecting %d but got %d" % (cookie, callobj.cookie)
493 self.test(expr, "%s call should be sent with correct cookie" % opstr, failmsg=fmsg)
494 expr = (callobj.maxcount > 0)
495 fmsg = ", expecting > %d but got %d" % (0, callobj.maxcount)
496 self.test(expr, "%s call should be sent with correct maxcount" % opstr, failmsg=fmsg)
497 elif opcode in (OP_GETXATTR, OP_SETXATTR, OP_REMOVEXATTR):
498 xname = ename.replace("user.", "")
499 expr = (callobj.name == xname)
500 fmsg = ", expecting %r but got %r" % (xname, callobj.name)
501 self.test(expr, "%s call should be sent with correct attribute name" % opstr, failmsg=fmsg)
502 if opcode == OP_SETXATTR:
503 xvalue = self.xattr_values.get(ename)
504 expr = (callobj.value == xvalue)
505 fmsg = ", expecting %r but got %r" % (xvalue, callobj.value)
506 self.test(expr, "%s call should be sent with correct attribute value" % opstr, failmsg=fmsg)
507 xoption = stype_map.get(stype)
508 expr = (callobj.option == xoption)
509 fmsg = ", expecting %r but got %r" % (xoption, callobj.option)
510 self.test(expr, "%s call should be sent with correct option" % opstr, failmsg=fmsg)
511
512 def verify_xattr_reply(self, pkt, idx, opcode, opstr, estatus, ename=None, user_xattrs=[], cinfo=None, cinfodiff=False, emsg=""):
513 """Verify Packet Reply"""
514 self.test(pkt, "%s reply should be sent to client" % opstr)
515
516 ename = self.xattrname if ename is None else ename
517 replyobj = pkt.nfs.array[idx]
518 expr = (pkt.nfs.status == estatus)
519 estr = nfsstat4.get(estatus, estatus)
520 fmsg = ", but got %s" % pkt.nfs.status
521 self.test(expr, "%s reply should return %s%s" % (opstr, estr, emsg), failmsg=fmsg)
522
523 cookie = 0
524 if pkt.nfs.status == NFS4_OK:
525 if opcode == OP_LISTXATTRS:
526 cookie = replyobj.cookie
527 if len(user_xattrs) == 0:
528 expr = (len(replyobj.names) == 0)
529 fmsg = ", expecting %d but got %d" % (0, len(replyobj.names))
530 self.test(expr, "%s reply should return an empty list of attributes" % opstr, failmsg=fmsg)
531 expr = (cookie == 0)
532 fmsg = ", expecting %d but got %d" % (0, cookie)
533 self.test(expr, "%s reply should return cookie = 0 when no attributes are returned" % opstr, failmsg=fmsg)
534 else:
535 expr = (len(replyobj.names) > 0)
536 fmsg = ", expecting %d but got %d" % (0, len(replyobj.names))
537 self.test(expr, "%s reply should return list of attributes" % opstr, failmsg=fmsg)
538 if replyobj.eof:
539 expr = (cookie >= 0)
540 fmsg = ", expecting >= %d but got %d" % (0, cookie)
541 amsg = "%s reply should return any cookie when eof=True" % opstr
542 else:
543 expr = (cookie > 0)
544 fmsg = ", expecting > %d but got %d" % (0, cookie)
545 amsg = "%s reply should return a cookie > 0 when eof=False" % opstr
546 self.test(expr, amsg, failmsg=fmsg)
547 if len(user_xattrs) > len(replyobj.names):
548 beof = False
549 else:
550 beof = True
551 fmsg = ", expecting %s but got %s" % (beof, replyobj.eof)
552 self.test(replyobj.eof == beof, "%s reply should return eof=%s" % (opstr, beof), failmsg=fmsg)
553 elif opcode == OP_GETXATTR:
554 expr = (replyobj.value == self.xattr_values.get(ename))
555 self.test(expr, "%s reply should return correct attribute value" % opstr)
556 elif opcode in (OP_SETXATTR, OP_REMOVEXATTR):
557 expr = (replyobj.info.before != replyobj.info.after)
558 amsg = "%s reply should return correct change info" % opstr
559 if not expr:
560 fmsg = ", expecting before(%s) != after(%s)" % (replyobj.info.before, replyobj.info.after)
561 elif cinfo is not None:
562 self.dprint('DBG2', str(replyobj.info))
563 if cinfo > 0:
564 if cinfodiff:
565 expr = (expr and (replyobj.info.before != cinfo))
566 amsg += " [the file has been modified]"
567 fmsg = ", expecting <before> != %s" % cinfo
568 else:
569 expr = (expr and (replyobj.info.before == cinfo))
570 fmsg = ", expecting before(%s) but got %s" % (cinfo, replyobj.info.before)
571 self.test(expr, amsg, failmsg=fmsg)
572 return cookie
573
574 def verify_xattr_support(self):
575 """Verify extended attributes are supported in the server"""
576 matchstr = "nfs.argop == %d and " % OP_GETATTR
577 matchstr += "(%d in nfs.attributes or " % FATTR4_SUPPORTED_ATTRS
578 matchstr += "%d in nfs.attributes)" % FATTR4_XATTR_SUPPORT
579 fname_list = []
580 fattr_xattr = {}
581 self.pktt.clear_xid_list()
582 while self.pktt.match(matchstr, reply=True, rewind=False):
583 pkt = self.pktt.pkt
584 if pkt.rpc.type == 1:
585 pkt_call = self.pktt.pkt_call
586 callobj = pkt_call.NFSop
587 replyobj = pkt.nfs.array[pkt_call.NFSidx]
588 filename = None
589 for fname, fh in self.name_fh.items():
590 if fh == callobj.fh:
591 filename = fname
592 break
593 if filename not in fname_list:
594 fname_list.append(filename)
595 support_h = fattr_xattr.setdefault(filename, {"supported":False, "xattrsupport":False})
596 if callobj and FATTR4_XATTR_SUPPORT in callobj.attributes and replyobj and not support_h.get("xattrsupport"):
597 support_h["xattrsupport"] = bool(replyobj.attributes.get(FATTR4_XATTR_SUPPORT, False))
598 elif replyobj and replyobj.attributes and not support_h.get("supported"):
599 obj = replyobj.attributes.get(FATTR4_SUPPORTED_ATTRS)
600 if obj:
601 support_h["supported"] = bool(FATTR4_XATTR_SUPPORT in obj.attributes)
602 for filename in fname_list:
603 support_h = fattr_xattr.get(filename)
604 self.test(support_h["supported"], "Server returns FATTR4_XATTR_SUPPORT in list of supported attributes for %r" % filename)
605 self.test(support_h["xattrsupport"], "Server returns FATTR4_XATTR_SUPPORT=TRUE for %r" % filename)
606 self.pktt.rewind()
607
608 def test_xattr(self, opcode, **kwargs):
609 """Verify extended attributes"""
610 fileidx = kwargs.get("fileidx", self.xattridx) # Index of file to use for testing
611 stype = kwargs.get("stype", 0) # SETXATTR create/replace flag
612 failure = kwargs.get("failure", 0) # Expected failure for function
613 estatus = kwargs.get("estatus", NFS4_OK) # Expected NFSv4 status
614 exists = kwargs.get("exists", 0) # Use existing attribute name
615 namelen = kwargs.get("namelen", 0) # Length of attribute name to use
616 valuelen = kwargs.get("valuelen", 0) # Length of attribute value to use
617 rmtdeleg = kwargs.get("rmtdeleg", 0) # Get delegation on second client
618
619 #=======================================================================
620 # Main test
621 #=======================================================================
622 self.test_group(re.sub("\s+", " ", self.test_description()))
623 fd = None
624 fdko = None
625 srcname = None
626 try:
627 self.trace_start()
628 self.mount()
629
630 if rmtdeleg:
631 filename = self.files[self.dgfileidx]
632 self.dgfileidx += 1
633
634 # Mount server on remote client
635 self.clientobj.mount()
636
637 # Get a read delegation on the remote client
638 self.get_deleg_remote(filename)
639 else:
640 filename = self.files[fileidx]
641 absfile = self.abspath(filename)
642
643 # Valid extended attribute name for file under test
644 if not rmtdeleg and opcode == OP_REMOVEXATTR:
645 idx = self.removeidx
646 self.removeidx += 1
647 else:
648 idx = 1
649 name = "%s%02d" % (self.xattrbase, idx)
650 ename = name if exists else (None if opcode == OP_SETXATTR else "user.notexisting")
651
652 if namelen > 0:
653 ename = "%s_%d_" % (self.xattrbase, namelen)
654 ename += "x" * (namelen - len(ename))
655
656 evalue = None
657 if valuelen > 0:
658 evalue = b"X" * valuelen
659
660 user_xattrs = []
661 if opcode == OP_GETXATTR:
662 opstr = "GETXATTR"
663 try:
664 err = 0
665 value = None
666 self.dprint('DBG1', "Get extended attribute [%s] for %s" % (ename, absfile))
667 value = os.getxattr(absfile, ename)
668 self.dprint('DBG2', "Extended attribute value: %r" % value)
669 except OSError as error:
670 err = error.errno
671 expr, amsg, fmsg = self.get_assertion(failure, err, "get attribute value")
672 self.test(expr, "GETXATTR should %s" % amsg, failmsg=fmsg)
673 if value is not None:
674 expr = (value == self.xattr_values.get(ename))
675 self.test(expr, "GETXATTR should return correct attribute value")
676 elif opcode == OP_SETXATTR:
677 opstr = "SETXATTR"
678 try:
679 err = 0
680 ename = self.set_xattr(filename, name=ename, value=evalue, stype=stype)
681 except OSError as error:
682 ename = self.xattrname
683 err = error.errno
684 expr, amsg, fmsg = self.get_assertion(failure, err, "create extended attribute")
685 self.test(expr, "SETXATTR should %s" % amsg, failmsg=fmsg)
686 if not err:
687 self.dprint('DBG2', "List extended attributes for %s" % absfile)
688 xattr_list = os.listxattr(absfile)
689 self.dprint('DBG3', "Extended attribute list: %r" % xattr_list)
690 expr = ename in xattr_list
691 self.test(expr, "Extended attribute should exist in file")
692 self.dprint('DBG2', "Get extended attribute [%s] for %s" % (ename, absfile))
693 value = os.getxattr(absfile, ename)
694 self.dprint('DBG3', "Extended attribute value: %r" % value)
695 expr = value == self.xattr_values.get(ename)
696 self.test(expr, "Extended attribute value should be correct")
697 elif opcode == OP_REMOVEXATTR:
698 opstr = "REMOVEXATTR"
699 try:
700 err = 0
701 self.dprint('DBG2', "List extended attributes for %s" % absfile)
702 xattr_list = os.listxattr(absfile)
703 self.dprint('DBG3', "Extended attribute list: %r" % xattr_list)
704 self.dprint('DBG3', "Remove extended attribute [%s] for %s" % (ename, absfile))
705 os.removexattr(absfile, ename)
706 except OSError as error:
707 err = error.errno
708 try:
709 self.dprint('DBG2', "List extended attributes for %s" % absfile)
710 xattr_list = os.listxattr(absfile)
711 self.dprint('DBG3', "Extended attribute list: %r" % xattr_list)
712 except:
713 pass
714 expr, amsg, fmsg = self.get_assertion(failure, err, "succeed")
715 self.test(expr, "REMOVEXATTR should %s" % amsg, failmsg=fmsg)
716 if xattr_list is not None:
717 if failure:
718 expr = True if not exists else (ename in xattr_list)
719 self.test(expr, "Extended attribute should not be removed from file")
720 else:
721 expr = ename not in xattr_list
722 self.test(expr, "Extended attribute should be removed from file")
723 elif opcode == OP_LISTXATTRS:
724 opstr = "LISTXATTRS"
725 try:
726 err = 0
727 self.dprint('DBG1', "List extended attributes for %s" % absfile)
728 xattr_list = os.listxattr(absfile)
729 self.dprint('DBG2', "Extended attribute list: %r" % xattr_list)
730 user_xattrs = [x for x in xattr_list if x[:5] == "user."]
731 except OSError as error:
732 err = error.errno
733 expr, amsg, fmsg = self.get_assertion(failure, err, "succeed")
734 self.test(expr, "LISTXATTR should %s" % amsg, failmsg=fmsg)
735 if fileidx == self.noxattridx:
736 expr = (len(user_xattrs) == 0)
737 self.test(expr, "LISTXATTR should not return any user namespace attributes")
738 else:
739 expr = (len(user_xattrs) > 0)
740 self.test(expr, "LISTXATTR should return all user namespace attributes")
741 except Exception:
742 self.test(False, traceback.format_exc())
743 finally:
744 if fdko is not None:
745 fdko.close()
746 if fd is not None:
747 fd.close()
748 self.umount()
749 self.clientobj.umount()
750 self.trace_stop()
751
752 #=======================================================================
753 # Process packet trace
754 #=======================================================================
755 try:
756 nfs4errlist = [estatus, NFS4ERR_NOENT]
757 if rmtdeleg:
758 nfs4errlist.append(NFS4ERR_DELAY)
759 file_name = filename
760
761 self.set_nfserr_list(nfs4list=nfs4errlist)
762 self.trace_open()
763
764 self.get_filehandles()
765
766 self.verify_xattr_support()
767
768 cbcall = None
769 deleg_stateid = None
770 if rmtdeleg:
771 # Look for delegation on second client
772 filehandle, open_stateid, deleg_stateid = self.find_open(filename=file_name, nfs_version=self.clientobj.nfs_version)
773 cbcall, cbreply = self.find_nfs_op(OP_CB_RECALL, ipaddr=self.client_ipaddr, port=None, src_ipaddr=self.server_ipaddr, first_call=True, nfs_version=None)
774 if cbcall:
775 self.pktt.rewind(cbcall.record.index)
776 drcall, drreply = self.find_nfs_op(OP_DELEGRETURN, first_call=True, nfs_version=self.clientobj.nfs_version)
777 self.pktt.rewind()
778
779 # Look for main XATTR operation
780 cookie = 0
781 xlist = set()
782 xlist_done = set()
783 fh = self.name_fh.get(file_name)
784 matchstr = "nfs.argop == %d" % opcode
785 cbrecall_done = False
786 self.pktt.clear_xid_list()
787 while self.pktt.match(matchstr, reply=True, rewind=False):
788 pkt = self.pktt.pkt
789 if pkt.rpc.type == 1:
790 pkt_call = self.pktt.pkt_call
791 callobj = pkt_call.NFSop
792 replyobj = pkt.nfs.array[pkt_call.NFSidx]
793
794 # Verify Packet Call
795 self.verify_xattr_call(pkt_call, opcode, opstr, fh, ename, stype, cookie)
796
797 estat = estatus
798 if rmtdeleg and opcode in (OP_SETXATTR, OP_REMOVEXATTR) and (cbcall or estatus == NFS4_OK):
799 if cbcall.record.index > pkt.record.index or (cbreply and \
800 cbreply.record.index > pkt.record.index):
801 estat = NFS4ERR_DELAY
802 cbrecall = True
803 emsg = " when recalling delegation"
804 else:
805 cbrecall = False
806 emsg = ""
807
808 if opcode == OP_LISTXATTRS:
809 if callobj.cookie == 0:
810 xlist = set(user_xattrs)
811 else:
812 xlist = xlist.difference(xlist_done)
813
814 # Verify Packet Reply
815 cookie = self.verify_xattr_reply(pkt, pkt_call.NFSidx, opcode, opstr, estat, ename, xlist, emsg=emsg)
816
817 if opcode == OP_LISTXATTRS:
818 if replyobj.eof:
819 # Done with this listing, reset the cookie
820 cookie = 0
821 xlist_done = set()
822 else:
823 xlist_done = xlist_done.union(["user."+x for x in replyobj.names])
824
825 if cbrecall:
826 cbrecall_done = True
827 self.test(cbcall, "%s should recall delegation on second client" % opstr)
828 if cbcall:
829 expr = cbcall.NFSop.stateid.other == deleg_stateid
830 self.test(expr, "CB_RECALL call should recall delegation granted to client")
831 self.test(cbreply, "CB_RECALL reply should be sent to the server")
832 if cbreply:
833 self.test(cbreply.NFSop.status == NFS4_OK, "CB_RECALL should return NFS4_OK")
834 self.test(drcall, "DELEGRETURN call should be sent to server")
835 if drcall:
836 expr = drcall.NFSop.stateid.other == deleg_stateid
837 self.test(expr, "DELEGRETURN call should be sent with the stateid of delegation being recalled")
838 self.test(drreply, "DELEGRETURN reply should be sent to the client")
839 if drreply:
840 self.test(drreply.NFSop.status == NFS4_OK, "DELEGRETURN reply should return NFS4_OK")
841 elif deleg_stateid and not cbrecall_done:
842 self.test(cbcall is None, "%s should not recall delegation on second client" % opstr)
843 self.pktt.rewind()
844
845 except Exception:
846 self.test(False, traceback.format_exc())
847 finally:
848 self.pktt.close()
849
850 def test_cinfo(self, **kwargs):
851 """Verify extended attribute change info"""
852 fileidx = kwargs.get("fileidx", 1) # Index of file to use for testing
853 stype = kwargs.get("stype", 0) # SETXATTR create/replace flag
854 failure = kwargs.get("failure", 0) # Expected failure for function
855 exists = kwargs.get("exists", 0) # Use existing attribute name
856 modify = kwargs.get("modify", 0) # Modify file on a second client
857
858 #=======================================================================
859 # Main test
860 #=======================================================================
861 self.test_group(re.sub("\s+", " ", self.test_description()))
862 try:
863 self.trace_start()
864 self.mount()
865
866 if modify:
867 # Mount server on remote client
868 self.clientobj.mount()
869
870 filename = self.files[fileidx]
871 absfile = self.abspath(filename)
872 opcode = OP_SETXATTR
873 opstr = "SETXATTR"
874 estatus = NFS4_OK
875 ename_list = []
876 modindex = 2
877
878 for i in range(4):
879 # Valid extended attribute name for file under test
880 name = "%s%02d" % (self.xattrbase, 1)
881 ename = name if exists else None
882
883 if modify and i == modindex:
884 afile = self.clientobj.abspath(filename)
885 self.dprint('DBG2', "Modify file on the second client %r" % afile)
886 st = os.stat(afile)
887 offset = st.st_size
888 with open(afile, "ab") as fd:
889 fd.write(self.data_pattern(offset, 32))
890
891 try:
892 err = 0
893 ename = self.set_xattr(filename, name=ename, stype=stype)
894 except OSError as error:
895 ename = self.xattrname
896 err = error.errno
897 ename_list.append(ename)
898 expr, amsg, fmsg = self.get_assertion(failure, err, "create extended attribute")
899 self.test(expr, "SETXATTR should %s" % amsg, failmsg=fmsg)
900 except Exception:
901 self.test(False, traceback.format_exc())
902 finally:
903 self.umount()
904 self.trace_stop()
905
906 #=======================================================================
907 # Process packet trace
908 #=======================================================================
909 try:
910 self.trace_open()
911 self.get_filehandles()
912
913 # Look for main SETXATTR operation
914 index = 0
915 cookie = 0
916 cinfo = -1 # Not valid but not None so change info is displayed
917 fh = self.name_fh.get(filename)
918 matchstr = "nfs.argop == %d" % opcode
919 self.pktt.clear_xid_list()
920 while self.pktt.match(matchstr, reply=True, rewind=False):
921 pkt = self.pktt.pkt
922 if pkt.rpc.type == 1:
923 pkt_call = self.pktt.pkt_call
924 callobj = pkt_call.NFSop
925 replyobj = pkt.nfs.array[pkt_call.NFSidx]
926 cmod = True if modify and modindex == index else False
927 ename = ename_list[index]
928 index += 1
929
930 # Verify Packet Call
931 self.verify_xattr_call(pkt_call, OP_SETXATTR, opstr, fh, ename, stype)
932
933 # Verify Packet Reply
934 self.verify_xattr_reply(pkt, pkt_call.NFSidx, OP_SETXATTR, opstr, estatus, ename, cinfo=cinfo, cinfodiff=cmod)
935 cinfo = replyobj.info.after
936 except Exception:
937 self.test(False, traceback.format_exc())
938 finally:
939 self.pktt.close()
940
941 def ngetxattr01_test(self):
942 """Verify getting extended attribute"""
943 self.test_xattr(OP_GETXATTR, exists=1)
944
945 def ngetxattr02_test(self):
946 """Verify getting extended attribute fails when attribute does not exist"""
947 self.test_xattr(OP_GETXATTR, exists=0, failure=errno.ENODATA, estatus=NFS4ERR_NOXATTR)
948
949 def dgetxattr01_test(self):
950 """Verify getting extended attribute
951 when delegation is granted on second client"""
952 self.test_xattr(OP_GETXATTR, exists=1, rmtdeleg=1)
953
954 def dgetxattr02_test(self):
955 """Verify getting extended attribute fails when attribute does not exist
956 when delegation is granted on second client"""
957 self.test_xattr(OP_GETXATTR, exists=0, failure=errno.ENODATA, estatus=NFS4ERR_NOXATTR, rmtdeleg=1)
958
959 def nsetxattr01_test(self):
960 """Verify setting extended attribute with SETXATTR4_EITHER when attribute does not exist"""
961 self.test_xattr(OP_SETXATTR)
962
963 def nsetxattr02_test(self):
964 """Verify setting extended attribute with SETXATTR4_CREATE when attribute does not exist"""
965 self.test_xattr(OP_SETXATTR, stype=os.XATTR_CREATE)
966
967 def nsetxattr03_test(self):
968 """Verify setting extended attribute with SETXATTR4_REPLACE fails when attribute does not exist"""
969 self.test_xattr(OP_SETXATTR, stype=os.XATTR_REPLACE, failure=errno.ENODATA, estatus=NFS4ERR_NOXATTR)
970
971 def nsetxattr04_test(self):
972 """Verify setting extended attribute with SETXATTR4_EITHER when attribute already exists"""
973 self.test_xattr(OP_SETXATTR, exists=1)
974
975 def nsetxattr05_test(self):
976 """Verify setting extended attribute with SETXATTR4_CREATE fails when attribute already exists"""
977 self.test_xattr(OP_SETXATTR, stype=os.XATTR_CREATE, exists=1, failure=errno.EEXIST, estatus=NFS4ERR_EXIST)
978
979 def nsetxattr06_test(self):
980 """Verify setting extended attribute with SETXATTR4_REPLACE when attribute already exists"""
981 self.test_xattr(OP_SETXATTR, stype=os.XATTR_REPLACE, exists=1)
982
983 def dsetxattr01_test(self):
984 """Verify setting extended attribute with SETXATTR4_EITHER when attribute does not exist
985 when delegation is granted on second client"""
986 self.test_xattr(OP_SETXATTR, rmtdeleg=1)
987
988 def dsetxattr02_test(self):
989 """Verify setting extended attribute with SETXATTR4_CREATE when attribute does not exist
990 when delegation is granted on second client"""
991 self.test_xattr(OP_SETXATTR, stype=os.XATTR_CREATE, rmtdeleg=1)
992
993 def dsetxattr03_test(self):
994 """Verify setting extended attribute with SETXATTR4_REPLACE fails when attribute does not exist
995 when delegation is granted on second client"""
996 self.test_xattr(OP_SETXATTR, stype=os.XATTR_REPLACE, failure=errno.ENODATA, estatus=NFS4ERR_NOXATTR, rmtdeleg=1)
997
998 def dsetxattr04_test(self):
999 """Verify setting extended attribute with SETXATTR4_EITHER when attribute already exists
1000 when delegation is granted on second client"""
1001 self.test_xattr(OP_SETXATTR, exists=1, rmtdeleg=1)
1002
1003 def dsetxattr05_test(self):
1004 """Verify setting extended attribute with SETXATTR4_CREATE fails when attribute already exists
1005 when delegation is granted on second client"""
1006 self.test_xattr(OP_SETXATTR, stype=os.XATTR_CREATE, exists=1, failure=errno.EEXIST, estatus=NFS4ERR_EXIST, rmtdeleg=1)
1007
1008 def dsetxattr06_test(self):
1009 """Verify setting extended attribute with SETXATTR4_REPLACE when attribute already exists
1010 when delegation is granted on second client"""
1011 self.test_xattr(OP_SETXATTR, stype=os.XATTR_REPLACE, exists=1, rmtdeleg=1)
1012
1013 def nremovexattr01_test(self):
1014 """Verify removing extended attribute"""
1015 self.test_xattr(OP_REMOVEXATTR, exists=1)
1016
1017 def nremovexattr02_test(self):
1018 """Verify removing extended attribute fails when attribute does not exist"""
1019 self.test_xattr(OP_REMOVEXATTR, exists=0, failure=errno.ENODATA, estatus=NFS4ERR_NOXATTR)
1020
1021 def dremovexattr01_test(self):
1022 """Verify removing extended attribute
1023 when delegation is granted on second client"""
1024 self.test_xattr(OP_REMOVEXATTR, exists=1, rmtdeleg=1)
1025
1026 def dremovexattr02_test(self):
1027 """Verify removing extended attribute fails when attribute does not exist
1028 when delegation is granted on second client"""
1029 self.test_xattr(OP_REMOVEXATTR, exists=0, failure=errno.ENODATA, estatus=NFS4ERR_NOXATTR, rmtdeleg=1)
1030
1031 def nlistxattr01_test(self):
1032 """Verify listing extended attributes with no user namespace attributes"""
1033 self.test_xattr(OP_LISTXATTRS, fileidx=self.noxattridx)
1034
1035 def nlistxattr02_test(self):
1036 """Verify listing extended attribute"""
1037 self.test_xattr(OP_LISTXATTRS)
1038
1039 def nlistxattr03_test(self):
1040 """Verify listing extended attribute (many attributes)"""
1041 self.test_xattr(OP_LISTXATTRS, fileidx=self.mxattridx)
1042
1043 def dlistxattr01_test(self):
1044 """Verify listing extended attributes with no user namespace attributes
1045 when delegation is granted on second client"""
1046 self.test_xattr(OP_LISTXATTRS, fileidx=self.noxattridx, rmtdeleg=1)
1047
1048 def dlistxattr02_test(self):
1049 """Verify listing extended attribute
1050 when delegation is granted on second client"""
1051 self.test_xattr(OP_LISTXATTRS, rmtdeleg=1)
1052
1053 def dlistxattr03_test(self):
1054 """Verify listing extended attribute (many attributes)
1055 when delegation is granted on second client"""
1056 self.test_xattr(OP_LISTXATTRS, fileidx=self.mxattridx, rmtdeleg=1)
1057
1058 def ncinfo01_test(self):
1059 """Verify SETXATTR change info with SETXATTR4_EITHER when attribute does not exist"""
1060 self.test_cinfo()
1061
1062 def ncinfo02_test(self):
1063 """Verify SETXATTR change info with SETXATTR4_EITHER when attribute already exists"""
1064 self.test_cinfo(exists=1)
1065
1066 def ncinfo03_test(self):
1067 """Verify SETXATTR change info with SETXATTR4_CREATE when attribute does not exist"""
1068 self.test_cinfo(stype=os.XATTR_CREATE)
1069
1070 def ncinfo04_test(self):
1071 """Verify SETXATTR change info with SETXATTR4_REPLACE when attribute already exists"""
1072 self.test_cinfo(stype=os.XATTR_REPLACE, exists=1)
1073
1074 def mcinfo01_test(self):
1075 """Verify SETXATTR change info with SETXATTR4_EITHER when attribute does not exist
1076 when file is modified on second client"""
1077 self.test_cinfo(modify=1)
1078
1079 def mcinfo02_test(self):
1080 """Verify SETXATTR change info with SETXATTR4_EITHER when attribute already exists
1081 when file is modified on second client"""
1082 self.test_cinfo(exists=1, modify=1)
1083
1084 def mcinfo03_test(self):
1085 """Verify SETXATTR change info with SETXATTR4_CREATE when attribute does not exist
1086 when file is modified on second client"""
1087 self.test_cinfo(stype=os.XATTR_CREATE, modify=1)
1088
1089 def mcinfo04_test(self):
1090 """Verify SETXATTR change info with SETXATTR4_REPLACE when attribute already exists
1091 when file is modified on second client"""
1092 self.test_cinfo(stype=os.XATTR_REPLACE, exists=1, modify=1)
1093
1094 ################################################################################
1095 # Entry point
1096 x = XATTRTest(usage=USAGE, testnames=TESTNAMES, testgroups=TESTGROUPS, sid=SCRIPT_ID)
1097
1098 try:
1099 x.setup()
1100
1101 # Run all the tests
1102 x.run_tests()
1103 except Exception:
1104 x.test(False, traceback.format_exc())
1105 finally:
1106 x.cleanup()
1107 x.exit()