From b62f6d3982cfcb7c5ea27843a68fca3c06ad4790 Mon Sep 17 00:00:00 2001 From: Steve Beattie Date: Tue, 10 Dec 2013 14:00:32 -0800 Subject: [PATCH] parser: more dbus variable testcases (v2) This patch adds more testcases around variables used in dbus rules. In particular, it - attempts to verify that variable expansion and alternation expansion results in identical DFA blobs, - tests that variables can be expanded within alternations, - tests that alternations can occur in variable definitions, and - that having alternations inside variable declarations that are used inside alternations results in parsing success Note that vars/vars_dbus_9.sd veers into stress test land, as the combinatoric expansion results in over 1000 dbus rule entries being generated, which means that DFA reduction on all the fields takes noticeable amounts of time (around 1s on my i5 ivy-core laptop). Patch history: v1: initial version v2: based on feedback: - add more alternation tests for cases where only part of the alternation is defined within a variable - mark test with nested alternations as being successful now that the patch that implements it was accepted v3: based on feedback from cboltz: - tst/simple_tests/vars/vars_dbus_9.sd: reference all variables declared, including a variable that references another variable Signed-off-by: Steve Beattie Acked-by: Seth Arnold --- parser/tst/equality.sh | 9 ++++++++- .../simple_tests/vars/vars_alternation_3.sd | 8 ++++++++ .../simple_tests/vars/vars_alternation_4.sd | 8 ++++++++ .../simple_tests/vars/vars_alternation_5.sd | 8 ++++++++ parser/tst/simple_tests/vars/vars_dbus_10.sd | 14 ++++++++++++++ parser/tst/simple_tests/vars/vars_dbus_11.sd | 14 ++++++++++++++ parser/tst/simple_tests/vars/vars_dbus_8.sd | 13 +++++++++++++ parser/tst/simple_tests/vars/vars_dbus_9.sd | 18 ++++++++++++++++++ 8 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 parser/tst/simple_tests/vars/vars_alternation_3.sd create mode 100644 parser/tst/simple_tests/vars/vars_alternation_4.sd create mode 100644 parser/tst/simple_tests/vars/vars_alternation_5.sd create mode 100644 parser/tst/simple_tests/vars/vars_dbus_10.sd create mode 100644 parser/tst/simple_tests/vars/vars_dbus_11.sd create mode 100644 parser/tst/simple_tests/vars/vars_dbus_8.sd create mode 100644 parser/tst/simple_tests/vars/vars_dbus_9.sd diff --git a/parser/tst/equality.sh b/parser/tst/equality.sh index 418043a15..7370c61f7 100755 --- a/parser/tst/equality.sh +++ b/parser/tst/equality.sh @@ -170,12 +170,19 @@ verify_binary_equality "dbus variable expansion" \ verify_binary_equality "dbus variable expansion, multiple values/rules" \ "/t { dbus (send, receive) path=/com/foo, dbus (send, receive) path=/com/bar, }" \ + "/t { dbus (send, receive) path=/com/{foo,bar}, }" \ + "/t { dbus (send, receive) path={/com/foo,/com/bar}, }" \ "@{FOO}=foo /t { dbus (send, receive) path=/com/@{FOO}, dbus (send, receive) path=/com/bar, }" \ "@{FOO}=foo bar /t { dbus (send, receive) path=/com/@{FOO}, }" \ "@{FOO}=bar foo - /t { dbus (send, receive) path=/com/@{FOO}, }" + /t { dbus (send, receive) path=/com/@{FOO}, }" \ + "@{FOO}={bar,foo} + /t { dbus (send, receive) path=/com/@{FOO}, }" \ + "@{FOO}=foo + @{BAR}=bar + /t { dbus (send, receive) path=/com/{@{FOO},@{BAR}}, }" \ verify_binary_equality "dbus variable expansion, ensure rule de-duping occurs" \ "/t { dbus (send, receive) path=/com/foo, dbus (send, receive) path=/com/bar, }" \ diff --git a/parser/tst/simple_tests/vars/vars_alternation_3.sd b/parser/tst/simple_tests/vars/vars_alternation_3.sd new file mode 100644 index 000000000..2b1bc0c96 --- /dev/null +++ b/parser/tst/simple_tests/vars/vars_alternation_3.sd @@ -0,0 +1,8 @@ +#=DESCRIPTION variable w/part of an alternation included +#=EXRESULT PASS + +@{BAR}={bar,baz,blort + +/does/not/exist { + /does/not/@{BAR},exist,notexist} r, +} diff --git a/parser/tst/simple_tests/vars/vars_alternation_4.sd b/parser/tst/simple_tests/vars/vars_alternation_4.sd new file mode 100644 index 000000000..c57adac06 --- /dev/null +++ b/parser/tst/simple_tests/vars/vars_alternation_4.sd @@ -0,0 +1,8 @@ +#=DESCRIPTION variable w/part of an alternation included +#=EXRESULT PASS + +@{BAR}=bar,baz,blort} + +/does/not/exist { + /does/not/{exist,notexist@{BAR}/meep r, +} diff --git a/parser/tst/simple_tests/vars/vars_alternation_5.sd b/parser/tst/simple_tests/vars/vars_alternation_5.sd new file mode 100644 index 000000000..46954a81d --- /dev/null +++ b/parser/tst/simple_tests/vars/vars_alternation_5.sd @@ -0,0 +1,8 @@ +#=DESCRIPTION variable w/part of an alternation included +#=EXRESULT PASS + +@{BAR}=bar,baz,blort + +/does/not/exist { + /does/not/{exist@{BAR}notexist}/meep r, +} diff --git a/parser/tst/simple_tests/vars/vars_dbus_10.sd b/parser/tst/simple_tests/vars/vars_dbus_10.sd new file mode 100644 index 000000000..4a5637edf --- /dev/null +++ b/parser/tst/simple_tests/vars/vars_dbus_10.sd @@ -0,0 +1,14 @@ +#=DESCRIPTION reference variables in dbus rules, var containing alternation +#=EXRESULT PASS + +@{BUSES}=session system +@{TLDS}=com org +@{MEMBERS}={Get,Set} + +/does/not/exist { + dbus (send, receive) + bus=@{BUSES} + path=/@{TLDS}/foo + member=@{MEMBERS}.bar, + +} diff --git a/parser/tst/simple_tests/vars/vars_dbus_11.sd b/parser/tst/simple_tests/vars/vars_dbus_11.sd new file mode 100644 index 000000000..03f2c40a5 --- /dev/null +++ b/parser/tst/simple_tests/vars/vars_dbus_11.sd @@ -0,0 +1,14 @@ +#=DESCRIPTION reference variables in dbus rules, nested embedded alternations +#=EXRESULT PASS + +@{BUSES}=session system +@{TLDS}=com org +@{MEMBERS}={Get,Set} + +/does/not/exist { + dbus (send, receive) + bus=@{BUSES} + path=/@{TLDS}/foo + member={@{MEMBERS}.bar,List.baz}, + +} diff --git a/parser/tst/simple_tests/vars/vars_dbus_8.sd b/parser/tst/simple_tests/vars/vars_dbus_8.sd new file mode 100644 index 000000000..03f135baa --- /dev/null +++ b/parser/tst/simple_tests/vars/vars_dbus_8.sd @@ -0,0 +1,13 @@ +#=DESCRIPTION reference variables in dbus rules, embedded within alternation +#=EXRESULT PASS + +@{TLDS}=com org +@{DOMAINS}=gnome freedesktop + +/does/not/exist { + dbus (send, receive) + bus=session + path={/@{TLDS}/foo,/com/@{DOMAINS}} + interface=@{TLDS}.freedesktop + peer=(name=@{TLDS}.freedesktop label=/@{TLDS}/freedesktop), +} diff --git a/parser/tst/simple_tests/vars/vars_dbus_9.sd b/parser/tst/simple_tests/vars/vars_dbus_9.sd new file mode 100644 index 000000000..1d25c279f --- /dev/null +++ b/parser/tst/simple_tests/vars/vars_dbus_9.sd @@ -0,0 +1,18 @@ +#=DESCRIPTION reference variables in dbus rules, multiple expansions +#=EXRESULT PASS + +@{BUSES}=session system +@{TLDS}=com org +@{DOMAINS}=gnome freedesktop +@{FOO}=bar baz +@{BAR}=@{FOO}/blort +@{MEMBERS}=Get Set + +/does/not/exist { + dbus (send, receive) + bus=@{BUSES} + path=/@{TLDS}/foo + member=@{MEMBERS}.bar + interface=@{TLDS}.@{DOMAINS} + peer=(name=@{TLDS}.@{DOMAINS} label=/@{TLDS}/@{BAR}), +}