author | Danek Duvall <danek.duvall@oracle.com> |
Tue, 22 Apr 2014 12:43:58 -0700 | |
changeset 1847 | b43426a2f6ba |
child 4894 | 7219201c1b0d |
child 7853 | 87236a3c36b4 |
permissions | -rw-r--r-- |
1847
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
1 |
Every file on Solaris 11 and on has two extended attributes, so if we find |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
2 |
them, we shouldn't fail. Also, we don't support extended attributes on |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
3 |
symlinks, so just quietly pass that test. |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
4 |
|
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
5 |
Merged as of 0.7.6. |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
6 |
|
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
7 |
diff --git a/xattr/tests/test_xattr.py b/xattr/tests/test_xattr.py |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
8 |
--- a/xattr/tests/test_xattr.py Mon Mar 3 10:12:24 2014 |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
9 |
+++ b/xattr/tests/test_xattr.py Wed Mar 26 16:29:24 2014 |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
10 |
@@ -1,4 +1,5 @@ |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
11 |
import os |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
12 |
+import sys |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
13 |
from unittest import TestCase |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
14 |
from tempfile import mkdtemp, NamedTemporaryFile |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
15 |
|
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
16 |
@@ -8,10 +9,19 @@ |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
17 |
class BaseTestXattr(object): |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
18 |
def test_attr(self): |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
19 |
x = xattr.xattr(self.tempfile) |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
20 |
- self.assertEqual(x.keys(), []) |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
21 |
- self.assertEqual(x.list(), []) |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
22 |
- self.assertEqual(dict(x), {}) |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
23 |
|
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
24 |
+ # Solaris 11 and forward contain system attributes (file flags) in |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
25 |
+ # extended attributes present on all files, so cons them up into a |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
26 |
+ # comparison dict. |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
27 |
+ d = {} |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
28 |
+ if sys.platform == 'sunos5' and 'SUNWattr_ro' in x: |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
29 |
+ d['SUNWattr_ro'] = x['SUNWattr_ro'] |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
30 |
+ d['SUNWattr_rw'] = x['SUNWattr_rw'] |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
31 |
+ |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
32 |
+ self.assertEqual(x.keys(), d.keys()) |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
33 |
+ self.assertEqual(x.list(), d.keys()) |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
34 |
+ self.assertEqual(dict(x), d) |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
35 |
+ |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
36 |
x['user.sopal'] = b'foo' |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
37 |
x['user.sop.foo'] = b'bar' |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
38 |
x[u'user.\N{SNOWMAN}'] = b'not a snowman' |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
39 |
@@ -38,6 +48,9 @@ |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
40 |
self.assertTrue('user.sop.foo' not in x) |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
41 |
|
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
42 |
def test_symlink_attrs(self): |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
43 |
+ # Solaris doesn't support extended attributes on symlinks |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
44 |
+ if sys.platform == 'sunos5': |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
45 |
+ return |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
46 |
symlinkPath = self.tempfilename + '.link' |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
47 |
os.symlink(self.tempfilename, symlinkPath) |
b43426a2f6ba
PSARC/2014/113 xattr: filesystem extended attribute support for Python
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
48 |
try: |