[tracker-miners/sam/test-runner-fix] functional-tests: Fix race condition when creating temporary directory
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/sam/test-runner-fix] functional-tests: Fix race condition when creating temporary directory
- Date: Tue, 5 Mar 2019 20:41:03 +0000 (UTC)
commit 861f539ea7b9ca72510b0e88db52dfdda33fd33e
Author: Sam Thursfield <sam afuera me uk>
Date: Tue Mar 5 21:36:17 2019 +0100
functional-tests: Fix race condition when creating temporary directory
This code path would fail if two tests tried to create the
directory at the same time. We should ignore EEXIST rather than doing
a check + create sequence that isn't atomic.
tests/functional-tests/common/utils/configuration.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/tests/functional-tests/common/utils/configuration.py
b/tests/functional-tests/common/utils/configuration.py
index 12b187383..203bd4cc2 100644
--- a/tests/functional-tests/common/utils/configuration.py
+++ b/tests/functional-tests/common/utils/configuration.py
@@ -111,8 +111,13 @@ if _TEST_MONITORED_TMP_DIR.startswith('/tmp'):
def create_monitored_test_dir():
'''Returns a unique tmpdir which supports filesystem monitor events.'''
- if not os.path.exists(_TEST_MONITORED_TMP_DIR):
+ try:
os.makedirs(_TEST_MONITORED_TMP_DIR)
+ except OSError as e:
+ if e.errno == errno.EEXIST:
+ pass
+ else:
+ raise
return tempfile.mkdtemp(dir=_TEST_MONITORED_TMP_DIR)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]