s3/script/tests: Ensure all remote test files are removed
authorJeremy Allison <jra@samba.org>
Mon, 30 Nov 2020 17:19:29 +0000 (17:19 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 1 Dec 2020 19:06:45 +0000 (19:06 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
source3/script/tests/test_smbclient_tarmode.pl

index c0c35b937326b3f02238111ecdf61c79c78814f4..bdbbd1a44a806f57ee33e8dae3ff789db0873852 100755 (executable)
@@ -921,7 +921,22 @@ Remove all files in the server C<$DIR> (not root)
 sub reset_remote {
     # remove_tree($LOCALPATH . '/'. $DIR);
     # make_path($LOCALPATH . '/'. $DIR);
+    my $DIR;
+    my @names;
+    my $name;
+
     smb_client_cmd(0, '-c', "deltree ./*");
+
+    # Ensure all files are gone.
+
+    opendir(DIR,$LOCALPATH) or die "Can't open $LOCALPATH\n";
+    @names = readdir(DIR) or die "Unable to read $LOCALPATH\n";
+    closedir(DIR);
+    foreach $name (@names) {
+       next if ($name eq ".");   # skip the current directory entry
+       next if ($name eq "..");  # skip the parent  directory entry
+       die "$LOCALPATH not empty\n";
+    }
 }
 
 =head3 C<reset_tmp( )>