1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
9 from multiprocessing import Process
15 def createfiles(d, n):
17 print("Starting small file %s %i, %i" % (d, n, j))
22 print("ERROR %s missing" % d)
25 for i in range(n, n+10):
26 with open(fn(i), "w") as f:
30 for i in range(n, n+10):
32 print("ERROR %s missing" % fn(i))
34 for i in range(n, n+10):
35 with open(fn(i), "r") as f:
37 print("ERROR %s doesn't have expected contents" % fn(i))
39 for i in range(n, n+10):
43 for i in range(n, n+10):
45 print("ERROR %s should have been removed" % fn(i))
52 print("ERROR %s should have been removed" % d)
55 def createbigfile(d, n):
57 print("Starting big file %s %i, %i" % (d, n, j))
63 print("ERROR %s missing" % d)
66 with open(fn(i), "w") as f:
67 for j in range(0, 1000):
68 f.write((str(j) + fn(i)) * 10000)
72 print("ERROR %s missing" % fn(i))
74 with open(fn(i), "r") as f:
75 for j in range(0, 1000):
76 expect = (str(j) + fn(i)) * 10000
77 if f.read(len(expect)) != expect:
78 print("ERROR %s doesn't have expected contents" % fn(i))
84 print("ERROR %s should have been removed" % fn(i))
91 print("ERROR %s should have been removed" % d)
94 with open("/dev/null", "w") as nul:
95 for j in range(1, 50):
96 subprocess.call(["ls", "-l"], stdout=nul, stderr=nul)
98 def runit(target, indir):
100 for n in range(0, 20):
102 p = Process(target=target, args=("dir%i" % n, n*10,))
104 p = Process(target=target, args=("", n*10,))
108 p = Process(target=do_ls, args=())
116 print("ERROR there are left over files in the directory")
119 if __name__ == '__main__':
121 print("ERROR starting directory is not empty")
124 print("Single directory small files")
125 with prof.CountTime():
126 runit(createfiles, False)
128 print("Separate directories small files")
129 with prof.CountTime():
130 runit(createfiles, True)
132 print("Single directory large files")
133 with prof.CountTime():
134 runit(createbigfile, False)
136 print("Separate directories large files")
137 with prof.CountTime():
138 runit(createbigfile, True)