diff options
Diffstat (limited to 'tests/lib/testcase.php')
-rw-r--r-- | tests/lib/testcase.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/lib/testcase.php b/tests/lib/testcase.php index d385a903d1e..407c5165140 100644 --- a/tests/lib/testcase.php +++ b/tests/lib/testcase.php @@ -104,6 +104,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { self::tearDownAfterClassCleanFileCache(); self::tearDownAfterClassCleanStrayDataFiles($dataDir); self::tearDownAfterClassCleanStrayHooks(); + self::tearDownAfterClassCleanStrayLocks(); parent::tearDownAfterClass(); } @@ -197,6 +198,13 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { } /** + * Clean up the list of locks + */ + static protected function tearDownAfterClassCleanStrayLocks() { + \OC::$server->getLockingProvider()->releaseAll(); + } + + /** * Login and setup FS as a given user, * sets the given user as the current user. * @@ -249,11 +257,13 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { * @param \OC\Files\View $view view * @param string $path path to check * @param int $type lock type + * @param bool $onMountPoint true to check the mount point instead of the + * mounted storage * * @return boolean true if the file is locked with the * given type, false otherwise */ - protected function isFileLocked($view, $path, $type) { + protected function isFileLocked($view, $path, $type, $onMountPoint = false) { // Note: this seems convoluted but is necessary because // the format of the lock key depends on the storage implementation // (in our case mostly md5) @@ -266,10 +276,10 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { $checkType = \OCP\Lock\ILockingProvider::LOCK_SHARED; } try { - $view->lockFile($path, $checkType); + $view->lockFile($path, $checkType, $onMountPoint); // no exception, which means the lock of $type is not set // clean up - $view->unlockFile($path, $checkType); + $view->unlockFile($path, $checkType, $onMountPoint); return false; } catch (\OCP\Lock\LockedException $e) { // we could not acquire the counter-lock, which means |