aboutsummaryrefslogtreecommitdiffstats
path: root/image_tests
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2012-02-17 17:54:36 +0000
committerRomain d'Alverny <rda@mageia.org>2012-02-17 17:54:36 +0000
commit7a5cac718aa056abe96eafe8e910ec256dd3793d (patch)
tree3be419acbcd840864d045826ae6e33904e0785bc /image_tests
parent10afa7f61593c6ee82f7256c5dfa29104ba19e52 (diff)
downloadisocheck-7a5cac718aa056abe96eafe8e910ec256dd3793d.tar
isocheck-7a5cac718aa056abe96eafe8e910ec256dd3793d.tar.gz
isocheck-7a5cac718aa056abe96eafe8e910ec256dd3793d.tar.bz2
isocheck-7a5cac718aa056abe96eafe8e910ec256dd3793d.tar.xz
isocheck-7a5cac718aa056abe96eafe8e910ec256dd3793d.zip
Move all image-related tests in a separate place.
Diffstat (limited to 'image_tests')
-rw-r--r--image_tests/000_test_env.t62
-rw-r--r--image_tests/001_check_file.t118
-rw-r--r--image_tests/003_is_hybrid.t99
-rw-r--r--image_tests/install_iso/010_check_autorun.t83
-rw-r--r--image_tests/install_iso/011_check_idx.t97
-rw-r--r--image_tests/install_iso/012_check_ids.t41
-rw-r--r--image_tests/install_iso/013_check_rpms.t50
-rw-r--r--image_tests/install_iso/014_check_bad_words.t53
-rw-r--r--image_tests/install_iso/016_check_pubkey.t113
9 files changed, 716 insertions, 0 deletions
diff --git a/image_tests/000_test_env.t b/image_tests/000_test_env.t
new file mode 100644
index 0000000..eea336c
--- /dev/null
+++ b/image_tests/000_test_env.t
@@ -0,0 +1,62 @@
+# 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.
+#
+#
+# These tests check that the testing environment is complete.
+#
+
+use Test::Most;
+
+bail_on_fail;
+
+my ($image_path) = @ARGV;
+
+# FIXME root is needed for mount/umount of the ISO. Find another way.
+is($ENV{USERNAME}, 'root', "Current user is root. FIXME.");
+
+# TODO remove this once packaged
+sub pkg_check { my ($pkg) = @_; return system("rpm -q $pkg >/dev/null") }
+
+my @packages = qw(cdrkit cdrkit-isotools gnupg);
+
+foreach my $p (@packages) {
+ is(pkg_check($p), 0, sprintf("%s is installed.", $p));
+}
+
+# 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.';
+ok -r $image_path . '.sha1.gpg', 'SHA1.gpg is available.';
+ok -r $image_path . '.idx', 'IDX is available.';
+# TODO check if LiveCD or not, so .idx or .lst
+#ok -r $image_path . '.lst', 'LST is available.';
+
+# is ISO mount point readable?
+ok -r $image_path, 'ISO mount point is readable.'
+ or diag("$image_path: $!");
+
+# is network available?
+# will be needed in a near future.
+my $nb_packet = 2;
+my $server = "google.com";
+my $result = `ping -c $nb_packet $server | grep received | sed 's/ //g' | cut -d, -f 2 | cut -c 1 | tr -d '\n'`;
+is ($result, $nb_packet, "Network available");
+
+done_testing();
diff --git a/image_tests/001_check_file.t b/image_tests/001_check_file.t
new file mode 100644
index 0000000..26e331a
--- /dev/null
+++ b/image_tests/001_check_file.t
@@ -0,0 +1,118 @@
+# 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 Test::Most;
+use File::Basename;
+use Isocheck;
+
+my ($image_path) = @ARGV;
+
+my $name = basename($image_path);
+my %info;
+
+bail_on_fail;
+
+%info = Isocheck::parse_image_file_name($name);
+if (scalar %info) {
+ pass 'ISO has valid filename.';
+ while (my ($k, $v) = each %info) {
+ note uc($k), "=$v\n" if defined $v;
+ }
+} else {
+ fail 'ISO has valid filename.';
+ diag 'See https://wiki.mageia.org/en/Product_naming for more information.';
+}
+
+# is file size correct?
+my $du = `du --apparent-size --block-size=MB $image_path`;
+my @size_name = split(/\t/, $du);
+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}},
+ sprintf("File has a working size (%s) for its medium type (%s, max %s).",
+ $size, $info{medium}, $max_sizes{$info{medium}}));
+
+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.');
+}
+
+
+# verify checksums
+my $md5file = $image_path . '.md5';
+my $sha1file = $image_path . '.sha1';
+
+my @ts = split(/ /, `md5sum $image_path`);
+my $md5 = $ts[0];
+@ts = split(/ /, `cat $md5file`);
+$md5file = $ts[0];
+is($md5, $md5file, 'MD5/.md5 checksums match.');
+
+@ts = split(/ /, `sha1sum $image_path`);
+my $sha1 = $ts[0];
+@ts = split(/ /, `cat $sha1file`);
+$sha1file = $ts[0];
+is($sha1, $sha1file, 'SHA1/.sha1 checksums match.');
+
+
+# check ISO header info
+# Check (see http://wiki.mandriva.com/en/Product_id)
+my $isoinfo = `isoinfo -d -i $image_path`;
+my %isoValues = (
+ "System id", "LINUX",
+ "Volume id", "$info{name} $info{version} $info{release}", # TODO not defined for sure yet
+ "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/",
+ "Abstract File id", "http://www.mageia.org/2/"
+);
+
+my $testval;
+while (my ($k, $v) = each(%isoValues)) {
+ $testval = `printf "%s\n" "$isoinfo" | grep -i "$k:" |tr -d '\n'`;
+
+ # not testing right now, all expected values are not sure yet.
+ # is $testval, "$k: $v", "$k is correct. Found $testval.";
+ note "Found: $testval - expecting: $k: $v";
+}
+
+
+# bootable?
+ok(`isoinfo -d -i $image_path | grep bootable`, 'ISO is bootable.');
+
+# TODO check burnable?
+my $burner = "/dev/sr0";
+
+# FIXME is -eject really needed?
+my $_burning = `cdrecord -dummy speed=42 dev=$burner -v -eject -data $image_path 2> is_burnable.log`;
+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.");
+
+
+done_testing();
diff --git a/image_tests/003_is_hybrid.t b/image_tests/003_is_hybrid.t
new file mode 100644
index 0000000..dd89fd7
--- /dev/null
+++ b/image_tests/003_is_hybrid.t
@@ -0,0 +1,99 @@
+# 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 Test::Most;
+
+bail_on_fail;
+
+my ($image_path) = @ARGV;
+
+ok(is_hybrid($image_path, 0), "Is hybrid");
+
+# Verification if the ISO is hybrid
+sub is_hybrid {
+ my ($img, $full) = @_;
+
+ open(my $iso, $img);
+ my $hybrid = hybrid1($iso);
+ $hybrid &= hybrid2($iso);
+ $hybrid &= hybrid3($iso);
+ if ($full) {
+ # system "dd if=$img of=/dev/my-pendrive bs=8";
+ }
+ close($iso);
+
+ return $hybrid;
+}
+
+
+# Check the first 512 bytes of the iso
+sub hybrid1 {
+ my ($iso) = @_;
+ my $buffer;
+ my $hybrid;
+
+ foreach (0 .. 512) {
+ read($iso, $buffer, 1);
+ if ($buffer ne '\x00') {
+ $hybrid = 1;
+ }
+ }
+
+ return $hybrid;
+}
+
+#Check the 0x1fe & 0x1ff bytes of the iso
+sub hybrid2 {
+ my ($iso) = @_;
+ my $hybrid;
+ my $buffer;
+ my $byte = "\x55";
+
+ seek($iso, 0x1fe, 0);
+ read($iso, $buffer, 1);
+ if ($buffer eq $byte) {
+ read($iso, $buffer, 1);
+ $byte = "\xaa";
+ if ($buffer eq $byte) {
+ $hybrid = 1;
+ }
+ }
+
+ return $hybrid;
+}
+
+# check from the 0x200 to the 0x8000 bytes
+sub hybrid3 {
+ my ($iso) = @_;
+ my $hybrid = 1;
+ my $buffer;
+
+ seek($iso, 0x200, 0);
+ foreach (0x200 .. 0x8000) {
+ read($iso, $buffer, 1);
+ if ($buffer eq '\x00') {
+ $hybrid = 0;
+ }
+ }
+
+ return $hybrid;
+}
+
+done_testing();
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();