csync tests: Fix for new owncloudcmd return codes

These were introduced in 4af45394f9
This commit is contained in:
Christian Kamm 2017-07-03 11:48:04 +02:00
parent 0f70bd7913
commit bdb8a4a0cb
4 changed files with 37 additions and 24 deletions

View file

@ -294,15 +294,13 @@ sub localCleanup($)
system( "rm -rf $dir" ); system( "rm -rf $dir" );
} }
# parameter: An optional full url to the owncloud sync dir. # parameter: the expected return code
sub csync( ;$ ) sub csync( ;$ )
{ {
my ($aurl) = @_; my $expected = $_[0] // 0;
print "EXPECTED $expected\n";
my $url = testDirUrl(); my $url = testDirUrl();
if( $aurl ) {
$url = $aurl;
}
if( $url =~ /^https:/ ) { if( $url =~ /^https:/ ) {
$url =~ s#^https://##; # Remove the leading http:// $url =~ s#^https://##; # Remove the leading http://
$url = "ownclouds://$user:$passwd@". $url; $url = "ownclouds://$user:$passwd@". $url;
@ -317,7 +315,8 @@ sub csync( ;$ )
my $cmd = "LD_LIBRARY_PATH=$ld_libpath $csync $args $localDir $url"; my $cmd = "LD_LIBRARY_PATH=$ld_libpath $csync $args $localDir $url";
print "Starting: $cmd\n"; 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");
} }
# #

View file

@ -79,7 +79,8 @@ printInfo("Add a file in a read only directory");
system( "echo \"Hello World\" >> /tmp/kernelcrash.txt" ); system( "echo \"Hello World\" >> /tmp/kernelcrash.txt" );
put_to_dir( '/tmp/kernelcrash.txt', 'test_stat' ); 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' ); assert( ! -e localDir().'test_stat/kernelcrash' );

View file

@ -102,10 +102,6 @@ system("echo '__modified' > ". localDir() . "normalDirectory_PERM_CKDNV_/canBeMo
system("echo '__modified_' > ". localDir() . "readonlyDirectory_PERM_M_/canBeModified_PERM_W_.data"); system("echo '__modified_' > ". localDir() . "readonlyDirectory_PERM_M_/canBeModified_PERM_W_.data");
#5. Create a new file in a read only folder #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) # (should be uploaded)
createLocalFile( localDir() . "normalDirectory_PERM_CKDNV_/newFile_PERM_WDNV_.data", 106 ); createLocalFile( localDir() . "normalDirectory_PERM_CKDNV_/newFile_PERM_WDNV_.data", 106 );
@ -113,7 +109,6 @@ createLocalFile( localDir() . "normalDirectory_PERM_CKDNV_/newFile_PERM_WDNV_.da
csync(); csync();
assertCsyncJournalOk(localDir()); assertCsyncJournalOk(localDir());
#1. #1.
# File should be recovered # File should be recovered
assert( -e localDir(). 'normalDirectory_PERM_CKDNV_/cannotBeRemoved_PERM_WVN_.data' ); assert( -e localDir(). 'normalDirectory_PERM_CKDNV_/cannotBeRemoved_PERM_WVN_.data' );
@ -139,6 +134,23 @@ system("rm " . localDir().'readonlyDirectory_PERM_M_/canotBeModified_PERM_DVN__c
#4. File should be updated, that's tested by assertLocalAndRemoteDir #4. File should be updated, that's tested by assertLocalAndRemoteDir
#5. #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 # The file should not exist on the remote
# TODO: test that the file is NOT on the server # TODO: test that the file is NOT on the server
# but still be there # but still be there
@ -146,11 +158,6 @@ assert( -e localDir() . "readonlyDirectory_PERM_M_/newFile_PERM_WDNV_.data" );
# remove it so assertLocalAndRemoteDir succeed. # remove it so assertLocalAndRemoteDir succeed.
unlink(localDir() . "readonlyDirectory_PERM_M_/newFile_PERM_WDNV_.data"); 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 ### Both side should still be the same
assertLocalAndRemoteDir( '', 0); assertLocalAndRemoteDir( '', 0);
@ -207,7 +214,8 @@ system("mv " . localDir().'readonlyDirectory_PERM_M_/subdir_PERM_CK_ ' . localDi
#2. move a directory from read to read only (move the directory from previous step) #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_' ); 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()); assertCsyncJournalOk(localDir());
#1. #1.

View file

@ -54,7 +54,8 @@ createLocalFile( $tmpdir . "test.dat", 170 );
createRemoteDir( "dir" ); createRemoteDir( "dir" );
glob_put( "$tmpdir/*", "dir" ); glob_put( "$tmpdir/*", "dir" );
csync(); # can't download these
csync(1);
# Check that only one of the two file was synced. # Check that only one of the two file was synced.
# The one that exist here is undefined, the current implementation will take the # The one that exist here is undefined, the current implementation will take the
@ -76,7 +77,8 @@ printInfo( "Renaming one file to the same name as another one with different cas
moveRemoteFile( 'dir/Hello.dat', 'dir/NORMAL.dat'); moveRemoteFile( 'dir/Hello.dat', 'dir/NORMAL.dat');
moveRemoteFile( 'dir/test.dat', 'dir/TEST.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 # Hello -> NORMAL should not have do the move since the case conflict
assert( -e localDir() . 'dir/Hello.dat' ); assert( -e localDir() . 'dir/Hello.dat' );
@ -87,13 +89,16 @@ assert( -e localDir() . 'dir/Normal.dat' );
assert( -e localDir() . 'dir/TEST.dat' ); assert( -e localDir() . 'dir/TEST.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" ); printInfo( "Another directory with the same name but different casing is created" );
createRemoteDir( "DIR" ); createRemoteDir( "DIR" );
glob_put( "$tmpdir/*", "DIR" ); glob_put( "$tmpdir/HELLO.dat", "DIR" );
csync(); # can't download dirs
csync(1);
assert( !-e localDir() . 'DIR' ); assert( !-e localDir() . 'DIR' );
@ -107,7 +112,6 @@ csync();
# now DIR was fetched # now DIR was fetched
assert( -e localDir() . 'DIR' ); assert( -e localDir() . 'DIR' );
assert( -e localDir() . 'DIR/HELLO.dat' ); assert( -e localDir() . 'DIR/HELLO.dat' );
assert( !-e localDir() . 'DIR/Hello.dat' );
assert( !-e localDir() . 'dir' ); assert( !-e localDir() . 'dir' );
# dir/NORMAL.dat is still on the server # dir/NORMAL.dat is still on the server
@ -125,7 +129,8 @@ createLocalFile( $tmpdir2 . "file.dat", 33 );
createRemoteDir( "parallel" ); createRemoteDir( "parallel" );
glob_put( "$tmpdir2/*", "parallel" ); glob_put( "$tmpdir2/*", "parallel" );
csync(); # again, can't download both
csync(1);
# only one file must exist # only one file must exist
assert( (!-e localDir() . 'parallel/FILE.dat' ) or (!-e localDir() . 'parallel/file.dat') ); assert( (!-e localDir() . 'parallel/FILE.dat' ) or (!-e localDir() . 'parallel/file.dat') );