Skip failing execute tests when using /tmp noexec
test_retry_on_failure and test_no_retry_on_success from ExecuteTestCase are failing when running system with /tmp noexec. These tests should be skipped in this case. Related-bug: #1359463 Change-Id: I32fa8f90a6292229bd23eec6d648fab617e59ec3
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import testtools
|
import testtools
|
||||||
@@ -52,11 +53,18 @@ exit 1
|
|||||||
''')
|
''')
|
||||||
fp.close()
|
fp.close()
|
||||||
os.chmod(tmpfilename, 0o755)
|
os.chmod(tmpfilename, 0o755)
|
||||||
|
try:
|
||||||
self.assertRaises(processutils.ProcessExecutionError,
|
self.assertRaises(processutils.ProcessExecutionError,
|
||||||
utils.execute,
|
utils.execute,
|
||||||
tmpfilename, tmpfilename2, attempts=10,
|
tmpfilename, tmpfilename2, attempts=10,
|
||||||
process_input='foo',
|
process_input='foo',
|
||||||
delay_on_retry=False)
|
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')
|
fp = open(tmpfilename2, 'r')
|
||||||
runs = fp.read()
|
runs = fp.read()
|
||||||
fp.close()
|
fp.close()
|
||||||
@@ -97,10 +105,17 @@ grep foo
|
|||||||
''')
|
''')
|
||||||
fp.close()
|
fp.close()
|
||||||
os.chmod(tmpfilename, 0o755)
|
os.chmod(tmpfilename, 0o755)
|
||||||
|
try:
|
||||||
utils.execute(tmpfilename,
|
utils.execute(tmpfilename,
|
||||||
tmpfilename2,
|
tmpfilename2,
|
||||||
process_input='foo',
|
process_input='foo',
|
||||||
attempts=2)
|
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:
|
finally:
|
||||||
os.unlink(tmpfilename)
|
os.unlink(tmpfilename)
|
||||||
os.unlink(tmpfilename2)
|
os.unlink(tmpfilename2)
|
||||||
|
Reference in New Issue
Block a user