From 7a5cac718aa056abe96eafe8e910ec256dd3793d Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Fri, 17 Feb 2012 17:54:36 +0000 Subject: Move all image-related tests in a separate place. --- t/000_test_env.t | 62 ---------------------------- t/001_check_file.t | 118 ----------------------------------------------------- t/003_is_hybrid.t | 99 -------------------------------------------- 3 files changed, 279 deletions(-) delete mode 100644 t/000_test_env.t delete mode 100644 t/001_check_file.t delete mode 100644 t/003_is_hybrid.t (limited to 't') diff --git a/t/000_test_env.t b/t/000_test_env.t deleted file mode 100644 index 2b5b0d1..0000000 --- a/t/000_test_env.t +++ /dev/null @@ -1,62 +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. -# -# -# These tests check that the testing environment is complete. -# - -use Test::Most; - -bail_on_fail; - -my ($image_path) = @ARGV; - -# root is needed for mount/umount of the ISO -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") } - -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 -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/t/001_check_file.t b/t/001_check_file.t deleted file mode 100644 index edbf7ba..0000000 --- a/t/001_check_file.t +++ /dev/null @@ -1,118 +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. -# - - -use Test::Most; -use File::Basename; -use Tools; - -my ($image_path) = @ARGV; - -my $name = basename($image_path); -my %info; - -bail_on_fail; - -%info = Tools::parse_mageia_iso_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/t/003_is_hybrid.t b/t/003_is_hybrid.t deleted file mode 100644 index dd89fd7..0000000 --- a/t/003_is_hybrid.t +++ /dev/null @@ -1,99 +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. -# - -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(); -- cgit v1.2.1