csync tests: Fix for new owncloudcmd return codes
authorChristian Kamm <mail@ckamm.de>
Mon, 3 Jul 2017 09:48:04 +0000 (11:48 +0200)
committerChristian Kamm <mail@ckamm.de>
Mon, 3 Jul 2017 09:48:38 +0000 (11:48 +0200)
These were introduced in 4af45394f9f61fbc68c9f0a4d2e5387d14052e3b

csync/tests/ownCloud/ownCloud/Test.pm
csync/tests/ownCloud/t4.pl
csync/tests/ownCloud/t7.pl
csync/tests/ownCloud/t8.pl

index ee3d557294b9d3f2ae892ddf6b14387b308af18b..0034b0e6bfe92c652bfdb4ca2ce9f87edf7b2429 100644 (file)
@@ -294,15 +294,13 @@ sub localCleanup($)
     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;
@@ -317,7 +315,8 @@ sub csync( ;$ )
     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");
 }
 
 #
index e862abebb0147c617e6aca134348390bb2d11557..aeccd2a767005ebeef0208dd1189626e59623994 100755 (executable)
@@ -79,7 +79,8 @@ printInfo("Add a file in a read only directory");
 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' );
 
index 117b998fe80d91fd67aa69d1109967e14e7ffa71..6b68a06efa569b8806a1bae8b69f387ddafd7a5f 100755 (executable)
@@ -102,10 +102,6 @@ system("echo '__modified' > ". localDir() . "normalDirectory_PERM_CKDNV_/canBeMo
 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 );
 
@@ -113,7 +109,6 @@ createLocalFile( localDir() . "normalDirectory_PERM_CKDNV_/newFile_PERM_WDNV_.da
 csync();
 assertCsyncJournalOk(localDir());
 
-
 #1.
 # File should be recovered
 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
 
 #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
@@ -146,11 +158,6 @@ assert( -e localDir() . "readonlyDirectory_PERM_M_/newFile_PERM_WDNV_.data" );
 # 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);
 
@@ -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)
 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.
index 1a0557d7fe3aaff4da94cfddbea3be24ec6d3c21..4628344da030c40290d89eb7d8816b131b1eba7f 100755 (executable)
@@ -54,7 +54,8 @@ createLocalFile( $tmpdir . "test.dat", 170 );
 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
@@ -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/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' );
@@ -87,13 +89,16 @@ assert( -e localDir() . 'dir/Normal.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' );
 
@@ -107,7 +112,6 @@ csync();
 # 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
@@ -125,7 +129,8 @@ createLocalFile( $tmpdir2 . "file.dat",       33 );
 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') );