Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] sanity: Use random filename for maximum path length test
@ 2013-11-25 15:20 Mike Crowe
  2013-11-25 15:20 ` [PATCH 2/2] sanity: Don't hard code value of ENAMETOOLONG Mike Crowe
  2013-11-25 15:48 ` [PATCH 1/2] sanity: Use random filename for maximum path length test Richard Purdie
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Crowe @ 2013-11-25 15:20 UTC (permalink / raw)
  To: openembedded-core; +Cc: Mike Crowe

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>
---
 meta/classes/sanity.bbclass |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 6807a23..0d40792 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -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)
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] sanity: Don't hard code value of ENAMETOOLONG
  2013-11-25 15:20 [PATCH 1/2] sanity: Use random filename for maximum path length test Mike Crowe
@ 2013-11-25 15:20 ` Mike Crowe
  2013-11-25 15:48 ` [PATCH 1/2] sanity: Use random filename for maximum path length test Richard Purdie
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Crowe @ 2013-11-25 15:20 UTC (permalink / raw)
  To: openembedded-core; +Cc: Mike Crowe

Although ENAMETOOLONG is 36 on Linux x86 and x86_64 it does isn't on other
architectures so the value shouldn't be hard coded.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
---
 meta/classes/sanity.bbclass |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 0d40792..8531df1 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -184,8 +184,9 @@ def check_create_long_filename(filepath, pathname):
         f.close()
         os.remove(testfile)
     except IOError as e:
-        errno, strerror = e.args
-        if errno == 36: # ENAMETOOLONG
+        import errno
+        err, strerror = e.args
+        if err == errno.ENAMETOOLONG:
             return "Failed to create a file with a long name in %s. Please use a filesystem that does not unreasonably limit filename length.\n" % pathname
         else:
             return "Failed to create a file in %s: %s.\n" % (pathname, strerror)
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] sanity: Use random filename for maximum path length test
  2013-11-25 15:20 [PATCH 1/2] sanity: Use random filename for maximum path length test Mike Crowe
  2013-11-25 15:20 ` [PATCH 2/2] sanity: Don't hard code value of ENAMETOOLONG Mike Crowe
@ 2013-11-25 15:48 ` Richard Purdie
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2013-11-25 15:48 UTC (permalink / raw)
  To: Mike Crowe; +Cc: openembedded-core

On Mon, 2013-11-25 at 15:20 +0000, Mike Crowe wrote:
> 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>
> ---
>  meta/classes/sanity.bbclass |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

We've been puzzling over this on the project autobuilder too, although I
didn't spot why, nicely found!

Cheers,

Richard

> diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
> index 6807a23..0d40792 100644
> --- a/meta/classes/sanity.bbclass
> +++ b/meta/classes/sanity.bbclass
> @@ -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)




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-25 15:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-25 15:20 [PATCH 1/2] sanity: Use random filename for maximum path length test Mike Crowe
2013-11-25 15:20 ` [PATCH 2/2] sanity: Don't hard code value of ENAMETOOLONG Mike Crowe
2013-11-25 15:48 ` [PATCH 1/2] sanity: Use random filename for maximum path length test Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox