aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2012-03-16 10:48:03 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2012-03-16 10:48:03 +0000
commit7c6ac2ebabd800595c3da2acd2e21b8340e0904e (patch)
treec19339c155823bc19975b70d309821bca8afe847
parentff030fd3005e05a2f73a0008faac02063c2582bb (diff)
downloadexternal_llvm-7c6ac2ebabd800595c3da2acd2e21b8340e0904e.zip
external_llvm-7c6ac2ebabd800595c3da2acd2e21b8340e0904e.tar.gz
external_llvm-7c6ac2ebabd800595c3da2acd2e21b8340e0904e.tar.bz2
lit/TestRunner.py: [Win32] Rework WinWaitReleased().
We can simply confirm the handle released to open it with EXCLUSIVE. Attempting renaming was bad. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152915 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--utils/lit/lit/TestRunner.py31
1 files changed, 12 insertions, 19 deletions
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
index 74220b8..2a42fd9 100644
--- a/utils/lit/lit/TestRunner.py
+++ b/utils/lit/lit/TestRunner.py
@@ -29,12 +29,20 @@ def RemoveForce(f):
except OSError:
pass
-def WinRename(f_o, f_n):
- import time
+def WinWaitReleased(f):
+ import time, win32file
retry_cnt = 256
- while (True):
+ while True:
try:
- os.rename(f_o, f_n)
+ h = win32file.CreateFile(
+ f,
+ 0, # Querying, neither GENERIC_READ nor GENERIC_WRITE
+ 0, # Exclusive
+ None,
+ win32file.OPEN_EXISTING,
+ win32file.FILE_ATTRIBUTE_NORMAL,
+ None)
+ h.close()
break
except WindowsError, (winerror, strerror):
retry_cnt = retry_cnt - 1
@@ -45,21 +53,6 @@ def WinRename(f_o, f_n):
else:
raise
-def WinWaitReleased(f):
- import random
- t = "%s%06d" % (f, random.randint(0, 999999))
- RemoveForce(t)
- try:
- WinRename(f, t) # rename
- WinRename(t, f) # restore
- except WindowsError, (winerror, strerror):
- if winerror in (2, 3):
- # 2: ERROR_FILE_NOT_FOUND
- # 3: ERROR_PATH_NOT_FOUND
- pass
- else:
- raise
-
def executeCommand(command, cwd=None, env=None):
p = subprocess.Popen(command, cwd=cwd,
stdin=subprocess.PIPE,