1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-21 15:23:59 +02:00

Bug 314439 - [efs][testing] testDeleteSpecialCases runs into test failures on Linux

This commit is contained in:
Martin Oberhuber 2010-05-26 14:17:31 +00:00
parent 25d65ec6e2
commit 4d959264cc

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - initial API and implementation * Martin Oberhuber (Wind River) - initial API and implementation
* Martin Oberhuber (Wind River) - [240729] More flexible disabling of testcases * Martin Oberhuber (Wind River) - [240729] More flexible disabling of testcases
* Martin Oberhuber (Wind River) - [314439] testDeleteSpecialCases fails on Linux
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.tests.subsystems.files; package org.eclipse.rse.tests.subsystems.files;
@ -147,6 +148,7 @@ public class RSEFileStoreTest extends FileServiceBaseTest {
} }
public void tearDown() throws Exception { public void tearDown() throws Exception {
try {
if (fIS != null) { if (fIS != null) {
try { try {
fIS.close(); fIS.close();
@ -164,14 +166,33 @@ public class RSEFileStoreTest extends FileServiceBaseTest {
} }
} }
//Try..catch to allow super.tearDown() to run //Try..catch to allow super.tearDown() to run
try {
IFileInfo info = fTestStore.fetchInfo();
info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false);
info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, true);
fTestStore.putInfo(info, EFS.SET_ATTRIBUTES, getDefaultProgressMonitor());
} finally {
try { try {
fTestStore.delete(EFS.NONE, getDefaultProgressMonitor()); fTestStore.delete(EFS.NONE, getDefaultProgressMonitor());
} catch (CoreException ce) { } catch (CoreException ce) {
System.err.println("Exception in tearDown.deleteTestStore:"); /* might be expected if fTestStore had no permissions */
ce.printStackTrace(); } finally {
IRemoteCmdSubSystem rcmd = getShellServiceSubSystem();
if (rcmd!=null) {
SimpleCommandOperation op = new SimpleCommandOperation(rcmd, fHomeDirectory, true);
op.runCommand("chmod 777 \"" + fTestStorePath + "\"", true);
while (op.isActive()) {
Thread.sleep(200);
} }
//no more exception expected.
fTestStore.delete(EFS.NONE, getDefaultProgressMonitor());
}
}
}
} finally {
super.tearDown(); super.tearDown();
} }
}
protected IFileStore createFile(String name) throws Exception { protected IFileStore createFile(String name) throws Exception {
IFileStore store = fTestStore.getChild(name); IFileStore store = fTestStore.getChild(name);
@ -287,8 +308,13 @@ public class RSEFileStoreTest extends FileServiceBaseTest {
System.out.println("Good! " + ce); System.out.println("Good! " + ce);
assertTrue("1.1.1", ce.getStatus().getCode() == EFS.ERROR_DELETE); assertTrue("1.1.1", ce.getStatus().getCode() == EFS.ERROR_DELETE);
} }
if (fPropertiesFileName != null || File.separatorChar != '\\') { // restore deletable
// On Windows, no exception is thrown (read-only stuff can be deleted) info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false);
info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, true);
fTestStore.putInfo(info, EFS.SET_ATTRIBUTES, getDefaultProgressMonitor());
if (fPropertiesFileName != null && File.separatorChar != '\\') {
// Do not check Eclipse EFS due to bug 314448
// Do not check RSE-EFS on Windows (read-only stuff can be deleted)
if (fHomeDirectory == null || fHomeDirectory.getSeparatorChar() != '\\') { if (fHomeDirectory == null || fHomeDirectory.getSeparatorChar() != '\\') {
assertTrue("1.1", exceptionThrown); assertTrue("1.1", exceptionThrown);
IFileInfo info2 = store.fetchInfo(); IFileInfo info2 = store.fetchInfo();
@ -296,10 +322,6 @@ public class RSEFileStoreTest extends FileServiceBaseTest {
} }
} }
// restore deletable
info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false);
info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, true);
fTestStore.putInfo(info, EFS.SET_ATTRIBUTES, getDefaultProgressMonitor());
store.delete(EFS.NONE, getDefaultProgressMonitor()); store.delete(EFS.NONE, getDefaultProgressMonitor());
info = store.fetchInfo(EFS.NONE, getDefaultProgressMonitor()); info = store.fetchInfo(EFS.NONE, getDefaultProgressMonitor());
assertTrue("1.2", !info.exists()); assertTrue("1.2", !info.exists());
@ -343,7 +365,10 @@ public class RSEFileStoreTest extends FileServiceBaseTest {
System.out.println("Good! " + ce); System.out.println("Good! " + ce);
assertTrue("1.5.1", ce.getStatus().getCode() == EFS.ERROR_DELETE); assertTrue("1.5.1", ce.getStatus().getCode() == EFS.ERROR_DELETE);
} }
if (!"localConnection.properties".equals(fPropertiesFileName)) {
//bug 314439: java.io.File cannot tell between no-permission and not-exists
assertTrue("1.5", exceptionThrown); assertTrue("1.5", exceptionThrown);
}
exceptionThrown = false; exceptionThrown = false;
try { try {
@ -353,10 +378,13 @@ public class RSEFileStoreTest extends FileServiceBaseTest {
System.out.println("Good! " + ce); System.out.println("Good! " + ce);
assertTrue("1.6.1", ce.getStatus().getCode() == EFS.ERROR_READ); assertTrue("1.6.1", ce.getStatus().getCode() == EFS.ERROR_READ);
} }
if (!"localConnection.properties".equals(fPropertiesFileName)) {
//bug 314439: java.io.File cannot tell between no-permission and not-exists
assertTrue("1.6", exceptionThrown); assertTrue("1.6", exceptionThrown);
}
SimpleCommandOperation op4 = new SimpleCommandOperation(rcmd, fHomeDirectory, true); SimpleCommandOperation op4 = new SimpleCommandOperation(rcmd, fHomeDirectory, true);
op4.runCommand("chmod 777 \"" + fTestStorePath + "\"", true); op4.runCommand("chmod 777 \"" + fTestStorePath + "\"", true);
while (op3.isActive()) { while (op4.isActive()) {
Thread.sleep(200); Thread.sleep(200);
} }
//Experience shows that we need to wait a little longer until the filesystem calms down //Experience shows that we need to wait a little longer until the filesystem calms down