]>
git.proxmox.com Git - pve-storage.git/blob - test/archive_info_test.pm
283fe47a266df97b49668c4196fa19e92149292a
1 package PVE
::Storage
::TestArchiveInfo
;
13 # an array of test cases, each test is comprised of the following keys:
14 # description => to identify a single test
15 # archive => the input filename for archive_info
16 # expected => the hash that archive_info returns
18 # most of them are created further below
22 description
=> 'Backup archive, lxc, tgz',
23 archive
=> "backup/vzdump-lxc-$vmid-2020_03_30-21_39_30.tgz",
27 'decompressor' => ['tar', '-z'],
28 'compression' => 'gz',
32 description
=> 'Backup archive, openvz, tgz',
33 archive
=> "backup/vzdump-openvz-$vmid-2020_03_30-21_39_30.tgz",
37 'decompressor' => ['tar', '-z'],
38 'compression' => 'gz',
43 # add new compression fromats to test
47 lzo
=> ['tar', '--lzop'],
48 zst
=> ['tar', '--zstd'],
52 lzo
=> ['lzop', '-d', '-c'],
53 zst
=> ['zstd', '-q', '-d', '-c'],
58 qemu
=> [ 'vma', $decompressor->{vma
}, ],
59 lxc
=> [ 'tar', $decompressor->{tar
}, ],
60 openvz
=> [ 'tar', $decompressor->{tar
}, ],
63 # create more test cases for backup files matches
64 foreach my $virt (keys %$bkp_suffix) {
65 my ($format, $decomp) = @{ $bkp_suffix->{$virt} };
67 foreach my $suffix (keys %$decomp) {
70 description
=> "Backup archive, $virt, $format.$suffix",
71 archive
=> "backup/vzdump-$virt-$vmid-2020_03_30-21_12_40.$format.$suffix",
74 'format' => "$format",
75 'decompressor' => $decomp->{$suffix},
76 'compression' => "$suffix",
86 # add compression formats to test failed matches
87 my $non_bkp_suffix = {
88 'openvz' => [ 'zip', 'tgz.lzo', 'tar.bz2', 'zip.gz', '', ],
89 'lxc' => [ 'zip', 'tgz.lzo', 'tar.bz2', 'zip.gz', '', ],
90 'qemu' => [ 'vma.xz', 'vms.gz', 'vmx.zst', '', ],
91 'none' => [ 'tar.gz', ],
94 # create tests for failed matches
95 foreach my $virt (keys %$non_bkp_suffix) {
96 my $suffix = $non_bkp_suffix->{$virt};
97 foreach my $s (@$suffix) {
100 description
=> "Failed match: Backup archive, $virt, $s",
101 archive
=> "backup/vzdump-$virt-$vmid-2020_03_30-21_12_40.$s",
102 expected
=> "ERROR: couldn't determine format and compression type\n",
111 plan tests
=> scalar @$tests;
113 # run through tests array
114 foreach my $tt (@$tests) {
115 my $description = $tt->{description
};
116 my $archive = $tt->{archive
};
117 my $expected = $tt->{expected
};
119 eval { $got = PVE
::Storage
::archive_info
($archive) };
122 is_deeply
($got, $expected, $description) || diag
(explain
($got));