Try to fix intermittent test failure related to file timestamps
Improve how tests do a "touch" operation on files. Instead of doing "f.setLastModified(System.currentTimeMillis)" open a Outputstream on the file and directly close it again. This makes this method rely only on one clock - the clock of the filesystem. Bug: 436917 Change-Id: I68ef3c2878f28b12daebf2ef6a9fa0a5d6e0964d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
10aee9b1b7
commit
0f14d3bf40
|
@ -375,7 +375,7 @@ public static String lookup(Object l, String nameTemplate,
|
|||
*/
|
||||
public static long fsTick(File lastFile) throws InterruptedException,
|
||||
IOException {
|
||||
long sleepTime = 1;
|
||||
long sleepTime = 64;
|
||||
FS fs = FS.DETECTED;
|
||||
if (lastFile != null && !fs.exists(lastFile))
|
||||
throw new FileNotFoundException(lastFile.getPath());
|
||||
|
@ -386,8 +386,9 @@ public static long fsTick(File lastFile) throws InterruptedException,
|
|||
long actTime = fs.lastModified(tmp);
|
||||
while (actTime <= startTime) {
|
||||
Thread.sleep(sleepTime);
|
||||
sleepTime *= 5;
|
||||
fs.setLastModified(tmp, System.currentTimeMillis());
|
||||
sleepTime *= 2;
|
||||
FileOutputStream fos = new FileOutputStream(tmp);
|
||||
fos.close();
|
||||
actTime = fs.lastModified(tmp);
|
||||
}
|
||||
return actTime;
|
||||
|
|
Loading…
Reference in New Issue