Blame tests/field_recursive.sh

Packit 1422b7
# added 2014-11-26 by singh.janmejay
Packit 1422b7
# This file is part of the liblognorm project, released under ASL 2.0
Packit 1422b7
Packit 1422b7
uname -a | grep "SunOS.*5.10"
Packit 1422b7
if [ $? -eq 0 ] ; then
Packit 1422b7
   echo platform: `uname -a`
Packit 1422b7
   echo This looks like solaris 10, we disable known-failing tests to
Packit 1422b7
   echo permit OpenCSW to build packages. However, this are real failurs
Packit 1422b7
   echo and so a fix should be done as soon as time permits.
Packit 1422b7
   exit 77
Packit 1422b7
fi
Packit 1422b7
. $srcdir/exec.sh
Packit 1422b7
Packit 1422b7
test_def $0 "recursive parsing field"
Packit 1422b7
Packit 1422b7
#tail recursion with default tail field
Packit 1422b7
add_rule 'rule=:%word:word% %next:recursive%'
Packit 1422b7
add_rule 'rule=:%word:word%'
Packit 1422b7
execute '123 abc 456 def'
Packit 1422b7
assert_output_json_eq '{"word": "123", "next": {"word": "abc", "next": {"word": "456", "next" : {"word": "def"}}}}'
Packit 1422b7
Packit 1422b7
#tail recursion with explicitly named 'tail' field
Packit 1422b7
reset_rules
Packit 1422b7
add_rule 'rule=:%word:word% %next:recursive:tail%'
Packit 1422b7
add_rule 'rule=:%word:word%'
Packit 1422b7
execute '123 abc 456 def'
Packit 1422b7
assert_output_json_eq '{"word": "123", "next": {"word": "abc", "next": {"word": "456", "next" : {"word": "def"}}}}'
Packit 1422b7
Packit 1422b7
#tail recursion with tail field having arbirary name
Packit 1422b7
reset_rules
Packit 1422b7
add_rule 'rule=:%word:word% %next:recursive:foo%'
Packit 1422b7
add_rule 'rule=:%word:word%'
Packit 1422b7
execute '123 abc 456 def'
Packit 1422b7
assert_output_json_eq '{"word": "123", "next": {"word": "abc", "next": {"word": "456", "next" : {"word": "def"}}}}'
Packit 1422b7
Packit 1422b7
#non tail recursion with default tail field 
Packit 1422b7
reset_rules
Packit 1422b7
add_rule 'rule=:blocked on %device:word% %net:recursive%at %tm:date-rfc5424%'
Packit 1422b7
add_rule 'rule=:%ip_addr:ipv4% %tail:rest%'
Packit 1422b7
add_rule 'rule=:%subnet_addr:ipv4%/%mask:number% %tail:rest%'
Packit 1422b7
execute 'blocked on gw-1 10.20.30.40 at 2014-12-08T08:53:33.05+05:30'
Packit 1422b7
assert_output_json_eq '{"device": "gw-1", "net": {"ip_addr": "10.20.30.40"}, "tm": "2014-12-08T08:53:33.05+05:30"}'
Packit 1422b7
execute 'blocked on gw-1 10.20.30.40/16 at 2014-12-08T08:53:33.05+05:30'
Packit 1422b7
assert_output_json_eq '{"device": "gw-1", "net": {"subnet_addr": "10.20.30.40", "mask": "16"}, "tm": "2014-12-08T08:53:33.05+05:30"}'
Packit 1422b7
Packit 1422b7
#non tail recursion with tail field being explicitly named 'tail'
Packit 1422b7
reset_rules
Packit 1422b7
add_rule 'rule=:blocked on %device:word% %net:recursive:tail%at %tm:date-rfc5424%'
Packit 1422b7
add_rule 'rule=:%ip_addr:ipv4% %tail:rest%'
Packit 1422b7
add_rule 'rule=:%subnet_addr:ipv4%/%mask:number% %tail:rest%'
Packit 1422b7
execute 'blocked on gw-1 10.20.30.40 at 2014-12-08T08:53:33.05+05:30'
Packit 1422b7
assert_output_json_eq '{"device": "gw-1", "net": {"ip_addr": "10.20.30.40"}, "tm": "2014-12-08T08:53:33.05+05:30"}'
Packit 1422b7
execute 'blocked on gw-1 10.20.30.40/16 at 2014-12-08T08:53:33.05+05:30'
Packit 1422b7
assert_output_json_eq '{"device": "gw-1", "net": {"subnet_addr": "10.20.30.40", "mask": "16"}, "tm": "2014-12-08T08:53:33.05+05:30"}'
Packit 1422b7
Packit 1422b7
#non tail recursion with tail field having arbirary name
Packit 1422b7
reset_rules
Packit 1422b7
add_rule 'rule=:blocked on %device:word% %net:recursive:remaining%at %tm:date-rfc5424%'
Packit 1422b7
add_rule 'rule=:%ip_addr:ipv4% %remaining:rest%'
Packit 1422b7
add_rule 'rule=:%subnet_addr:ipv4%/%mask:number% %remaining:rest%'
Packit 1422b7
execute 'blocked on gw-1 10.20.30.40 at 2014-12-08T08:53:33.05+05:30'
Packit 1422b7
assert_output_json_eq '{"device": "gw-1", "net": {"ip_addr": "10.20.30.40"}, "tm": "2014-12-08T08:53:33.05+05:30"}'
Packit 1422b7
execute 'blocked on gw-1 10.20.30.40/16 at 2014-12-08T08:53:33.05+05:30'
Packit 1422b7
assert_output_json_eq '{"device": "gw-1", "net": {"subnet_addr": "10.20.30.40", "mask": "16"}, "tm": "2014-12-08T08:53:33.05+05:30"}'
Packit 1422b7
Packit 1422b7
Packit 1422b7
Packit 1422b7
cleanup_tmp_files
Packit 1422b7