1#!/usr/local/bin/perl -w 2# 3# PEAK Library - Test suite script 4# 5# Copyright (c) 2004 6# Jean-Edouard BABIN <Jeb@jeb.com.fr>. All rights reserved. 7# 8# Redistribution and use in source and binary forms, with or without 9# modification, are permitted provided that the following conditions 10# are met: 11# 12# 1. Redistributions of source code must retain the above copyright 13# notice, this list of conditions and the following disclaimer. 14# 15# 2. Redistributions in binary form must reproduce the above copyright 16# notice, this list of conditions and the following disclaimer in the 17# documentation and/or other materials provided with the distribution. 18# 19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30# 31# $Id: test-suite.pl,v 1.12 2004/01/17 22:26:19 radius Exp $ 32 33use strict; 34 35select STDOUT; 36$| = 1; 37 38my %status; 39use vars qw($test $alrm); 40my $default_alarm; 41require 'test.desc'; 42 43$SIG{'ALRM'} = \&sigALRM_handler; 44$ENV{'PATH'} = '.'; 45 46$default_alarm = 1; 47$status{error}=0; 48$status{'file not found'}=0; 49$status{"can't exec file"}=0; 50$status{alarm}=0; 51$status{warning}=0; 52$status{successful}=0; 53$status{'test is not defined'}=0; 54$status{'unknow return code'}=0; 55$status{'unknow timeout message'}=0; 56 57print "\nTesting libpeak:\n"; 58 59for (@ARGV) { 60 print "$_...\t"; 61 if (!$test->{$_}) { 62 print "Error: This test is not defined\n"; 63 $status{'test is not defined'}++; 64 $status{error}++; 65 next; 66 } 67 if (!(-e $test->{$_}{file})) { 68 print "Error: File not found\n"; 69 $status{'file not found'}++; 70 $status{error}++; 71 next; 72 } 73 if (!(-x $test->{$_}{file})) { 74 print "Error: File can't be executed\n"; 75 $status{"can't exec file"}++; 76 $status{error}++; 77 next; 78 } 79 if ($test->{$_}{timeout}{time}) { 80 alarm $test->{$_}{timeout}{time}; 81 } 82 else { 83 alarm $default_alarm; 84 } 85 $alrm = 0; 86 system("$test->{$_}{file} 1>>STDOUT.log 2>>STDERR.log"); 87 alarm 0; 88 if ($alrm) { 89 if ($test->{$_}{timeout}{message}) { 90 print "$test->{$_}{timeout}{message}\n"; 91 } 92 else { 93 print "Timeout: Unknow timeout message\n"; 94 $status{'unknow timeout message'}++; 95 } 96 foreach my $status_type (@{$test->{$_}{timeout}{status}}) { 97 $status{$status_type}++; 98 } 99 next; 100 } 101 if (($?>>8) > 127) { 102 # Anormal Quit, program got a signal 103 print "Anormal Quit, program got signal " . (($?>>8)&127) . "\n"; 104 $status{'signal number ' . (($?>>8)&127)}++; 105 $status{error}++; 106 next; 107 } 108 if ($test->{$_}{code}{($?>>8)}{message}) { 109 print "$test->{$_}{code}{($?>>8)}{message}\n"; 110 } 111 else { 112 print "Unknow code: " . ($?>>8) . "\n"; 113 $status{'unknow return code'}++; 114 } 115 foreach my $status_type (@{$test->{$_}{code}{($?>>8)}{status}}) { 116 $status{$status_type}++; 117 } 118} 119 120print "\nSummary:\n"; 121foreach (sort keys %status) { 122 print "\t$status{$_} $_\n" if $status{$_}; 123} 124 125sub sigALRM_handler { 126 $alrm = 1; 127} 128