Blame tests/parser_prios.sh

Packit 1422b7
# added 2015-05-05 by Rainer Gerhards
Packit 1422b7
# This file is part of the liblognorm project, released under ASL 2.0
Packit 1422b7
. $srcdir/exec.sh
Packit 1422b7
Packit 1422b7
test_def $0 "parser priorities, simple case"
Packit 1422b7
add_rule 'version=2'
Packit 1422b7
add_rule 'rule=:%{"name":"field", "type":"mac48"}%'
Packit 1422b7
add_rule 'rule=:%{"name":"rest", "type":"rest"}%'
Packit 1422b7
Packit 1422b7
execute 'f0:f6:1c:5f:cc:a2'
Packit 1422b7
assert_output_json_eq '{"field": "f0:f6:1c:5f:cc:a2"}'
Packit 1422b7
Packit 1422b7
execute 'f0-f6-1c-5f-cc-a2'
Packit 1422b7
assert_output_json_eq '{"field": "f0-f6-1c-5f-cc-a2"}'
Packit 1422b7
Packit 1422b7
# things that need to match rest
Packit 1422b7
Packit 1422b7
execute 'f0-f6:1c:5f:cc-a2'
Packit 1422b7
assert_output_json_eq '{ "rest": "f0-f6:1c:5f:cc-a2" }'
Packit 1422b7
Packit 1422b7
Packit 1422b7
# now the same with inverted priorites. We should now always have
Packit 1422b7
# rest matches.
Packit 1422b7
reset_rules
Packit 1422b7
add_rule 'version=2'
Packit 1422b7
add_rule 'rule=:%{"name":"field", "type":"mac48", "priority":100}%'
Packit 1422b7
add_rule 'rule=:%{"name":"rest", "type":"rest", "priority":10}%'
Packit 1422b7
Packit 1422b7
execute 'f0:f6:1c:5f:cc:a2'
Packit 1422b7
assert_output_json_eq '{"rest": "f0:f6:1c:5f:cc:a2"}'
Packit 1422b7
Packit 1422b7
execute 'f0-f6-1c-5f-cc-a2'
Packit 1422b7
assert_output_json_eq '{"rest": "f0-f6-1c-5f-cc-a2"}'
Packit 1422b7
Packit 1422b7
execute 'f0-f6:1c:5f:cc-a2'
Packit 1422b7
assert_output_json_eq '{ "rest": "f0-f6:1c:5f:cc-a2" }'
Packit 1422b7
Packit 1422b7
cleanup_tmp_files