[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:38:33 +0000 (UTC)
commit 7ea596f2afb7f9ace64a2930f68e926130c7e491
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 | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/tests/functional-tests/common/utils/configuration.py
b/tests/functional-tests/common/utils/configuration.py
index 12b187383..30b740e27 100644
--- a/tests/functional-tests/common/utils/configuration.py
+++ b/tests/functional-tests/common/utils/configuration.py
@@ -111,8 +111,12 @@ 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
+ raise
return tempfile.mkdtemp(dir=_TEST_MONITORED_TMP_DIR)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]