1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 from multiprocessing import Process
14 def createfiles(d, n):
15 for j in xrange(1, 5):
16 print "Starting small file %s %i, %i" % (d, n, j)
21 print "ERROR %s missing" % d
24 for i in xrange(n, n+10):
25 with open(fn(i), "w") as f:
29 for i in xrange(n, n+10):
31 print "ERROR %s missing" % fn(i)
33 for i in xrange(n, n+10):
34 with open(fn(i), "r") as f:
36 print "ERROR %s doesn't have expected contents" % fn(i)
38 for i in xrange(n, n+10):
42 for i in xrange(n, n+10):
44 print "ERROR %s should have been removed" % fn(i)
51 print "ERROR %s should have been removed" % d
54 def createbigfile(d, n):
55 for j in xrange(1, 5):
56 print "Starting big file %s %i, %i" % (d, n, j)
62 print "ERROR %s missing" % d
65 with open(fn(i), "w") as f:
66 for j in xrange(0, 1000):
67 f.write((str(j) + fn(i)) * 10000)
71 print "ERROR %s missing" % fn(i)
73 with open(fn(i), "r") as f:
74 for j in xrange(0, 1000):
75 expect = (str(j) + fn(i)) * 10000
76 if f.read(len(expect)) != expect:
77 print "ERROR %s doesn't have expected contents" % fn(i)
83 print "ERROR %s should have been removed" % fn(i)
90 print "ERROR %s should have been removed" % d
93 with open("/dev/null", "w") as nul:
94 for j in xrange(1, 50):
95 subprocess.call(["ls", "-l"], stdout=nul, stderr=nul)
97 def runit(target, indir):
99 for n in xrange(0, 20):
101 p = Process(target=target, args=("dir%i" % n, n*10,))
103 p = Process(target=target, args=("", n*10,))
107 p = Process(target=do_ls, args=())
115 print "ERROR there are left over files in the directory"
118 if __name__ == '__main__':
120 print "ERROR starting directory is not empty"
123 print "Single directory small files"
124 with prof.CountTime():
125 runit(createfiles, False)
127 print "Separate directories small files"
128 with prof.CountTime():
129 runit(createfiles, True)
131 print "Single directory large files"
132 with prof.CountTime():
133 runit(createbigfile, False)
135 print "Separate directories large files"
136 with prof.CountTime():
137 runit(createbigfile, True)