aboutsummaryrefslogtreecommitdiffstats
path: root/isocheck.pl
blob: 7c4f9b7321bf228fdcb77af16e94d3594c9df9f8 (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
#!/usr/bin/perl -w 
#
# This file is part of the Mageia project
#   Copyright (C) 2011 Damien Lallement <dams@mageia.org>
#             (C) 2011 Romain d'Alverny <rda@mageia.org>
#
#   This library is free software; you can redistribute it and/or
#   modify it under the terms of the GNU Library General Public
#   License as published by the Free Software Foundation; either
#   version 2 of the License, or (at your option) any later version.
#
#   This library is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   Library General Public License for more details.
#
#   You should have received a copy of the GNU Library General Public License
#   along with this library; see the file COPYING.LIB.  If not, write to
#   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
#   Boston, MA 02110-1301, USA.
#

use 5.010;
use MDK::Common;
use TAP::Harness;
use TAP::Parser::Aggregator;
use MDK::ISOcheck;

my ($image_path) = @ARGV;

if (!defined $image_path) {
    print "Usage: isocheck [ISO file]\nTry `./test_iso.pl --help' for more information.\n";
    exit;
}

my $harness = TAP::Harness->new({
    formatter_class => 'TAP::Formatter::Console',
    merge           => 1,
    verbosity       => 1,
    normalize       => 1,
    color           => 1,
    test_args       => [
        $image_path,
        "Testing"
    ]
});

my $ts0 = time();

print "# Date\t\t: ", `date --rfc-3339='ns' -u`;
print "# Testing\t: $image_path\n";
print "# Host\t\t: ", `uname -n`;

my $aggregator = TAP::Parser::Aggregator->new;
$aggregator->start;
$harness->aggregate_tests($aggregator, glob('image_tests/*.t'));

my $name = basename($image_path);
my %info = parse_image_file_name($name);
my @testfiles;

if (defined $info{variant} && $info{variant} =~ /^LiveCD/) {
    @testfiles = glob('image_tests/live_iso/*.t');
} else {
    @testfiles = glob('image_tests/install_iso/*.t');
}

if (@testfiles) {
    print "# Mounting ISO in /media/iso_check\n";
    -r "/media/iso_check" or mkdir('/media/iso_check');
    system "mount -r " . if_(!-b $image_path, "-o loop ") . "$image_path /media/iso_check/";

    $harness->aggregate_tests($aggregator, @testfiles);

    print "# Umounting ISO\n";
    system('umount -l', '/media/iso_check');
    rmdir('/media/iso_check');
}

$aggregator->stop;
$harness->summary($aggregator);

my $tdiff = time() - $ts0;
print "# Tested $name in $tdiff seconds.\n";

print $aggregator->all_passed, "\n", $aggregator->get_status, "\n";

exit($aggregator->all_passed ? 0 : 1);