array( 'mwstore://backend/container/path', 'mwstore://backend/container/path' ),
array( 'mwstore://backend/container//path', 'mwstore://backend/container/path' ),
array( 'mwstore://backend/container///path', 'mwstore://backend/container/path' ),
- array( 'mwstore://backend/container///path//to///obj', 'mwstore://backend/container/path/to/obj',
+ array( 'mwstore://backend/container///path//to///obj', 'mwstore://backend/container/path/to/obj' ),
array( 'mwstore://', null ),
array( 'mwstore://backend', null ),
array( 'mwstore://backend//container/path', null ),
array( 'mwstore://backend//container//path', null ),
array( 'mwstore:///', null ),
array( 'mwstore:/', null ),
- array( 'mwstore:', null ), )
+ array( 'mwstore:', null ),
);
}
$dest, // dest
);
+ $op2 = $op;
+ $op2['ignoreMissingSource'] = true;
+ $cases[] = array(
+ $op2, // operation
+ self::baseStorePath() . '/unittest-cont-bad/e/file.txt', // source
+ $dest, // dest
+ );
+
return $cases;
}
$dest, // dest
);
+ $op2 = $op;
+ $op2['ignoreMissingSource'] = true;
+ $cases[] = array(
+ $op2, // operation
+ self::baseStorePath() . '/unittest-cont-bad/e/file.txt', // source
+ $dest, // dest
+ );
+
return $cases;
}
true // succeeds
);
+ $op['ignoreMissingSource'] = true;
+ $op['src'] = self::baseStorePath() . '/unittest-cont-bad/e/file.txt';
+ $cases[] = array(
+ $op, // operation
+ false, // without source
+ true // succeeds
+ );
+
return $cases;
}
$status = $this->prepare( array( 'dir' => dirname( $path ) ) );
$this->assertGoodStatus( $status,
"Preparing $path succeeded without warnings ($backendName)." );
- $ops[] = array( 'op' => 'create', 'dst' => $path, 'content' => mt_rand(0,50000) );
+ $ops[] = array( 'op' => 'create', 'dst' => $path, 'content' => mt_rand(0, 50000) );
$purgeOps[] = array( 'op' => 'delete', 'src' => $path );
}
$purgeOps[] = array( 'op' => 'null' );
$cases[] = array( "$base/unittest-cont1/e/b/some-other_file.txt", "more file contents" );
$cases[] = array(
array( "$base/unittest-cont1/e/a/x.txt", "$base/unittest-cont1/e/a/y.txt",
- "$base/unittest-cont1/e/a/z.txt" ),
+ "$base/unittest-cont1/e/a/z.txt" ),
array( "contents xx", "contents xy", "contents xz" )
);
$cases[] = array( "$base/unittest-cont1/e/a/\$odd&.txt", "test file contents" );
$cases[] = array(
array( "$base/unittest-cont1/e/a/x.txt", "$base/unittest-cont1/e/a/y.txt",
- "$base/unittest-cont1/e/a/z.txt" ),
+ "$base/unittest-cont1/e/a/z.txt" ),
array( "contents xx", "contents xy", "contents xz" )
);
$cases[] = array( "$base/unittest-cont1/e/a/\$odd&.txt", "test file contents" );
$cases[] = array(
array( "$base/unittest-cont1/e/a/x.txt", "$base/unittest-cont1/e/a/y.txt",
- "$base/unittest-cont1/e/a/z.txt" ),
+ "$base/unittest-cont1/e/a/z.txt" ),
array( "contents xx", "contents xy", "contents xz" )
);
private function doTestLockCalls() {
$backendName = $this->backendClass();
- for ( $i=0; $i<50; $i++ ) {
- $paths = array(
- "test1.txt",
- "test2.txt",
- "test3.txt",
- "subdir1",
- "subdir1", // duplicate
- "subdir1/test1.txt",
- "subdir1/test2.txt",
- "subdir2",
- "subdir2", // duplicate
- "subdir2/test3.txt",
- "subdir2/test4.txt",
- "subdir2/subdir",
- "subdir2/subdir/test1.txt",
- "subdir2/subdir/test2.txt",
- "subdir2/subdir/test3.txt",
- "subdir2/subdir/test4.txt",
- "subdir2/subdir/test5.txt",
- "subdir2/subdir/sub",
- "subdir2/subdir/sub/test0.txt",
- "subdir2/subdir/sub/120-px-file.txt",
- );
+ $paths = array(
+ "test1.txt",
+ "test2.txt",
+ "test3.txt",
+ "subdir1",
+ "subdir1", // duplicate
+ "subdir1/test1.txt",
+ "subdir1/test2.txt",
+ "subdir2",
+ "subdir2", // duplicate
+ "subdir2/test3.txt",
+ "subdir2/test4.txt",
+ "subdir2/subdir",
+ "subdir2/subdir/test1.txt",
+ "subdir2/subdir/test2.txt",
+ "subdir2/subdir/test3.txt",
+ "subdir2/subdir/test4.txt",
+ "subdir2/subdir/test5.txt",
+ "subdir2/subdir/sub",
+ "subdir2/subdir/sub/test0.txt",
+ "subdir2/subdir/sub/120-px-file.txt",
+ );
+ for ( $i=0; $i<25; $i++ ) {
$status = $this->backend->lockFiles( $paths, LockManager::LOCK_EX );
- $this->assertEquals( array(), $status->errors,
- "Locking of files succeeded ($backendName)." );
+ $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+ "Locking of files succeeded ($backendName) ($i)." );
$this->assertEquals( true, $status->isOK(),
- "Locking of files succeeded with OK status ($backendName)." );
+ "Locking of files succeeded with OK status ($backendName) ($i)." );
$status = $this->backend->lockFiles( $paths, LockManager::LOCK_SH );
- $this->assertEquals( array(), $status->errors,
- "Locking of files succeeded ($backendName)." );
+ $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+ "Locking of files succeeded ($backendName) ($i)." );
$this->assertEquals( true, $status->isOK(),
- "Locking of files succeeded with OK status ($backendName)." );
+ "Locking of files succeeded with OK status ($backendName) ($i)." );
$status = $this->backend->unlockFiles( $paths, LockManager::LOCK_SH );
- $this->assertEquals( array(), $status->errors,
- "Locking of files succeeded ($backendName)." );
+ $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+ "Locking of files succeeded ($backendName) ($i)." );
+ $this->assertEquals( true, $status->isOK(),
+ "Locking of files succeeded with OK status ($backendName) ($i)." );
+
+ $status = $this->backend->unlockFiles( $paths, LockManager::LOCK_EX );
+ $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+ "Locking of files succeeded ($backendName). ($i)" );
+ $this->assertEquals( true, $status->isOK(),
+ "Locking of files succeeded with OK status ($backendName) ($i)." );
+
+ ## Flip the acquire/release ordering around ##
+
+ $status = $this->backend->lockFiles( $paths, LockManager::LOCK_SH );
+ $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+ "Locking of files succeeded ($backendName) ($i)." );
+ $this->assertEquals( true, $status->isOK(),
+ "Locking of files succeeded with OK status ($backendName) ($i)." );
+
+ $status = $this->backend->lockFiles( $paths, LockManager::LOCK_EX );
+ $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+ "Locking of files succeeded ($backendName) ($i)." );
$this->assertEquals( true, $status->isOK(),
- "Locking of files succeeded with OK status ($backendName)." );
+ "Locking of files succeeded with OK status ($backendName) ($i)." );
$status = $this->backend->unlockFiles( $paths, LockManager::LOCK_EX );
- $this->assertEquals( array(), $status->errors,
- "Locking of files succeeded ($backendName)." );
+ $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+ "Locking of files succeeded ($backendName). ($i)" );
$this->assertEquals( true, $status->isOK(),
- "Locking of files succeeded with OK status ($backendName)." );
+ "Locking of files succeeded with OK status ($backendName) ($i)." );
+
+ $status = $this->backend->unlockFiles( $paths, LockManager::LOCK_SH );
+ $this->assertEquals( print_r( array(), true ), print_r( $status->errors, true ),
+ "Locking of files succeeded ($backendName) ($i)." );
+ $this->assertEquals( true, $status->isOK(),
+ "Locking of files succeeded with OK status ($backendName) ($i)." );
}
+
+ $status = Status::newGood();
+ $sl = $this->backend->getScopedFileLocks( $paths, LockManager::LOCK_EX, $status );
+ $this->assertType( 'ScopedLock', $sl,
+ "Scoped locking of files succeeded ($backendName)." );
+ $this->assertEquals( array(), $status->errors,
+ "Scoped locking of files succeeded ($backendName)." );
+ $this->assertEquals( true, $status->isOK(),
+ "Scoped locking of files succeeded with OK status ($backendName)." );
+
+ ScopedLock::release( $sl );
+ $this->assertEquals( null, $sl,
+ "Scoped unlocking of files succeeded ($backendName)." );
+ $this->assertEquals( array(), $status->errors,
+ "Scoped unlocking of files succeeded ($backendName)." );
+ $this->assertEquals( true, $status->isOK(),
+ "Scoped unlocking of files succeeded with OK status ($backendName)." );
}
// test helper wrapper for backend prepare() function