resess / GoalExplorer

MIT License
7 stars 2 forks source link

Something wrong in stg.xml #13

Closed kotorinxn closed 2 months ago

kotorinxn commented 2 months ago

I used GoalExplorer 1.2.2-SNAPSHOT to generate the STG, and it seemed to be generated successfully. However, I encountered an error when running Stoat:

'target_action': undefined method `[]' for nil:NilClass (NoMethodError)

      @targets[target][0]

I checked the source code, and if I understand correctly, the targetAction value should be obtained from STG.xml when constructing the STG. However, I found that the targetAction values in stg.xml are all empty, as shown below:

<ScreenNode>
      <name>a2dp.Vol.main</name>
      <target>true</target>
      <targetAction/>
      <fragments/>
      <dialogs/>
      <baseScreen>true</baseScreen>
    </ScreenNode>

a2dp.Vol is an app from the benchmark. How can I resolve this issue?

kotorinxn commented 2 months ago

I tried using version 1.2.1, and the generated STG includes targetAction values.

dah-fari7009 commented 2 months ago

Hi,

I do not think the issue has to do with <targetAction> being empty, as by design this field can be empty, i.e., this field is only non empty if an extra action needs to be performed once the activity is reached to consider the target as reached, otherwise empty. I do not get this exception when running the dynamic explorer on the STG obtained with version 1.2.2 on the a2dp apk included in the benchmarks.

Please make sure that you followed all the instructions provided in the README and used the correct cmd line options for your use case. If the issue still persists, please provide the detailed steps to reproduce this issue, including the cmd line options you used for the static and dynamic explorers, which targets you set and which version of a2dp you're using. It'd be great if you also include the two STGs you obtained for reference.

kotorinxn commented 2 months ago

Thank you for your quick response. I attempted to migrate your project to a Windows environment and run it on a real device, but I believe the issue likely occurred during the static analysis process. I ran the following command:

java -jar target/GoalExplorer-1.2.2-SNAPSHOT-jar-with-dependencies.jar ge -s "D:\Android" -o "./out" --target "api:<android.app.Activity: void onCreate(android.os.Bundle)>" -i "E:\Project\GUIAutoExplore\benchmark\a2dp.Vol_169.apk"

The result is in the attached a2dp.Vol_169_stg.xml. Then, I ran the following command:

java -jar target/GoalExplorer-1.2.1-SNAPSHOT-jar-with-dependencies.jar ge -s "D:\Android" -o "./out1" --target "api:<android.app.Activity: void onCreate(android.os.Bundle)>" -i "E:\Project\GUIAutoExplore\benchmark\a2dp.Vol_169.apk"

The result is in the attached a2dp.Vol_169_1_stg.xml.

Next, I ran the dynamic exploration part using the following command:

ruby Stoat/bin/run_stoat_testing.rb --stoat_port 2001 --stg "E:\Project\GUIAutoExplore\GoalExplorer\GoalExplorer\out1\biz.gyrus.yaab_30_stg.xml" --apk_path "E:\Project\GUIAutoExplore\benchmark\biz.gyrus.yaab_30.apk" --real_device_serial my_device

When I used the STG result from version 1.2.1 for dynamic exploration, the previous issue didn't occur, but I encountered a problem with the app repeatedly restarting. I suspect this might be due to something going wrong during the migration to Windows. I'm currently investigating, and if I'm unable to resolve it, I'll reach out to you for assistance. a2dp.Vol_169_stg.xml.txt a2dp.Vol_169_1_stg.xml.txt

kotorinxn commented 2 months ago

I successfully experimented with the application biz.gyrus.yaab from benchmark using GoalExplorer on Windows and a real mobile device. I used the static analysis results from version 1.2.1. Based on the results, it appears to be successful, so I think the issue lies with the static analysis results of version 1.2.2.

Some of the experimental results for biz.gyrus.yaab are as follows:

reached_screen_node  #time_to_reach (sec)
biz.gyrus.yaab.MainActivity 9
biz.gyrus.yaab.CreditsActivity 45
biz.gyrus.yaab.RangesActivity 70
biz.gyrus.yaab.DonateActivity 95
Avg time to reach one screen node: 54.75
dah-fari7009 commented 2 months ago

Hello, I've further investigated the issue with the info you provided and the latest push should fix this issue.

For context, the problem was in the dynamic exploration and not actually related to targetAction being empty (as noted above, this field is designed so it does not always exist). In this case, due to a bug in node matching, the target node was mistakenly deleted in the stg at some point in the program and once the target was actually reached, it no longer existed in the STG (leading to the exception you observed). This exception indicates that the target node can not be found in the STG:

target_action': undefined method `[]' for nil:NilClass (NoMethodError)

      @targets[target][0]

The push also deals with the case of empty targets more efficiently by removing them alltogether in the dynamic explorer.

Hopefully this clarifies things and thank you for bringing this problem up!