From deb9713857f8f47cf392df14b4d7fd6af0bbb395 Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Fri, 17 Feb 2012 17:55:28 +0000 Subject: Move all image-related tests in a separate place --- t_install_iso/010_check_autorun.t | 84 --------------------------- t_install_iso/011_check_idx.t | 97 ------------------------------- t_install_iso/012_check_ids.t | 41 ------------- t_install_iso/013_check_rpms.t | 50 ---------------- t_install_iso/014_check_bad_words.t | 53 ----------------- t_install_iso/016_check_pubkey.t | 113 ------------------------------------ 6 files changed, 438 deletions(-) delete mode 100644 t_install_iso/010_check_autorun.t delete mode 100644 t_install_iso/011_check_idx.t delete mode 100644 t_install_iso/012_check_ids.t delete mode 100644 t_install_iso/013_check_rpms.t delete mode 100644 t_install_iso/014_check_bad_words.t delete mode 100644 t_install_iso/016_check_pubkey.t diff --git a/t_install_iso/010_check_autorun.t b/t_install_iso/010_check_autorun.t deleted file mode 100644 index ce607fe..0000000 --- a/t_install_iso/010_check_autorun.t +++ /dev/null @@ -1,84 +0,0 @@ -# This file is part of the Mageia project -# Copyright (C) 2011 Damien Lallement -# (C) 2011 Romain D'Alverny -# -# 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; -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'; -}); - -# -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/t_install_iso/011_check_idx.t b/t_install_iso/011_check_idx.t deleted file mode 100644 index 8863b9b..0000000 --- a/t_install_iso/011_check_idx.t +++ /dev/null @@ -1,97 +0,0 @@ -# This file is part of the Mageia project -# Copyright (C) 2011 Damien Lallement -# (C) 2011 Romain D'Alverny -# -# 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 "\n" if $verb; - print $log "\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 "\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 "\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/t_install_iso/012_check_ids.t b/t_install_iso/012_check_ids.t deleted file mode 100644 index 56eed85..0000000 --- a/t_install_iso/012_check_ids.t +++ /dev/null @@ -1,41 +0,0 @@ -# This file is part of the Mageia project -# Copyright (C) 2011 Damien Lallement -# (C) 2011 Romain D'Alverny -# -# 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/t_install_iso/013_check_rpms.t b/t_install_iso/013_check_rpms.t deleted file mode 100644 index cd329ac..0000000 --- a/t_install_iso/013_check_rpms.t +++ /dev/null @@ -1,50 +0,0 @@ -# This file is part of the Mageia project -# Copyright (C) 2011 Damien Lallement -# (C) 2011 Romain D'Alverny -# -# 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/t_install_iso/014_check_bad_words.t b/t_install_iso/014_check_bad_words.t deleted file mode 100644 index 260f323..0000000 --- a/t_install_iso/014_check_bad_words.t +++ /dev/null @@ -1,53 +0,0 @@ -# This file is part of the Mageia project -# Copyright (C) 2011 Damien Lallement -# (C) 2011 Romain D'Alverny -# -# 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/t_install_iso/016_check_pubkey.t b/t_install_iso/016_check_pubkey.t deleted file mode 100644 index edf20cb..0000000 --- a/t_install_iso/016_check_pubkey.t +++ /dev/null @@ -1,113 +0,0 @@ -# This file is part of the Mageia project -# Copyright (C) 2011 Damien Lallement -# (C) 2011 Romain D'Alverny -# -# 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 Tools; - -my ($image_path) = @ARGV; -my $name = basename($image_path); -my %info = Tools::parse_mageia_iso_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(); -- cgit v1.2.1