]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Add function to test atime with expected value in check_protect()
authorEric Bollengier <eric@baculasystems.com>
Fri, 31 Mar 2023 09:21:26 +0000 (11:21 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:01 +0000 (13:57 +0200)
regress/scripts/functions.pm

index eddca8d23f2e5d3a6b5f8939cc657f8c7033185e..65099b8392a59ea5f7e4184be96d19880ddb5d57 100644 (file)
@@ -2597,7 +2597,20 @@ sub get_perm
 # Parse the output of llist volume to check the protection parameters
 sub check_protect
 {
-    my ($file, $name, $status, $protect, $useprotect) = @_;
+    my ($file, $name, $status, $protect, $useprotect, $atime) = @_;
+
+    if ($atime) {
+        my @attr = stat("$tmp/$name") or die "Unable to find $tmp/$name";
+        if ($attr[8] > ($attr[9] + $atime + 2) || $attr[8] < ($attr[9] + $atime - 2)) {
+            print "ERROR: the atime value is not correct fname=$tmp/$name atime=$attr[8] mtime=$attr[9] diff=$atime\n";
+            exit 1;
+        }
+        if ($protect && ($attr[2] & 07777) != 0400) {
+            print "ERROR: $tmp/$name is not protected mode=", $attr[2] & 07777, "\n";
+            exit 1;
+        }
+    }
+
     open(FP, $file) or die "Unable to open $file. $!";
     my $found=0;
     while (my $line = <FP>) {