1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#! /usr/bin/perl -Idebian/tests/lib
use diagnostics;
use strict;
use warnings;
use AdduserTestsCommon;
my $name="ausbackup";
END {
remove_tree("/var/mail/$name");
}
test_suffix('gz', 'gzip');
test_suffix('bz2', 'bzip2');
test_suffix('lzo', 'lzop');
test_suffix('xz', 'xz');
test_suffix('zst', 'zstd');
sub test_suffix {
my ($suffix, $program) = @_;
my ($archive, $file_list);
assert_user_does_not_exist($name);
assert_command_success(
'/usr/sbin/adduser',
'--stdoutmsglevel=error', '--stderrmsglevel=error',
'--system',
'--home', "/home/$name",
$name
);
assert_user_exists($name);
open (FH, '>', "/home/$name/test.txt");
print FH 'created by adduser/backups.t';
close (FH);
assert_command_success_silent(
'/usr/sbin/deluser',
'--stdoutmsglevel=error', '--stderrmsglevel=error',
'--remove-home',
'--backup-to', '/tmp',
'--backup-suffix', $suffix,
$name
);
assert_user_does_not_exist($name);
$archive = "/tmp/$name.tar.".((&which($program, 1)) ? $suffix : 'gz');
assert_path_exists($archive);
assert_path_has_ownership($archive, 'root:root');
assert_path_has_mode($archive, "0600");
$file_list = `tar tf $archive 2>/dev/null`;
ok($? == 0, "archive $archive ($suffix) listing successful");
ok($file_list =~ qr{home/$name/test.txt}, 'archive contents are correct');
unlink($archive);
}
# vim: tabstop=4 shiftwidth=4 expandtab
|