forked from extern/shorewall_code
Implement regression testing
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@7859 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
parent
8e9d2067d6
commit
8b29aa06a6
@ -383,6 +383,7 @@ compiler() {
|
|||||||
[ -n "$EXPORT" ] && options="$options --export"
|
[ -n "$EXPORT" ] && options="$options --export"
|
||||||
[ -n "$SHOREWALL_DIR" ] && options="$options --directory=$SHOREWALL_DIR"
|
[ -n "$SHOREWALL_DIR" ] && options="$options --directory=$SHOREWALL_DIR"
|
||||||
[ -n "$TIMESTAMP" ] && options="$options --timestamp"
|
[ -n "$TIMESTAMP" ] && options="$options --timestamp"
|
||||||
|
[ -n "$TEST" ] && options="$options --test"
|
||||||
[ "$debugging" = trace ] && options="$options --debug"
|
[ "$debugging" = trace ] && options="$options --debug"
|
||||||
[ -n "$REFRESHCHAINS" ] && options="$options --refresh=$REFRESHCHAINS"
|
[ -n "$REFRESHCHAINS" ] && options="$options --refresh=$REFRESHCHAINS"
|
||||||
[ -x $pc ] || startup_error "SHOREWALL_COMPILER=perl requires the shorewall-perl package which is not installed"
|
[ -x $pc ] || startup_error "SHOREWALL_COMPILER=perl requires the shorewall-perl package which is not installed"
|
||||||
@ -573,6 +574,10 @@ compile_command() {
|
|||||||
option=
|
option=
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
t*)
|
||||||
|
TEST=Yes
|
||||||
|
option=${option#t}
|
||||||
|
;;
|
||||||
d*)
|
d*)
|
||||||
DEBUG=Yes;
|
DEBUG=Yes;
|
||||||
option=${option#d}
|
option=${option#d}
|
||||||
|
@ -45,6 +45,8 @@ our $VERSION = 4.1.2;
|
|||||||
|
|
||||||
our $export;
|
our $export;
|
||||||
|
|
||||||
|
our $test;
|
||||||
|
|
||||||
our $reused = 0;
|
our $reused = 0;
|
||||||
|
|
||||||
use constant { EXPORT => 0x01 ,
|
use constant { EXPORT => 0x01 ,
|
||||||
@ -82,13 +84,12 @@ sub generate_script_1() {
|
|||||||
|
|
||||||
my $date = localtime;
|
my $date = localtime;
|
||||||
|
|
||||||
if ( $config{COMPILER_TEST} ) {
|
if ( $test ) {
|
||||||
emit "#!/bin/sh\n#\n# Compiled firewall script generated by Shorewall-perl\n#";
|
emit "#!/bin/sh\n#\n# Compiled firewall script generated by Shorewall-perl\n#";
|
||||||
} else {
|
} else {
|
||||||
emit "#!/bin/sh\n#\n# Compiled firewall script generated by Shorewall-perl $globals{VERSION} - $date\n#";
|
emit "#!/bin/sh\n#\n# Compiled firewall script generated by Shorewall-perl $globals{VERSION} - $date\n#";
|
||||||
}
|
|
||||||
|
|
||||||
copy $globals{SHAREDIRPL} . 'prog.header';
|
copy $globals{SHAREDIRPL} . 'prog.header';
|
||||||
|
}
|
||||||
|
|
||||||
for my $exit qw/init isusable start tcclear started stop stopped clear refresh refreshed/ {
|
for my $exit qw/init isusable start tcclear started stop stopped clear refresh refreshed/ {
|
||||||
emit "\nrun_${exit}_exit() {";
|
emit "\nrun_${exit}_exit() {";
|
||||||
@ -144,7 +145,7 @@ sub generate_script_1() {
|
|||||||
qq([ -n "\${RESTOREFILE:=$config{RESTOREFILE}}" ]),
|
qq([ -n "\${RESTOREFILE:=$config{RESTOREFILE}}" ]),
|
||||||
'[ -n "$LOGFORMAT" ] || LOGFORMAT="Shorewall:%s:%s:"' );
|
'[ -n "$LOGFORMAT" ] || LOGFORMAT="Shorewall:%s:%s:"' );
|
||||||
|
|
||||||
emit ( qq(VERSION="$globals{VERSION}") ) unless $config{COMPILER_TEST};
|
emit ( qq(VERSION="$globals{VERSION}") ) unless $test;
|
||||||
|
|
||||||
emit ( qq(PATH="$config{PATH}") ,
|
emit ( qq(PATH="$config{PATH}") ,
|
||||||
'TERMINATOR=fatal_error' ,
|
'TERMINATOR=fatal_error' ,
|
||||||
@ -508,7 +509,7 @@ EOF
|
|||||||
#
|
#
|
||||||
sub generate_script_2 () {
|
sub generate_script_2 () {
|
||||||
|
|
||||||
copy $globals{SHAREDIRPL} . 'prog.functions';
|
copy $globals{SHAREDIRPL} . 'prog.functions' unless $test;
|
||||||
|
|
||||||
emit( '',
|
emit( '',
|
||||||
'#',
|
'#',
|
||||||
@ -698,7 +699,7 @@ EOF
|
|||||||
|
|
||||||
emit "}\n";
|
emit "}\n";
|
||||||
|
|
||||||
copy $globals{SHAREDIRPL} . 'prog.footer';
|
copy $globals{SHAREDIRPL} . 'prog.footer' unless $test;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -712,6 +713,7 @@ sub compiler {
|
|||||||
( '', '', -1, '', 0, '', '', -1 );
|
( '', '', -1, '', 0, '', '', -1 );
|
||||||
|
|
||||||
$export = 0;
|
$export = 0;
|
||||||
|
$test = 0;
|
||||||
|
|
||||||
sub edit_boolean( $ ) {
|
sub edit_boolean( $ ) {
|
||||||
my $val = numeric_value( shift );
|
my $val = numeric_value( shift );
|
||||||
@ -732,6 +734,7 @@ sub compiler {
|
|||||||
chains => { store => \$chains },
|
chains => { store => \$chains },
|
||||||
log => { store => \$log },
|
log => { store => \$log },
|
||||||
log_verbosity => { store => \$log_verbosity, edit => \&edit_verbosity } ,
|
log_verbosity => { store => \$log_verbosity, edit => \&edit_verbosity } ,
|
||||||
|
test => { store => \$test },
|
||||||
);
|
);
|
||||||
|
|
||||||
while ( defined ( my $name = shift ) ) {
|
while ( defined ( my $name = shift ) ) {
|
||||||
|
@ -260,8 +260,7 @@ sub initialize() {
|
|||||||
# From shorewall.conf file
|
# From shorewall.conf file
|
||||||
#
|
#
|
||||||
%config =
|
%config =
|
||||||
( COMPILER_TEST => undef,
|
( STARTUP_ENABLED => undef,
|
||||||
STARTUP_ENABLED => undef,
|
|
||||||
VERBOSITY => undef,
|
VERBOSITY => undef,
|
||||||
#
|
#
|
||||||
# Logging
|
# Logging
|
||||||
@ -1800,7 +1799,6 @@ sub get_configuration( $ ) {
|
|||||||
$config{LOG_VERBOSITY} = -1;
|
$config{LOG_VERBOSITY} = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
default_yes_no 'COMPILER_TEST' , '';
|
|
||||||
default_yes_no 'ADD_IP_ALIASES' , 'Yes';
|
default_yes_no 'ADD_IP_ALIASES' , 'Yes';
|
||||||
default_yes_no 'ADD_SNAT_ALIASES' , '';
|
default_yes_no 'ADD_SNAT_ALIASES' , '';
|
||||||
default_yes_no 'DETECT_DNAT_IPADDRS' , '';
|
default_yes_no 'DETECT_DNAT_IPADDRS' , '';
|
||||||
|
@ -54,6 +54,7 @@ sub usage( $ ) {
|
|||||||
[ --refresh=<chainlist> ]
|
[ --refresh=<chainlist> ]
|
||||||
[ --log=<filename> ]
|
[ --log=<filename> ]
|
||||||
[ --log-verbose={-1|0-2} ]
|
[ --log-verbose={-1|0-2} ]
|
||||||
|
[ --test ]
|
||||||
';
|
';
|
||||||
exit shift @_;
|
exit shift @_;
|
||||||
}
|
}
|
||||||
@ -70,6 +71,7 @@ my $chains = '';
|
|||||||
my $log = '';
|
my $log = '';
|
||||||
my $log_verbose = 0;
|
my $log_verbose = 0;
|
||||||
my $help = 0;
|
my $help = 0;
|
||||||
|
my $test = 0;
|
||||||
|
|
||||||
Getopt::Long::Configure ('bundling');
|
Getopt::Long::Configure ('bundling');
|
||||||
|
|
||||||
@ -89,6 +91,7 @@ my $result = GetOptions('h' => \$help,
|
|||||||
'log=s' => \$log,
|
'log=s' => \$log,
|
||||||
'l=s' => \$log,
|
'l=s' => \$log,
|
||||||
'log_verbosity=i' => \$log_verbose,
|
'log_verbosity=i' => \$log_verbose,
|
||||||
|
'test' => \$test,
|
||||||
);
|
);
|
||||||
|
|
||||||
usage(1) unless $result && @ARGV < 2;
|
usage(1) unless $result && @ARGV < 2;
|
||||||
@ -102,4 +105,5 @@ compiler( object => defined $ARGV[0] ? $ARGV[0] : '',
|
|||||||
export => $export,
|
export => $export,
|
||||||
chains => $chains,
|
chains => $chains,
|
||||||
log => $log,
|
log => $log,
|
||||||
log_verbosity => $log_verbose );
|
log_verbosity => $log_verbose,
|
||||||
|
test => $test );
|
||||||
|
31
tools/testing/accepttest
Executable file
31
tools/testing/accepttest
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Clear an exception on one or more regression tests -- (C) 2007, Tom Eastep (teastep@shorewall.net)
|
||||||
|
#
|
||||||
|
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of Version 2 of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This program 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 General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
for directory in $*; do
|
||||||
|
if [ -d $directory ]; then
|
||||||
|
cp -f $directory/firewall $directory/firewall.last && echo "Test $directory ACCEPTED"
|
||||||
|
else
|
||||||
|
echo " WARNING: No directory named $directory" >&2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
43
tools/testing/regression
Executable file
43
tools/testing/regression
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Shorewall Compiler Positive Regression test driver -- (C) 2007, Tom Eastep (teastep@shorewall.net)
|
||||||
|
#
|
||||||
|
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of Version 2 of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This program 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 General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
for directory in *; do
|
||||||
|
if [ -d $directory ]; then
|
||||||
|
if /sbin/shorewall -v2 compile -t $directory $directory/firewall > $directory/compileroutput 2> $directory/compilererrors; then
|
||||||
|
if [ -f $directory/firewall.last ]; then
|
||||||
|
if diff -au $directory/firewall.last $directory/firewall > $directory/compare; then
|
||||||
|
echo "Test $directory PASSED"
|
||||||
|
else
|
||||||
|
echo "Test $directory FAILED ********* Failure data is in $directory/compare"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
cp $directory/firewall $directory/firewall.last
|
||||||
|
echo "Test $directory INITIAL RUN"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Test $directory FAILED ********* Failure data is in $directory/compilererrors"
|
||||||
|
rm -f $directory/faildata
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user