|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. |
2 |
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 14-20
Link Here
|
| 14 |
*******************************************************************************/ |
14 |
*******************************************************************************/ |
| 15 |
package org.eclipse.core.tests.filesystem; |
15 |
package org.eclipse.core.tests.filesystem; |
| 16 |
|
16 |
|
| 17 |
import java.io.*; |
17 |
import java.io.OutputStream; |
| 18 |
import org.eclipse.core.filesystem.*; |
18 |
import org.eclipse.core.filesystem.*; |
| 19 |
import org.eclipse.core.resources.IWorkspace; |
19 |
import org.eclipse.core.resources.IWorkspace; |
| 20 |
import org.eclipse.core.resources.ResourcesPlugin; |
20 |
import org.eclipse.core.resources.ResourcesPlugin; |
|
Lines 48-55
Link Here
|
| 48 |
public static boolean isTestablePlatform() { |
48 |
public static boolean isTestablePlatform() { |
| 49 |
// A Platform is testable if it supports the "ln -s" command. |
49 |
// A Platform is testable if it supports the "ln -s" command. |
| 50 |
String os = Platform.getOS(); |
50 |
String os = Platform.getOS(); |
| 51 |
//currently we only support linux and solaris |
51 |
//currently we only support linux, solaris and mac os |
| 52 |
if (os.equals(Platform.OS_LINUX) || os.equals(Platform.OS_SOLARIS) |
52 |
if (os.equals(Platform.OS_LINUX) || os.equals(Platform.OS_SOLARIS) || os.equals(Platform.OS_MACOSX) |
| 53 |
// ||os.equals(Platform.OS_AIX) |
53 |
// ||os.equals(Platform.OS_AIX) |
| 54 |
// ||os.equals(Platform.OS_HPUX) |
54 |
// ||os.equals(Platform.OS_HPUX) |
| 55 |
// ||isWindowsVista() |
55 |
// ||isWindowsVista() |
|
Lines 295-301
Link Here
|
| 295 |
public void testSymlinkEnabled() { |
295 |
public void testSymlinkEnabled() { |
| 296 |
String os = Platform.getOS(); |
296 |
String os = Platform.getOS(); |
| 297 |
String arch = Platform.getOSArch(); |
297 |
String arch = Platform.getOSArch(); |
| 298 |
if (Platform.OS_LINUX.equals(os) || (Platform.OS_SOLARIS.equals(os) && Platform.ARCH_SPARC.equals(arch))) { |
298 |
if (Platform.OS_LINUX.equals(os) || (Platform.OS_SOLARIS.equals(os) && Platform.ARCH_SPARC.equals(arch)) || Platform.OS_MACOSX.equals(os)) { |
| 299 |
assertTrue(haveSymlinks()); |
299 |
assertTrue(haveSymlinks()); |
| 300 |
} else { |
300 |
} else { |
| 301 |
assertFalse(haveSymlinks()); |
301 |
assertFalse(haveSymlinks()); |
|
Lines 332-361
Link Here
|
| 332 |
} |
332 |
} |
| 333 |
} |
333 |
} |
| 334 |
|
334 |
|
| 335 |
public void testSymlinkPutInfo() throws Exception { |
335 |
public void testSymlinkPutLastModified() throws Exception { |
| 336 |
if (!isTestablePlatform()) { |
336 |
if (!isTestablePlatform()) { |
| 337 |
return; |
337 |
return; |
| 338 |
} |
338 |
} |
|
|
339 |
if (Platform.OS_MACOSX.equals(Platform.getOS())) { |
| 340 |
// flag EFS.SET_LAST_MODIFIED is set by java.io and it fails on Mac OS |
| 341 |
return; |
| 342 |
} |
| 339 |
//check that putInfo() "writes through" the symlink |
343 |
//check that putInfo() "writes through" the symlink |
| 340 |
makeLinkStructure(); |
344 |
makeLinkStructure(); |
| 341 |
long oldTime = iFile.getLastModified(); |
345 |
long oldTime = iFile.getLastModified(); |
| 342 |
long timeToSet = oldTime - 100000; |
346 |
long timeToSet = oldTime - 100000; |
| 343 |
illFile.setLastModified(timeToSet); |
347 |
illFile.setLastModified(timeToSet); |
| 344 |
illFile.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true); |
|
|
| 345 |
llFile.putInfo(illFile, EFS.SET_ATTRIBUTES | EFS.SET_LAST_MODIFIED, getMonitor()); |
348 |
llFile.putInfo(illFile, EFS.SET_ATTRIBUTES | EFS.SET_LAST_MODIFIED, getMonitor()); |
| 346 |
iFile = aFile.fetchInfo(); |
349 |
iFile = aFile.fetchInfo(); |
| 347 |
assertEquals(iFile.getLastModified(), timeToSet); |
350 |
assertEquals(iFile.getLastModified(), timeToSet); |
| 348 |
assertTrue(iFile.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); |
|
|
| 349 |
|
351 |
|
| 350 |
oldTime = iDir.getLastModified(); |
352 |
oldTime = iDir.getLastModified(); |
| 351 |
timeToSet = oldTime - 100000; |
353 |
timeToSet = oldTime - 100000; |
| 352 |
illDir.setLastModified(timeToSet); |
354 |
illDir.setLastModified(timeToSet); |
| 353 |
illDir.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true); |
|
|
| 354 |
llDir.putInfo(illDir, EFS.SET_ATTRIBUTES | EFS.SET_LAST_MODIFIED, getMonitor()); |
355 |
llDir.putInfo(illDir, EFS.SET_ATTRIBUTES | EFS.SET_LAST_MODIFIED, getMonitor()); |
| 355 |
iDir = aDir.fetchInfo(); |
356 |
iDir = aDir.fetchInfo(); |
| 356 |
assertTrue(iDir.getLastModified() != oldTime); |
357 |
assertTrue(iDir.getLastModified() != oldTime); |
| 357 |
assertEquals(iDir.getLastModified(), timeToSet); |
358 |
assertEquals(iDir.getLastModified(), timeToSet); |
|
|
359 |
if (haveSymlinks()) { |
| 360 |
//check that link properties are maintained even through putInfo |
| 361 |
illFile = llFile.fetchInfo(); |
| 362 |
illDir = llDir.fetchInfo(); |
| 363 |
assertTrue(illFile.getAttribute(EFS.ATTRIBUTE_SYMLINK)); |
| 364 |
assertTrue(illDir.getAttribute(EFS.ATTRIBUTE_SYMLINK)); |
| 365 |
assertEquals(illFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lFile"); |
| 366 |
assertEquals(illDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lDir"); |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
public void testSymlinkPutReadOnly() throws Exception { |
| 371 |
if (!isTestablePlatform()) { |
| 372 |
return; |
| 373 |
} |
| 374 |
//check that putInfo() "writes through" the symlink |
| 375 |
makeLinkStructure(); |
| 376 |
illFile.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true); |
| 377 |
llFile.putInfo(illFile, EFS.SET_ATTRIBUTES, getMonitor()); |
| 378 |
iFile = aFile.fetchInfo(); |
| 379 |
assertTrue(iFile.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); |
| 380 |
|
| 381 |
illFile.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false); |
| 382 |
llFile.putInfo(illFile, EFS.SET_ATTRIBUTES, getMonitor()); |
| 383 |
iFile = aFile.fetchInfo(); |
| 384 |
assertFalse(iFile.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); |
| 385 |
|
| 386 |
illDir.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true); |
| 387 |
llDir.putInfo(illDir, EFS.SET_ATTRIBUTES, getMonitor()); |
| 388 |
iDir = aDir.fetchInfo(); |
| 358 |
assertTrue(iDir.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); |
389 |
assertTrue(iDir.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); |
|
|
390 |
|
| 391 |
illDir.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false); |
| 392 |
llDir.putInfo(illDir, EFS.SET_ATTRIBUTES, getMonitor()); |
| 393 |
iDir = aDir.fetchInfo(); |
| 394 |
assertFalse(iDir.getAttribute(EFS.ATTRIBUTE_READ_ONLY)); |
| 395 |
if (haveSymlinks()) { |
| 396 |
//check that link properties are maintained even through putInfo |
| 397 |
illFile = llFile.fetchInfo(); |
| 398 |
illDir = llDir.fetchInfo(); |
| 399 |
assertTrue(illFile.getAttribute(EFS.ATTRIBUTE_SYMLINK)); |
| 400 |
assertTrue(illDir.getAttribute(EFS.ATTRIBUTE_SYMLINK)); |
| 401 |
assertEquals(illFile.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lFile"); |
| 402 |
assertEquals(illDir.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET), "lDir"); |
| 403 |
} |
| 404 |
} |
| 405 |
|
| 406 |
public void testSymlinkPutExecutable() throws Exception { |
| 407 |
if (!isTestablePlatform()) { |
| 408 |
return; |
| 409 |
} |
| 410 |
//check that putInfo() "writes through" the symlink |
| 411 |
makeLinkStructure(); |
| 412 |
illFile.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, true); |
| 413 |
llFile.putInfo(illFile, EFS.SET_ATTRIBUTES, getMonitor()); |
| 414 |
iFile = aFile.fetchInfo(); |
| 415 |
assertTrue(iFile.getAttribute(EFS.ATTRIBUTE_EXECUTABLE)); |
| 416 |
|
| 417 |
illDir.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, false); |
| 418 |
llDir.putInfo(illDir, EFS.SET_ATTRIBUTES, getMonitor()); |
| 419 |
iDir = aDir.fetchInfo(); |
| 420 |
assertFalse(iDir.getAttribute(EFS.ATTRIBUTE_EXECUTABLE)); |
| 359 |
if (haveSymlinks()) { |
421 |
if (haveSymlinks()) { |
| 360 |
//check that link properties are maintained even through putInfo |
422 |
//check that link properties are maintained even through putInfo |
| 361 |
illFile = llFile.fetchInfo(); |
423 |
illFile = llFile.fetchInfo(); |