[CalendarServer-changes] [1300]
CalendarServer/trunk/contrib/stress_xattr.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Mar 1 18:24:27 PST 2007
Revision: 1300
http://trac.macosforge.org/projects/calendarserver/changeset/1300
Author: tfitz at apple.com
Date: 2007-03-01 18:24:26 -0800 (Thu, 01 Mar 2007)
Log Message:
-----------
Initial revision of xattr stress test.
Added Paths:
-----------
CalendarServer/trunk/contrib/stress_xattr.py
Added: CalendarServer/trunk/contrib/stress_xattr.py
===================================================================
--- CalendarServer/trunk/contrib/stress_xattr.py (rev 0)
+++ CalendarServer/trunk/contrib/stress_xattr.py 2007-03-02 02:24:26 UTC (rev 1300)
@@ -0,0 +1,49 @@
+import os
+from random import choice
+from string import uppercase
+
+from xattr import getxattr, listxattr, removexattr, setxattr
+
+def randstr(length):
+ return "".join(choice(uppercase) for n in xrange(length))
+
+def main(path):
+ while True:
+ try:
+ filename = os.path.join(path, randstr(8))
+ fout = open(filename, "w")
+ fout.write("---")
+ fout.close()
+
+ print filename
+ for n in xrange(1024):
+ expectedAttr = {}
+ for m in xrange(1024):
+ key, value = randstr(10), randstr(100)
+ expectedAttr[key] = value
+ setxattr(filename, key, value)
+ assert getxattr(filename, key) == value, (key,value)
+
+ attrList = sorted(listxattr(filename))
+ expectedAttrList = sorted(expectedAttr.keys())
+ assert attrList == expectedAttrList, (attrList, expectedAttrList)
+
+ for key, value in expectedAttr.items():
+ assert getxattr(filename, key) == value
+ removexattr(filename, key)
+
+ attrList = listxattr(filename)
+ assert not attrList, attrList
+
+ print n
+ finally:
+ os.remove(filename)
+
+if __name__ == "__main__":
+ import sys
+ path = "."
+ if len(sys.argv) == 2:
+ path = sys.argv[1]
+ elif len(sys.argv) > 2:
+ print "Usage: python stress_xattr.py [path]"
+ main(path)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070301/6da548e1/attachment.html
More information about the calendarserver-changes
mailing list