1# Test hooking facilities 2 3# $Id: hook.t,v 3.0 1993/11/29 13:50:00 ram Exp ram $ 4# 5# Copyright (c) 1990-2006, Raphael Manfredi 6# 7# You may redistribute only under the terms of the Artistic License, 8# as specified in the README file that comes with the distribution. 9# You may reuse parts of this distribution only within the terms of 10# that same Artistic License; a copy of which may be found at the root 11# of the source tree for mailagent 3.0. 12# 13# $Log: hook.t,v $ 14# Revision 3.0 1993/11/29 13:50:00 ram 15# Baseline for mailagent 3.0 netwide release. 16# 17 18do '../pl/filter.pl'; 19do '../pl/logfile.pl'; 20unlink 'never', 'always', 'always.2', 'always.3'; 21unlink 'hook.1', 'hook.2', 'hook.3', 'hook.4'; 22 23open(HOOK, '>hook.1') || print "1\n"; 24print HOOK <<'EOH'; 25#! /bin/sh 26cat > always 27exit 0 28EOH 29close HOOK; 30 31open(HOOK, '>hook.2') || print "2\n"; 32print HOOK <<'EOH'; 33#: deliver 34open(OUT, '>always.2') || exit 1; 35print OUT "$login\n"; 36close OUT; 37print "SAVE ~/always; RUN /bin/echo hi! > always.3"; 38EOH 39close HOOK; 40 41open(HOOK, '>hook.3') || print "3\n"; 42print HOOK <<'EOH'; 43#: rules 44!To: ram { SAVE never }; 45{ SAVE ~/always; RUN /bin/echo hi! > always.3 }; 46EOH 47close HOOK; 48 49open(HOOK, '>hook.4') || print "29\n"; 50print HOOK <<'EOH'; 51#: perl 52&save("~/always"); 53&run("/bin/echo hi! > always.3"); 54EOH 55close HOOK; 56chmod 0544, 'hook.1', 'hook.2', 'hook.3', 'hook.4'; 57 58&add_header('X-Tag: hook #1'); 59`$cmd`; 60$? == 0 || print "4\n"; 61-f 'never' && print "5\n"; 62&get_log(6, 'always'); 63&check_log('^To: ram', 7) == 1 || print "8\n"; 64&get_log(9, 'hook.1'); 65¬_log('^To: ram', 10); 66unlink 'never', 'always', 'always.2', 'always.3'; 67 68&replace_header('X-Tag: hook #2'); 69`$cmd`; 70$? == 0 || print "11\n"; 71-f 'never' && print "12\n"; 72&get_log(13, 'always'); 73&check_log('^To: ram', 14) == 1 || print "15\n"; 74&get_log(16, 'always.3'); 75&check_log('^hi!', 17) == 1 || print "18\n"; 76&get_log(19, 'always.2'); 77&check_log('^compilers-request$', 20); 78unlink 'never', 'always', 'always.2', 'always.3'; 79 80&replace_header('X-Tag: hook #3'); 81`$cmd`; 82$? == 0 || print "21\n"; 83-f 'never' && print "22\n"; 84&get_log(23, 'always'); 85&check_log('^To: ram', 24) == 1 || print "25\n"; 86&get_log(26, 'always.3'); 87&check_log('^hi!', 27) == 1 || print "28\n"; 88unlink 'never', 'always', 'always.2', 'always.3'; 89 90&replace_header('X-Tag: hook #4'); 91`$cmd`; 92$? == 0 || print "30\n"; 93-f 'never' && print "31\n"; 94&get_log(32, 'always'); 95&check_log('^To: ram', 33) == 1 || print "34\n"; 96&get_log(35, 'always.3'); 97&check_log('^hi!', 36) == 1 || print "37\n"; 98 99unlink 'hook.1', 'hook.2', 'hook.3', 'hook.4'; 100unlink 'never', 'always', 'always.2', 'always.3'; 101print "0\n"; 102