]> git.proxmox.com Git - pve-container.git/commitdiff
use real days in setup tests
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 21 Jun 2018 12:14:26 +0000 (14:14 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 21 Aug 2018 08:02:27 +0000 (10:02 +0200)
so that we can drop the special case in the real code,
use the real time in the tests

for that we replace the special string '@DAYS@' with
the correct value, and reset the file afterwards

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/PVE/LXC/Setup/Base.pm
src/test/run_setup_tests.pl
src/test/test-debian-009/etc/shadow.exp
src/test/test-debian-014/etc/shadow.exp

index 2f346e9b6c5e87bacfba74121da36afa589b6690..964d8d57d55730c5de44a219cfef62f0132fd5d7 100644 (file)
@@ -324,10 +324,6 @@ my $replacepw  = sub {
 
        my $last_change = int(time()/(60*60*24));
 
-       if ($epw =~ m/^\$TEST\$/) { # for regression tests
-           $last_change = 12345;
-       }
-       
        while (defined (my $line = <$src>)) {
            if ($shadow) {
                $line =~ s/^${user}:[^:]*:[^:]*:/${user}:${epw}:${last_change}:/;
index b103cfa57301727188195e686ea9cc79130a7654..bae94e8194d49baa44e762e280188740808cb1e0 100755 (executable)
@@ -12,7 +12,16 @@ use PVE::LXC::Setup;
 sub test_file {
     my ($exp_fn, $real_fn) = @_;
 
-    return if system("diff -u '$exp_fn' '$real_fn'") == 0;
+    # replace @DAYS@ with the current correct value
+    if ($exp_fn =~ m/shadow.exp$/) {
+       my $expecteddays = int(time()/(60*60*24));
+       system ("sed -i.bak 's/\@DAYS\@/$expecteddays/' $exp_fn");
+       my $ret = system("diff -u '$exp_fn' '$real_fn'");
+       system("mv '$exp_fn.bak' '$exp_fn'");
+       return if $ret == 0;
+    } else {
+       return if system("diff -u '$exp_fn' '$real_fn'") == 0;
+    }
 
     die "files do not match\n";
 }
index deb9e2dd4cf9d75e49f70e51f710d02ba66fff14..34768b5ddb1d710a1382dcb6a00b4f59c14c321b 100644 (file)
@@ -1,4 +1,4 @@
-root:$TEST$ABCDEF:12345:0:99999:7:::
+root:$TEST$ABCDEF:@DAYS@:0:99999:7:::
 daemon:*:15908:0:99999:7:::
 bin:*:15908:0:99999:7:::
 sys:*:15908:0:99999:7:::
index deb9e2dd4cf9d75e49f70e51f710d02ba66fff14..34768b5ddb1d710a1382dcb6a00b4f59c14c321b 100644 (file)
@@ -1,4 +1,4 @@
-root:$TEST$ABCDEF:12345:0:99999:7:::
+root:$TEST$ABCDEF:@DAYS@:0:99999:7:::
 daemon:*:15908:0:99999:7:::
 bin:*:15908:0:99999:7:::
 sys:*:15908:0:99999:7:::