summaryrefslogtreecommitdiff
path: root/agent/test/pl/logfile.pl
blob: 67ec46c2b35e208061880086072d5a06acc60565 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Get log file (by default) or any other file into @log

;# $Id: logfile.pl 1 2006-08-24 13:24:12Z rmanfredi $
;#
;#  Copyright (c) 1990-2006, Raphael Manfredi
;#  
;#  You may redistribute only under the terms of the Artistic License,
;#  as specified in the README file that comes with the distribution.
;#  You may reuse parts of this distribution only within the terms of
;#  that same Artistic License; a copy of which may be found at the root
;#  of the source tree for mailagent 3.0.
;#
;# $Log: logfile.pl,v $
;# Revision 3.0.1.2  1995/08/07  16:29:15  ram
;# patch37: simplified matching by removing spurious eval
;#
;# Revision 3.0.1.1  1994/07/01  15:10:42  ram
;# patch8: fixed RCS leading comment string
;#
;# Revision 3.0  1993/11/29  13:50:24  ram
;# Baseline for mailagent 3.0 netwide release.
;#

sub get_log {
	local($num, $file) = @_;
	$file = 'agentlog' unless $file;
	open(LOG, $file) || print "$num\n";
	@log = <LOG>;
	close LOG;
}

# Make sure a pattern is within @log, return number of matches
sub check_log {
	local($pattern, $num) = @_;
	local(@matches);
	@matches = grep(/$pattern/, @log);
	print "$num\n" unless @matches;
	0 + @matches;
}

# Make sure a pattern is NOT within @log, return number of matches
sub not_log {
	local($pattern, $num) = @_;
	local(@matches);
	@matches = grep(/$pattern/, @log);
	print "$num\n" if @matches;
	0 + @matches;
}