More helpful failure for tests on noexec /tmp

When tests are run with a noexec /tmp they may can fail with a
not-so-clear error message. Making this more clear.

Closes-Bug: #1359463
Change-Id: I67086c960dd249a88680958a3f8aaba54db1e691
This commit is contained in:
Gregory Haynes 2014-08-20 17:16:37 -07:00 committed by Vladyslav Drok
parent 92e7fc73db
commit e6ac648e41
1 changed files with 23 additions and 9 deletions

View File

@ -97,11 +97,18 @@ exit 1
''')
fp.close()
os.chmod(tmpfilename, 0o755)
self.assertRaises(processutils.ProcessExecutionError,
utils.execute,
tmpfilename, tmpfilename2, attempts=10,
process_input='foo',
delay_on_retry=False)
try:
self.assertRaises(processutils.ProcessExecutionError,
utils.execute,
tmpfilename, tmpfilename2, attempts=10,
process_input='foo',
delay_on_retry=False)
except OSError as e:
if e.errno == errno.EACCES:
self.skipTest("Permissions error detected. "
"Are you running with a noexec /tmp?")
else:
raise
fp = open(tmpfilename2, 'r')
runs = fp.read()
fp.close()
@ -142,10 +149,17 @@ grep foo
''')
fp.close()
os.chmod(tmpfilename, 0o755)
utils.execute(tmpfilename,
tmpfilename2,
process_input='foo',
attempts=2)
try:
utils.execute(tmpfilename,
tmpfilename2,
process_input='foo',
attempts=2)
except OSError as e:
if e.errno == errno.EACCES:
self.skipTest("Permissions error detected. "
"Are you running with a noexec /tmp?")
else:
raise
finally:
os.unlink(tmpfilename)
os.unlink(tmpfilename2)