File: parser_prios.sh

package info (click to toggle)
liblognorm 2.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,696 kB
  • sloc: ansic: 11,634; sh: 2,639; makefile: 255; python: 34
file content (39 lines) | stat: -rwxr-xr-x 1,115 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# added 2015-05-05 by Rainer Gerhards
# This file is part of the liblognorm project, released under ASL 2.0
. $srcdir/exec.sh

test_def $0 "parser priorities, simple case"
add_rule 'version=2'
add_rule 'rule=:%{"name":"field", "type":"mac48"}%'
add_rule 'rule=:%{"name":"rest", "type":"rest"}%'

execute 'f0:f6:1c:5f:cc:a2'
assert_output_json_eq '{"field": "f0:f6:1c:5f:cc:a2"}'

execute 'f0-f6-1c-5f-cc-a2'
assert_output_json_eq '{"field": "f0-f6-1c-5f-cc-a2"}'

# things that need to match rest

execute 'f0-f6:1c:5f:cc-a2'
assert_output_json_eq '{ "rest": "f0-f6:1c:5f:cc-a2" }'


# now the same with inverted priorities. We should now always have
# rest matches.
reset_rules
add_rule 'version=2'
add_rule 'rule=:%{"name":"field", "type":"mac48", "priority":100}%'
add_rule 'rule=:%{"name":"rest", "type":"rest", "priority":10}%'

execute 'f0:f6:1c:5f:cc:a2'
assert_output_json_eq '{"rest": "f0:f6:1c:5f:cc:a2"}'

execute 'f0-f6-1c-5f-cc-a2'
assert_output_json_eq '{"rest": "f0-f6-1c-5f-cc-a2"}'

execute 'f0-f6:1c:5f:cc-a2'
assert_output_json_eq '{ "rest": "f0-f6:1c:5f:cc-a2" }'

cleanup_tmp_files