]> code.ossystems Code Review - openembedded-core.git/commitdiff
sanity: Use random filename for maximum path length test
authorMike Crowe <mac@mcrowe.com>
Mon, 25 Nov 2013 15:20:14 +0000 (15:20 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 25 Nov 2013 16:14:15 +0000 (16:14 +0000)
check_create_long_filename used a fixed filename for its test files. This
meant that os.remove(testfile) could fail with ENOENT if two instances were
running at the same time against the same sstate directory. Using a
randomly generated filename stops this from happening.

(Although it might seem unlikely, this race did appear to occur multiple
times with Jenkins - presumably because the matrix jobs were all kicked off
at the same time.)

Signed-off-by: Mike Crowe <mac@mcrowe.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/sanity.bbclass

index b26ea6b3727e884ebdae022c668680b20f1d957d..8531df16b0e74de26eb51bf892011ff4f8179492 100644 (file)
@@ -175,7 +175,8 @@ def check_conf_exists(fn, data):
     return False
 
 def check_create_long_filename(filepath, pathname):
-    testfile = os.path.join(filepath, ''.join([`num`[-1] for num in xrange(1,200)]))
+    import string, random
+    testfile = os.path.join(filepath, ''.join(random.choice(string.ascii_letters) for x in range(200)))
     try:
         if not os.path.exists(filepath):
             bb.utils.mkdirhier(filepath)