diff options
-rw-r--r-- | image_tests/000_test_env.t (renamed from t/000_test_env.t) | 8 | ||||
-rw-r--r-- | image_tests/001_check_file.t (renamed from t/001_check_file.t) | 4 | ||||
-rw-r--r-- | image_tests/003_is_hybrid.t (renamed from t/003_is_hybrid.t) | 0 | ||||
-rw-r--r-- | image_tests/install_iso/010_check_autorun.t | 83 | ||||
-rw-r--r-- | image_tests/install_iso/011_check_idx.t | 97 | ||||
-rw-r--r-- | image_tests/install_iso/012_check_ids.t | 41 | ||||
-rw-r--r-- | image_tests/install_iso/013_check_rpms.t | 50 | ||||
-rw-r--r-- | image_tests/install_iso/014_check_bad_words.t | 53 | ||||
-rw-r--r-- | image_tests/install_iso/016_check_pubkey.t | 113 |
9 files changed, 443 insertions, 6 deletions
diff --git a/t/000_test_env.t b/image_tests/000_test_env.t index 2b5b0d1..eea336c 100644 --- a/t/000_test_env.t +++ b/image_tests/000_test_env.t @@ -27,10 +27,10 @@ bail_on_fail; my ($image_path) = @ARGV; -# root is needed for mount/umount of the ISO -is($ENV{USERNAME}, 'root', "Current user is root."); +# FIXME root is needed for mount/umount of the ISO. Find another way. +is($ENV{USERNAME}, 'root', "Current user is root. FIXME."); -# TODO move this elsewhere maybe? +# TODO remove this once packaged sub pkg_check { my ($pkg) = @_; return system("rpm -q $pkg >/dev/null") } my @packages = qw(cdrkit cdrkit-isotools gnupg); @@ -39,7 +39,7 @@ foreach my $p (@packages) { is(pkg_check($p), 0, sprintf("%s is installed.", $p)); } -# check if all necessary files are available +# check if all necessary files are available - FIXME not to use if not final release ok -r $image_path . '.md5', 'MD5 checksum is available.'; ok -r $image_path . '.sha1', 'SHA1 checkum is available.'; ok -r $image_path . '.md5.gpg', 'MD5.gpg is available.'; diff --git a/t/001_check_file.t b/image_tests/001_check_file.t index edbf7ba..26e331a 100644 --- a/t/001_check_file.t +++ b/image_tests/001_check_file.t @@ -21,7 +21,7 @@ use Test::Most; use File::Basename; -use Tools; +use Isocheck; my ($image_path) = @ARGV; @@ -30,7 +30,7 @@ my %info; bail_on_fail; -%info = Tools::parse_mageia_iso_name($name); +%info = Isocheck::parse_image_file_name($name); if (scalar %info) { pass 'ISO has valid filename.'; while (my ($k, $v) = each %info) { diff --git a/t/003_is_hybrid.t b/image_tests/003_is_hybrid.t index dd89fd7..dd89fd7 100644 --- a/t/003_is_hybrid.t +++ b/image_tests/003_is_hybrid.t diff --git a/image_tests/install_iso/010_check_autorun.t b/image_tests/install_iso/010_check_autorun.t new file mode 100644 index 0000000..0b23faa --- /dev/null +++ b/image_tests/install_iso/010_check_autorun.t @@ -0,0 +1,83 @@ +# 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. +# +# +# Check autorun +# +use Test::Most tests => 12; +use File::Basename; + +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'; +}); + +# +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"); + +# TODO check media name in autorun.inf (for Windows) + +# +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"); +} + +done_testing(); diff --git a/image_tests/install_iso/011_check_idx.t b/image_tests/install_iso/011_check_idx.t new file mode 100644 index 0000000..8863b9b --- /dev/null +++ b/image_tests/install_iso/011_check_idx.t @@ -0,0 +1,97 @@ +# 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. +# +# TODO +# +# +use Test::Most; + +bail_on_fail; + +SKIP: { + skip "TODO", 1 unless 0; +} + +done_testing(); + +# get the product to verify in idxlist +sub check_idx { + my ($log, $distro, $image, $verbo) = @_; + my $idx; + my $valid = 1; + my $col; + $col = 0 if member($distro, qw(Free FREE)); + $col = 2 if member($distro, qw(PWP Powerpack)); + $col = 3 if member($distro, qw(One ONE one)); + $col = 1 if -r "/media/iso_check/i586/" && -r "/media/iso_check/x86_64/"; + if ($col == 3) { + substr($image, -3 , 3) = ''; + $idx = $image . "lst"; + $valid &= check_idx_list($idx, $log, $col, $verbo) if -r $idx && -r "idxlist"; + } + else { + substr($image, -3 , 3) = ''; + $idx = $image . "idx"; + $valid &= check_idx_list($idx, $log, $col, $verbo) if -r $idx && -r "idxlist"; + } + + return $valid; +} + + +# Verification of the presence of the packages on the iso +sub check_idx_list { + my ($idx, $log, $col, $verb) = @_; + my $pkg; + my $valid = 1; + my $file; + my @media; + + print "<Log of check_idx>\n" if $verb; + print $log "<Log of check_idx>\n"; + + open(my $list, 'idxlist') or fail('check_idx_list'); + while ($pkg = <$list>) { + if (substr($pkg, 0, 1) ne '#') { + chomp($pkg); + @media = split(/ /, $pkg); + if ($media[$col] == 1) { + $file = `cat $idx | cut -d ' ' -f 2 | grep $media[4]` if $col != 3; + $file = `cat $idx | grep $media[4]` if $col == 3; + if ($file eq '') { + print $log "$media[4] NOT FOUND in $idx\n"; + print "$media[4] NOT FOUND in $idx\n" if $verb; + $valid = 0; + } + else { + print $file if $verb; + #print $log $file; + } + } + } + } + print $log "</Log of check_idx>\n"; + print $log "Comparison between idxlist and .idx OK\n" if $valid != 0; + print $log "Comparison between idxlist and .idx NOT OK\n" if $valid == 0; + print "</Log of check_idx>\n" if $verb; + print "Comparison between idxlist and .idx: OK\n" if $valid != 0 && $verb; + print "Comparison between idxlist and .idx: NOT OK\n" if $valid == 0 && $verb; + + return $valid; +} diff --git a/image_tests/install_iso/012_check_ids.t b/image_tests/install_iso/012_check_ids.t new file mode 100644 index 0000000..56eed85 --- /dev/null +++ b/image_tests/install_iso/012_check_ids.t @@ -0,0 +1,41 @@ +# 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. +# +# +# Check if PCI ids are on the ISO +# + +use Test::Most tests => 1; +use File::Basename; + +my ($image_path) = @ARGV; + +bail_on_fail; + +my $valid; +my $valid2; + +$valid = -r "/media/iso_check/i586/isolinux/pci.ids" if -r "/media/iso_check/i586"; +$valid2 = -r "/media/iso_check/x86_64/isolinux/pci.ids" if -r "/media/iso_check/x86_64"; +$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.'); + +done_testing(); diff --git a/image_tests/install_iso/013_check_rpms.t b/image_tests/install_iso/013_check_rpms.t new file mode 100644 index 0000000..cd329ac --- /dev/null +++ b/image_tests/install_iso/013_check_rpms.t @@ -0,0 +1,50 @@ +# 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. +# +# +# Verification of the signature of all the rpm packages present on the iso +# +use Test::Most; + +bail_on_fail; + +SKIP: { + skip "Not working yet", 1 unless 0; + +my $_find = `find /media/iso_check/* -name *.rpm > find_all_rpm.log`; +open(my $list, 'find_all_rpm.log'); + +my $pkg; +my $sign; +my $valid = 1; + +while ($pkg = <$list>) { + $sign = ''; + chomp($pkg); + $sign = `rpm -K $pkg | grep 'gpg OK'`; + ok($sign, "$pkg is correctly signed."); + + $valid = 0 if !$sign; +} +close($list); +my $_res = `rm -rf find_all_rpm.log`; + +} + +done_testing(); diff --git a/image_tests/install_iso/014_check_bad_words.t b/image_tests/install_iso/014_check_bad_words.t new file mode 100644 index 0000000..260f323 --- /dev/null +++ b/image_tests/install_iso/014_check_bad_words.t @@ -0,0 +1,53 @@ +# 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. +# +# +# This function search if there is any temporary files ( .file.swp and file~) +# or file with "bad" words. +# +use Test::Most tests => 3; + +#bail_on_fail; + +# check for temp/hidden files +my $res = `find /media/iso_check/ -name '*~' -or -iname '*.swp' -or -iname '.svn' -or -iname '.git*'`; +if ($res) { + fail('Has no swap temp or hiden RCS files (*~, *.swp, .svn or .git*).'); + note $res; +} else { + pass('Has no swap temp or hiden RCS files (*~, *.swp, .svn or .git*).'); +} + +# check for bad words in file name or inside files +$res = `find /media/iso_check/ -iname '*roxx*' -or -iname '*sucks*' -or -iname 'ubuntu*' -or -iname 'microsoft*' -or -iname 'mandrake*' -or -iname 'mandriva' -or -iname 'todo' -or -iname 'delete*'`; +if ($res) { + fail('Has no blacklisted words in files names.'); + note $res; +} else { + $res = `grep -c -r -l --exclude-dir=media --exclude-dir=dosutils --exclude=release* --exclude=pci.ids --exclude=memtest -i -e mandriva -e ubuntu -e roxx -e sucks -e microsoft -e mandrake -e trash -e delete /media/iso_check/`; + if ($res) { + fail('Has no blacklisted words inside files.'); + note $res; + } else { + pass('Has no blacklisted words inside files.'); + } + pass('Has no blacklisted words in files names.'); +} + +done_testing(); diff --git a/image_tests/install_iso/016_check_pubkey.t b/image_tests/install_iso/016_check_pubkey.t new file mode 100644 index 0000000..587e7c6 --- /dev/null +++ b/image_tests/install_iso/016_check_pubkey.t @@ -0,0 +1,113 @@ +# 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. +# +# +# TODO check pubkeys FIXME this looks like a mess. +# This function get the path of the pubkeys +# +use MDK::Common; +use Test::Most; +use File::Basename; +use Isocheck; + +my ($image_path) = @ARGV; +my $name = basename($image_path); +my %info = Tools::parse_image_file_name($name); + +bail_on_fail; + +my $url; +my $path; +my $pubkey = 1; +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"); + +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, $_, $info{arch}) if -r $path && -r $url; + } + elsif ($_ ne 'media_info') { + foreach my $arch ("i586", "x86_64") { + $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, $_, $arch); + } + } +} +-r "temp_media_on_iso.log" and system "rm temp_media_on_iso.log"; + + +#This function get the gpg -a key of the pubkey to compare it +sub get_gpg { + my ($pubkey) = @_; + my $key; + my $file; + system "gpg -a $pubkey > get_gpg_key.log"; + open($file, "get_gpg_key.log"); + while (my $a = <$file>) { + if (substr($a, 0, 11) eq "pub 1024D/") { + $key = substr($a, 11, 8); + } + } + system "rm get_gpg_key.log"; + + return $key; +} + + +#Verification of the pubkey with the original pubkey +sub check_key { # sed "s/pub\w1024D/\(.*\) /\1/" + my ($iso_file, $ref_file, $media, $arch) = @_; + my $unvalid; + my $valid = 1; + my $file = get_gpg($iso_file); + my $sign = `cat $ref_file`; + chomp($sign); + if ($file eq $sign) { + if (member($media, qw(core nonfree))) { + note "$arch-$media pubkey is valid.\t\tOK\n" if $arch eq 'i586'; + note "$arch-$media pubkey is valid.\t\tOK\n" if $arch eq 'x86_64' && member($media, qw(core nonfree)); + note "$arch-$media pubkey is valid.\tOK\n" if $arch eq 'x86_64' && $media eq 'non-free'; + } else { + note "$arch-$media pubkey is valid.\tOK\n"; + } + note "$arch-$media pubkey is valid.\n"; + return $valid; + } else { + if (member($media, qw(core))) { + note "$arch-$media pubkey isn't valid.\t\tNOK\n"; + } else { + note "$arch-$media pubkey isn't valid.\tNOK\n"; + } + note "$arch-$media pubkey isn't valid.\n"; + return $unvalid; + } + return $unvalid; +} + +done_testing(); |