system( "rm -rf $dir" );
}
-# parameter: An optional full url to the owncloud sync dir.
+# parameter: the expected return code
sub csync( ;$ )
{
- my ($aurl) = @_;
+ my $expected = $_[0] // 0;
+ print "EXPECTED $expected\n";
my $url = testDirUrl();
- if( $aurl ) {
- $url = $aurl;
- }
if( $url =~ /^https:/ ) {
$url =~ s#^https://##; # Remove the leading http://
$url = "ownclouds://$user:$passwd@". $url;
my $cmd = "LD_LIBRARY_PATH=$ld_libpath $csync $args $localDir $url";
print "Starting: $cmd\n";
- system( $cmd ) == 0 or die("CSync died!\n");
+ my $result = system( $cmd );
+ $result == ($expected << 8) or die("Wrong csync return code or crash! $result\n");
}
#
system( "echo \"Hello World\" >> /tmp/kernelcrash.txt" );
put_to_dir( '/tmp/kernelcrash.txt', 'test_stat' );
-csync();
+# Sync failed, can't download file to readonly dir
+csync(1);
assert( ! -e localDir().'test_stat/kernelcrash' );
system("echo '__modified_' > ". localDir() . "readonlyDirectory_PERM_M_/canBeModified_PERM_W_.data");
#5. Create a new file in a read only folder
-# (they should not be uploaded)
-createLocalFile( localDir() . "readonlyDirectory_PERM_M_/newFile_PERM_WDNV_.data", 105 );
-
-#6. Create a new file in a read only folder
# (should be uploaded)
createLocalFile( localDir() . "normalDirectory_PERM_CKDNV_/newFile_PERM_WDNV_.data", 106 );
csync();
assertCsyncJournalOk(localDir());
-
#1.
# File should be recovered
assert( -e localDir(). 'normalDirectory_PERM_CKDNV_/cannotBeRemoved_PERM_WVN_.data' );
#4. File should be updated, that's tested by assertLocalAndRemoteDir
#5.
+# the file should be in the server and local
+assert( -e localDir() . "normalDirectory_PERM_CKDNV_/newFile_PERM_WDNV_.data" );
+
+### Both side should still be the same
+assertLocalAndRemoteDir( '', 0);
+
+# Next test
+
+#6. Create a new file in a read only folder
+# (they should not be uploaded)
+createLocalFile( localDir() . "readonlyDirectory_PERM_M_/newFile_PERM_WDNV_.data", 105 );
+
+# error: can't upload to readonly
+csync(1);
+assertCsyncJournalOk(localDir());
+
+#6.
# The file should not exist on the remote
# TODO: test that the file is NOT on the server
# but still be there
# remove it so assertLocalAndRemoteDir succeed.
unlink(localDir() . "readonlyDirectory_PERM_M_/newFile_PERM_WDNV_.data");
-#6.
-# the file should be in the server and local
-assert( -e localDir() . "normalDirectory_PERM_CKDNV_/newFile_PERM_WDNV_.data" );
-
-
### Both side should still be the same
assertLocalAndRemoteDir( '', 0);
#2. move a directory from read to read only (move the directory from previous step)
system("mv " . localDir().'normalDirectory_PERM_CKDNV_/subdir_PERM_CKDNV_ ' . localDir().'readonlyDirectory_PERM_M_/moved_PERM_CK_' );
-csync();
+# error: can't upload to readonly!
+csync(1);
assertCsyncJournalOk(localDir());
#1.
createRemoteDir( "dir" );
glob_put( "$tmpdir/*", "dir" );
-csync();
+# can't download these
+csync(1);
# Check that only one of the two file was synced.
# The one that exist here is undefined, the current implementation will take the
moveRemoteFile( 'dir/Hello.dat', 'dir/NORMAL.dat');
moveRemoteFile( 'dir/test.dat', 'dir/TEST.dat');
-csync();
+# can't download these
+csync(1);
# Hello -> NORMAL should not have do the move since the case conflict
assert( -e localDir() . 'dir/Hello.dat' );
assert( -e localDir() . 'dir/TEST.dat' );
assert( !-e localDir() . 'dir/test.dat' );
+# undo the change that causes the sync fail
+moveRemoteFile( 'dir/NORMAL.dat', 'dir/Hello.dat');
printInfo( "Another directory with the same name but different casing is created" );
createRemoteDir( "DIR" );
-glob_put( "$tmpdir/*", "DIR" );
+glob_put( "$tmpdir/HELLO.dat", "DIR" );
-csync();
+# can't download dirs
+csync(1);
assert( !-e localDir() . 'DIR' );
# now DIR was fetched
assert( -e localDir() . 'DIR' );
assert( -e localDir() . 'DIR/HELLO.dat' );
-assert( !-e localDir() . 'DIR/Hello.dat' );
assert( !-e localDir() . 'dir' );
# dir/NORMAL.dat is still on the server
createRemoteDir( "parallel" );
glob_put( "$tmpdir2/*", "parallel" );
-csync();
+# again, can't download both
+csync(1);
# only one file must exist
assert( (!-e localDir() . 'parallel/FILE.dat' ) or (!-e localDir() . 'parallel/file.dat') );