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 <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
Steve Beattie 2013-12-10 14:00:32 -08:00
parent d3bc4e43a5
commit b62f6d3982
8 changed files with 91 additions and 1 deletions

View file

@ -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, }" \

View file

@ -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,
}

View file

@ -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,
}

View file

@ -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,
}

View file

@ -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,
}

View file

@ -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},
}

View file

@ -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),
}

View file

@ -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}),
}