aboutsummaryrefslogtreecommitdiffstats
path: root/t_install_iso/010_check_autorun.t
blob: 757951ec30ea2f8221c91e14b20942b793f85fb5 (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#
# Check autorun
#
use Test::Most tests => 13;
use File::Basename;
use Tools;

my ($image_path) = @ARGV;

my $name = basename($image_path);

bail_on_fail;

set_failure_handler( sub {
    print "umount iso\n";
    system 'umount /media/iso_check; rm -r /media/iso_check';
});

my %info = Tools::parse_mageia_iso_name($name);
skip 'Autorun is only on DVDs.', 13 unless $info{"medium"} eq 'DVD';

#
ok (-r "/media/iso_check/autorun.inf", 'autorun.inf is there');

BAIL_OUT('Autorun stuff is missing anyway.') if !(-r "/media/iso_check/autorun.inf");

#
my $lines = `cat -e /media/iso_check/autorun.inf | wc -l`;
my $num   = `cat -e /media/iso_check/autorun.inf | grep "\\^M" | wc -l`;
chomp($num);
chomp($lines);
my $last = `cat -e /media/iso_check/autorun.inf | tail -n 1 | grep "\\^M" | wc -l`;

# TODO rewrite this
if ( ($lines != $num && $lines - 1 != $num)
    || ($lines == 0)
    || ($lines -1 == $num && $last == 1)) {
    fail('autorun.inf valid EOL chars');
} else {
    pass('autorun.inf valid EOL chars');
}

#
my $directory;
$directory = "/media/iso_check/autorun/" if -r "/media/iso_check/autorun";
$directory = "/media/iso_check/dosutils/autorun/" if -r "/media/iso_check/dosutils/autorun";
ok -r $directory, 'dosutils directory is there';

#
my $exe = $directory . "autorun.exe";
ok -r $exe, 'autorun.exe is there';

BAIL_OUT('autorun.exe is not here.') if !(-r $exe);

#
my $file = $directory . "autorun.ico";
$file = $directory . "mageia.ico" if !(-r $file);
ok -r $file, 'autorun.ico is there';

#
foreach my $a ("de-DE/", "es-ES/", "fr-FR/", "it-IT/", "pt-BR/", "ru-RU/", "zh-CN/") {
    $file = $directory . $a . "autorun.resources.dll";
    ok -r $file, "$file is there";
}

# FIXME what does this do? does it work?
# in the meantime, skipped
SKIP: {
    skip 'Not clear what this does', 1 unless 0;

    my $_cp = `cp $exe .`;
    eval {
        local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
        alarm 5;
        my $_nread = sysread my $_SOCKET, my $_buffer, my $_size;
        my $_mono = `mono autorun.exe 2> autorun_exe.log`;
        alarm 0;
        if ($@) {
            die unless $@ eq "alarm\n"; # propagate unexpected errors
            # timed out
        } else {
            # didn't
        }
    };

    open(my $exe_log, 'autorun_exe.log');
    my $line = <$exe_log>;

    isnt (substr($line, 0, 20), 'Cannot open assembly', 'autorun.exe is launchable');

    my $_rm = `rm autorun.exe autorun_exe.log`;
}

done_testing();