netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
iptables-test Namespace Reference

Data Structures

class  Colors
 

Functions

def print_error
 
def delete_rule
 
def run_test
 
def execute_cmd
 
def run_test_file
 
def show_missing
 
def main
 

Variables

string IPTABLES = "iptables"
 
string IP6TABLES = "ip6tables"
 
string IPTABLES_SAVE = "iptables-save"
 
string IP6TABLES_SAVE = "ip6tables-save"
 
string EXTENSIONS_PATH = "extensions"
 
string LOGFILE = "/tmp/iptables-test.log"
 
 log_file = None
 

Function Documentation

def iptables-test.delete_rule (   iptables,
  rule,
  filename,
  lineno 
)
Removes an iptables rule

References execute_cmd(), and print_error().

Referenced by run_test().

Here is the call graph for this function:

Here is the caller graph for this function:

def iptables-test.execute_cmd (   cmd,
  filename,
  lineno 
)
Executes a command, checking for segfaults and returning the command exit
code.

:param cmd: string with the command to be executed
:param filename: name of the file tested (used for print_error purposes)
:param lineno: line number being tested (used for print_error purposes)

References print_error().

Referenced by delete_rule(), run_test(), and run_test_file().

Here is the call graph for this function:

Here is the caller graph for this function:

def iptables-test.main ( void  )

References run_test_file(), and show_missing().

Here is the call graph for this function:

def iptables-test.print_error (   reason,
  filename = None,
  lineno = None 
)
Prints an error with nice colors, indicating file and line number.

Referenced by delete_rule(), execute_cmd(), and run_test().

Here is the caller graph for this function:

def iptables-test.run_test (   iptables,
  rule,
  rule_save,
  res,
  filename,
  lineno 
)
Executes an unit test. Returns the output of delete_rule().

Parameters:
:param  iptables: string with the iptables command to execute
:param rule: string with iptables arguments for the rule to test
:param rule_save: string to find the rule in the output of iptables -save
:param res: expected result of the rule. Valid values: "OK", "FAIL"
:param filename: name of the file tested (used for print_error purposes)
:param lineno: line number being tested (used for print_error purposes)

References delete_rule(), execute_cmd(), len, and print_error().

Referenced by run_test_file().

Here is the call graph for this function:

Here is the caller graph for this function:

def iptables-test.run_test_file (   filename)
Runs a test file

:param filename: name of the file with the test rules

References execute_cmd(), len, and run_test().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

def iptables-test.show_missing ( )
Show the list of missing test files

Referenced by main().

Here is the caller graph for this function:

Variable Documentation

string iptables-test.EXTENSIONS_PATH = "extensions"
string iptables-test.IP6TABLES = "ip6tables"
string iptables-test.IP6TABLES_SAVE = "ip6tables-save"
string iptables-test.IPTABLES = "iptables"
string iptables-test.IPTABLES_SAVE = "iptables-save"
iptables-test.log_file = None
string iptables-test.LOGFILE = "/tmp/iptables-test.log"