honeynet / droidbot

A lightweight test input generator for Android. Similar to Monkey, but with more intelligence and cool features!
MIT License
791 stars 230 forks source link

Add probalistic script support to DroidBotScript DSL #125

Closed connglli closed 2 years ago

connglli commented 3 years ago

Enable DSL to Support Probabilistic Behavior

In my experience using DroidBot, I often come across cases where DroidBot

  1. traps into a state and cannot return back, or
  2. is too random to accomplish an app task (take a todo app as example, DroidBot often fails to create a new todo), this hinders from constructing a complete and scemantically correct UTG

Although we can overcome the above problems by using the currently defined DroidBotScrip DSL, it does not introduce any probabilistic behaviors, i.e., it always executes the operations of a matched state in a round-robin manner.

We meant to support DroidBotScrip DSL with the probabilistic ability without breaking current DSL. With such DSL, a user can control DroidBot to accomplish some specific tasks at a specific state probabilistically. This is helpful to construct a complete and scemantically correct UTG.

Example

The following example shows the probalistic support. This means that, when in welcome_state_1, DroidBot would execute swipe_operation with the probability of 0.8 and skip_operation with the probability of 0.2. However, when in welcome_state_2, DroidBot executes these two operations round-robin.

"main": {
    "welcome_state_1": [
        {
            "op_id": "swipe_operation",
            "prob": 0.8
        },
        {
            "op_id": "skip_operation",
            "prob": 0.2
        }
    ],
    "welcome_state_2": [ "swipe_operation", "skip_operation" ]
}
yuanchun-li commented 2 years ago

Thanks for the contribution, and sorry for the late merge. It looks like a very useful feature.