diff options
author | Romain d'Alverny <rda@mageia.org> | 2011-12-10 19:28:30 +0000 |
---|---|---|
committer | Romain d'Alverny <rda@mageia.org> | 2011-12-10 19:28:30 +0000 |
commit | 1e65efa6a3d996c34c902f2b04257307c2175776 (patch) | |
tree | 635ae0d5dc31d6bf186b0dc50a8d510d49474f2e | |
parent | fa4a16119ca7e744aee9b29b8a70ce01aa2516f0 (diff) | |
download | isocheck-1e65efa6a3d996c34c902f2b04257307c2175776.tar isocheck-1e65efa6a3d996c34c902f2b04257307c2175776.tar.gz isocheck-1e65efa6a3d996c34c902f2b04257307c2175776.tar.bz2 isocheck-1e65efa6a3d996c34c902f2b04257307c2175776.tar.xz isocheck-1e65efa6a3d996c34c902f2b04257307c2175776.zip |
more code style fixes (perl_checker & tv)
-rw-r--r-- | Tools.pm | 19 | ||||
-rw-r--r-- | t/000_test_env.t | 2 | ||||
-rw-r--r-- | t/001_check_file.t | 22 | ||||
-rw-r--r-- | t/003_is_hybrid.t | 2 | ||||
-rw-r--r-- | t_install_iso/010_check_autorun.t | 10 | ||||
-rw-r--r-- | t_install_iso/012_check_ids.t | 2 | ||||
-rw-r--r-- | t_install_iso/013_check_rpms.t | 2 | ||||
-rw-r--r-- | t_install_iso/016_check_pubkey.t | 24 | ||||
-rw-r--r-- | test_iso.pl | 13 |
9 files changed, 45 insertions, 51 deletions
@@ -29,23 +29,18 @@ our $VERSION = '0.1'; use base 'Exporter'; -#our @EXPORT = qw(parse_mageia_iso_name); +our @EXPORT = qw(parse_mageia_iso_name); sub parse_mageia_iso_name { my ($name) = @_; my %info; - if ($name =~ m/^(Mageia)-(\d+)(-(alpha|beta|RC)(\d*))?(-(.*))?-(i586|x86_64|dual)?(-(CD|DVD|BD))?(-(build_\w+))?\.(.*)$/) { - $info{full} = $name; - $info{name} = $1 if defined $1; - $info{version} = $2 if defined $2; - $info{release} = "$4$5" if defined $4; - $info{variant} = $7 if defined $7; - $info{arch} = $8 if defined $8; - $info{medium} = $10 if defined $10; - $info{build} = $12 if defined $12; - $info{ext} = $13 if defined $13; - + if ((@info{qw(name version release variant arch medium build ext)}) + = $name =~ m/^(Mageia)-(\d+)-((?:alpha|beta|RC)\d*)?(-(?:.*))?-(i586|x86_64|dual)?(?:-(CD|DVD|BD))?(?:-(build_\w+))?\.(.*)$/) + { + $info{full} = $name; + } else { + %info = (); } return %info; diff --git a/t/000_test_env.t b/t/000_test_env.t index 9ad445d..cf7abc2 100644 --- a/t/000_test_env.t +++ b/t/000_test_env.t @@ -30,7 +30,7 @@ my ($image_path) = @ARGV; is($ENV{USERNAME}, 'root', "Current user is root."); # TODO move this elsewhere maybe? -sub pkg_check { my ($pkg) = @_; return system("rpm -q $pkg >/dev/null"); } +sub pkg_check { my ($pkg) = @_; return system("rpm -q $pkg >/dev/null") } my @packages = qw(cdrkit cdrkit-isotools gnupg); diff --git a/t/001_check_file.t b/t/001_check_file.t index ce36df0..022a8d7 100644 --- a/t/001_check_file.t +++ b/t/001_check_file.t @@ -34,7 +34,7 @@ bail_on_fail; if (scalar %info) { pass 'ISO has valid filename.'; while (my ($k, $v) = each %info) { - note uc($k), "=$v\n"; + note uc($k), "=$v\n" if defined $v; } } else { fail 'ISO has valid filename.'; @@ -42,7 +42,7 @@ if (scalar %info) { } # are files available? -ok -r $image_path, 'ISO file is readable.' +ok(-r $image_path, 'ISO file is readable.') or diag("$image_path: $!"); # is file size correct? @@ -52,19 +52,19 @@ my $size = $size_name[0]; # Correct sizes: CD == 700MB & DVD == 4,700.373MB my %max_sizes = ("CD" => "700MB", "DVD" => "4700MB"); -ok $size le $max_sizes{$info{medium}}, +ok($size le $max_sizes{$info{medium}}, sprintf("File has a working size (%s) for its medium type (%s, max %s).", - $size, $info{medium}, $max_sizes{$info{medium}}); + $size, $info{medium}, $max_sizes{$info{medium}})); # -ok -r $image_path . '.md5', 'MD5 checksum is available.'; -ok -r $image_path . '.sha1', 'SHA1 checkum is available.'; +ok(-r $image_path . '.md5', 'MD5 checksum is available.'); +ok(-r $image_path . '.sha1', 'SHA1 checkum is available.'); TODO: { local $TODO = ".idx & .lst" if 1; - ok -r $image_path, '.idx list file is available.'; - ok -r $image_path, '.lst list file is available.'; + ok(-r $image_path, '.idx list file is available.'); + ok(-r $image_path, '.lst list file is available.'); } @@ -82,7 +82,7 @@ is($md5, $md5file, 'MD5/.md5 checksums match.'); my $sha1 = $ts[0]; @ts = split(/ /, `cat $sha1file`); $sha1file = $ts[0]; -is $sha1, $sha1file, 'SHA1/.sha1 checksums match.'; +is($sha1, $sha1file, 'SHA1/.sha1 checksums match.'); # check ISO header info @@ -94,7 +94,7 @@ my %isoValues = ( "Volume set id", "$info{name} $info{version} $info{release} $info{variant} $info{arch} $info{medium}", # TODO $info{'build'} ? "Publisher id", "Mageia.Org", "Data preparer id", "", # ? - "Copyright File id", "http://www.mageia.org/2/license/" + "Copyright File id", "http://www.mageia.org/2/license/", "Abstract File id", "http://www.mageia.org/2/" ); @@ -120,7 +120,7 @@ my $result = `cat is_burnable.log | grep overburn | wc -l | tr -d '\n'`; -r "is_burnable.log" and system "rm is_burnable.log"; -is $result, 0, "ISO can be burnt."; +is($result, 0, "ISO can be burnt."); done_testing(); diff --git a/t/003_is_hybrid.t b/t/003_is_hybrid.t index c1b0c25..dd89fd7 100644 --- a/t/003_is_hybrid.t +++ b/t/003_is_hybrid.t @@ -24,7 +24,7 @@ bail_on_fail; my ($image_path) = @ARGV; -ok is_hybrid($image_path, 0), "Is hybrid"; +ok(is_hybrid($image_path, 0), "Is hybrid"); # Verification if the ISO is hybrid sub is_hybrid { diff --git a/t_install_iso/010_check_autorun.t b/t_install_iso/010_check_autorun.t index ce6000a..ce607fe 100644 --- a/t_install_iso/010_check_autorun.t +++ b/t_install_iso/010_check_autorun.t @@ -36,7 +36,7 @@ set_failure_handler(sub { }); # -ok -r "/media/iso_check/autorun.inf", 'autorun.inf is there'; +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"); @@ -62,23 +62,23 @@ if ($lines != $num && $lines - 1 != $num 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'; +ok(-r $directory, 'dosutils directory is there'); # my $exe = $directory . "autorun.exe"; -ok -r $exe, 'autorun.exe is there'; +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'; +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"; + ok(-r $file, "$file is there"); } done_testing(); diff --git a/t_install_iso/012_check_ids.t b/t_install_iso/012_check_ids.t index b7161af..56eed85 100644 --- a/t_install_iso/012_check_ids.t +++ b/t_install_iso/012_check_ids.t @@ -36,6 +36,6 @@ $valid2 = -r "/media/iso_check/x86_64/isolinux/pci.ids" if -r "/media/iso_check/ $valid &= $valid2 if -r "/media/iso_check/x86_64" && -r "/media/iso_check/i586"; $valid = $valid2 if -r "/media/iso_check/x86_64" && !$valid; -ok $valid, 'HDT can find pci.ids.'; +ok($valid, 'HDT can find pci.ids.'); done_testing(); diff --git a/t_install_iso/013_check_rpms.t b/t_install_iso/013_check_rpms.t index f7c9a7a..cd329ac 100644 --- a/t_install_iso/013_check_rpms.t +++ b/t_install_iso/013_check_rpms.t @@ -38,7 +38,7 @@ while ($pkg = <$list>) { $sign = ''; chomp($pkg); $sign = `rpm -K $pkg | grep 'gpg OK'`; - ok $sign, "$pkg is correctly signed."; + ok($sign, "$pkg is correctly signed."); $valid = 0 if !$sign; } diff --git a/t_install_iso/016_check_pubkey.t b/t_install_iso/016_check_pubkey.t index d65e2bc..05eed86 100644 --- a/t_install_iso/016_check_pubkey.t +++ b/t_install_iso/016_check_pubkey.t @@ -39,24 +39,22 @@ my $media; system "ls /media/iso_check/i586/media/ > temp_media_on_iso.log" if -r "/media/iso_check/i586/media/"; system "ls /media/iso_check/x86_64/media/ >> temp_media_on_iso.log" if -r "/media/iso_check/x86_64/media/"; -ok -r "temp_media_on_iso.log", "Got a log for media contents"; +ok(-r "temp_media_on_iso.log", "Got a log for media contents"); -open(my $file, "temp_media_on_iso.log") if -r "temp_media_on_iso.log"; - -while ($media = <$file>) { - chomp($media); - if ($info{arch} ne "dual" && $media ne 'media_info') { - $path = "/media/iso_check/" . $info{arch} . "/media/$media/media_info/pubkey"; - $url = "pubkey/" . $info{arch} . "-$media-pubkey"; +foreach (cat_("temp_media_on_iso.log")) { + chomp; + if ($info{arch} ne "dual" && $_ ne 'media_info') { + $path = "/media/iso_check/" . $info{arch} . "/media/$_/media_info/pubkey"; + $url = "pubkey/" . $info{arch} . "-$_-pubkey"; #$url .= "-cooker" if !$finale; - $pubkey &= check_key($path, $url, $media, $info{arch}) if -r $path && -r $url; + $pubkey &= check_key($path, $url, $_, $info{arch}) if -r $path && -r $url; } - elsif ($media ne 'media_info') { + elsif ($_ ne 'media_info') { foreach my $arch ("i586", "x86_64") { - $path = "/media/iso_check/$arch/media/$media/media_info/pubkey"; - $url = "pubkey/$arch-$media-pubkey"; + $path = "/media/iso_check/$arch/media/$_/media_info/pubkey"; + $url = "pubkey/$arch-$_-pubkey"; #$url .= "-cooker" if !$finale; - -r $path and -r $url and $pubkey &= check_key($path, $url, $media, $arch); + -r $path and -r $url and $pubkey &= check_key($path, $url, $_, $arch); } } } diff --git a/test_iso.pl b/test_iso.pl index 87fc27f..ba9aab2 100644 --- a/test_iso.pl +++ b/test_iso.pl @@ -1,3 +1,5 @@ +#!/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> @@ -17,7 +19,6 @@ # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. # -#!/usr/bin/perl -w use 5.010; @@ -48,11 +49,11 @@ print "# Date: ", `date --rfc-3339='ns' -u`; print "# Testing: $image_path\n"; print "# Host: ", `uname -n`; -$harness->runtests(<./t/*.t>); +$harness->runtests(glob_('t/*.t')); # Mounting the ISO print "# Mounting ISO in /media/iso_check"; --r "/media/iso_check" or system 'mkdir /media/iso_check'; +-r "/media/iso_check" or mkdir('/media/iso_check'); system "mount -r " . if_(!-b $image_path, "-o loop ") . "$image_path /media/iso_check/"; print "... ok\n"; @@ -60,9 +61,9 @@ my $name = basename($image_path); my %info = Tools::parse_mageia_iso_name($name); # FIXME the difference is actually regular versus LiveCD -if ($info{"medium"} eq "DVD") { - $harness->runtests(<./t_install_iso/*.t>); -} elsif ($info{"medium"} eq "CD") { +if ($info{medium} eq "DVD") { + $harness->runtests(glob_('t_install_iso/*.t')); +} elsif ($info{medium} eq "CD") { # LiveCD specific # CD specific } |