13 use PVE
::Tools
qw(dir_glob_foreach file_get_contents);
15 my $INPUT_DIR = './restore-config-input';
16 my $EXPECTED_DIR = './restore-config-expected';
18 # NOTE update when you add/remove tests
21 dir_glob_foreach
('./restore-config-input', '[0-9]+.conf', sub {
24 my $vmid = basename
($file, ('.conf'));
26 my $fh = IO
::File-
>new("${INPUT_DIR}/${file}", "r") or
27 die "unable to read '$file' - $!\n";
32 # NOTE For now, the map is hardcoded to a file-based 'target' storage.
33 # In the future, the test could be extended to include parse_backup_hints
34 # and restore_allocate_devices. Even better if the config-related logic from
35 # the restore_XYZ_archive functions could become a separate function.
36 while (defined(my $line = <$fh>)) {
37 if ($line =~ m/^\#qmdump\#map:(\S+):(\S+):(\S*):(\S*):$/) {
38 my ($drive, undef, $storeid, $fmt) = ($1, $2, $3, $4);
42 $map->{$drive} = "target:${vmid}/vm-${vmid}-disk-${disknum}.${fmt}";
47 $fh->seek(0, 0) or die "seek failed - $!\n";
50 my $cookie = { netcount
=> 0 };
52 while (defined(my $line = <$fh>)) {
53 $got .= PVE
::QemuServer
::restore_update_config_line
(
62 my $expected = file_get_contents
("${EXPECTED_DIR}/${file}");
64 is_deeply
($got, $expected, $file);