节点文献
Android应用的环境适应性缺陷检测技术研究
Detecting Environmental Adaptability Defects for Android Applications
【作者】 刘毅;
【作者基本信息】 南京大学 , 计算机科学与技术, 2020, 硕士
【摘要】 智能手机应用在人们的生活中发挥着越来越重要的作用,但是智能手机应用缺陷也越来越常见,严重影响着用户体验。虽然智能手机应用缺陷种类复杂,但许多应用缺陷都可以归因于智能手机复杂多变的运行环境。这一类由运行环境触发的应用缺陷统称为环境适应性缺陷。本文关注的研究问题即为Android应用环境适应性缺陷检测方法。环境适应性缺陷由于触发因素复杂,开发者往往难以定位,需要自动化测试工具的帮助。已有工作往往只能检测某个特定的环境适应性缺陷,而无法给出通用的问题分析与缺陷检测方法。本文通过对环境适应性缺陷内在规律的分析,发现应用的运行环境与应用缺陷可以通过应用资源相联系。运行环境作用于应用中的资源,影响资源的性质,并触发应用的缺陷。基于这个发现,本文提出了一种检测环境适应性缺陷的测试预言设计框架。该框架以资源为视角,将应用的运行环境与应用缺陷联系了起来。使用这个框架,可以从环境适应性缺陷相关的资源入手,通过判断资源所具备的性质、确定应用需要具备的资源管理能力,来设计出应用需要满足的规约。本文展示了此框架应用于两个具体的环境适应性问题上得到的检测方法与工具,以证明测试预言设计框架的有效性。将测试预言设计框架应用于Android应用的能源低效问题检测上,可以得到Navy Droid工具。Android应用所提供的丰富的功能中,有许多功能需要高耗能操作。如果高耗能操作使用不当,会导致能源的消耗无法带来实际的用户收益,出现能源低效问题。运用测试预言设计框架对能源低效问题进行分析,可以得出此类缺陷涉及到的资源为传感器等耗电类资源,资源具有易泄漏性。因此,Navy Droid从资源生命周期管理能力出发,设计了能源低效问题模式。在运行时,通过判断耗电类资源的状态是否与组件的生命周期状态一致,检测应用的资源生命周期管理能力。Navy Droid方法使用精确的应用状态模型模拟了组件的生命周期状态,并从资源生命周期管理出发设计了全面的能源低效问题模式。Navy Droid从真实的Android应用中检测出了17个能源低效缺陷,并相比已有工作有检测效果和效率上的提升。将测试预言设计框架应用于Android应用在多变网络条件中的缺陷检测,可以得到ANIP工具。Android应用所提供的丰富功能中,绝大部分功能需要依赖于网络。由于智能手机的网络环境复杂多变,非常容易影响应用的功能,进而触发应用缺陷。由多变网络环境引发的应用缺陷表现形式多样,难以定位和修复。运用测试预言设计框架对网络缺陷进行分析,可以得出此类缺陷涉及到的资源为网络连接资源,资源具有间断性和易变性。因此,ANIP从资源状态管理能力出发,关注应用能否抵御网络连接状态的变化,并在面临不利网络条件时维持其正常功能。ANIP在应用原有测试用例的基础上构造不利网络条件,通过插入网络事件的方式模拟实际的网络条件变化。在应用运行时,通过观察不利网络条件出现和结束后的应用功能是否正常,可以检测应用的资源状态管理能力。ANIP通过设计应用行为的蜕变关系,比较应用行为,来评估应用是否恢复了正常的功能。ANIP从真实的Android应用中触发并检测出了网络缺陷,其中部分缺陷得到了应用开发者的确认与修复。以上两种缺陷检测方法是环境适应性缺陷测试预言设计框架应用于两种资源上,形成的两种具体的检测方法。两种方法针对具体的缺陷均有比较好的检测效果。测试预言设计框架在检测方法与应用规约设计中起到了重要的作用,展示了该框架的有效性。
【Abstract】 Smartphone applications are vital in people’s lives,but application defects are also common,seriously affecting user experiences.Although the types of application defects are complex,many application defects can be attributed to the changing environment of smartphones.This type of application defects triggered by the environment are named environmental adaptability defects.This paper focuses on the research problem of environmental adaptability defect detection of Android applications.These application defects are often difficult to locate for developers due to their complicated triggering factors.Thus,automated testing and detection tools are needed.Existing work can only detect a specific environmental adaptability defect,without a general problem analysis and detection approach.This paper find that the application defects can be linked to the environment through application resources,after the analysis of the inherent principle of environmental adaptability defects.The environment acts on the resources in an application,affects the property of some resources,and then triggers application defects.According to this finding,this paper proposes a design framework of test oracles for environmental adaptability defects.This framework links the application’s defects with environment from the perspective of resources.Using this framework,we can start with environmental adaptability related resources,and design specifications for an application by determining the properties of resources and the resource management capabilities that the application should have.This paper demonstrates the detection approaches and tools obtained by applying this framework to two specific environmental adaptability problems,in order to prove the effectiveness of this test oracle design framework.First,we apply the test oracle design framework to the detection of energy inefficiency problems in Android applications,and propose the Navy Droid tool.Among the rich functions provided by Android applications,many require energy consuming operations.If these operations are not performed properly,much energy will be wasted without user benefits,resulting in energy inefficiency.Using the test oracle design framework to analyze energy inefficiency problem,we can conclude that such defects involves power consumption resources such as sensors,which are easy to leak.Therefore,we design energy inefficiency patterns from the perspective of resource lifecycle management capabilities.At runtime,the application’s resource lifecycle management capabilities are evaluated by determining whether the states of resources are consistent with the states of application components.The Navy Droid approach simulates the lifecycle states of application components with an accurate application execution model,and design a complete suite of energy inefficiency patterns from the perspective of resource lifecycle management.Navy Droid has detected 17 energy inefficiency defects from real-world Android applications,and has improved detection effectiveness and efficiency compare to existing work.Second,we apply the test oracle design framework to the detection of changing network induced problems in Android applications,and propose the ANIP tool.Among the rich functions provided by Android applications,many depend on network access.The complex and variable network environments of smartphones often influence application functions,and trigger application defects.The defects induced by changing network conditions have various forms,and are difficult to locate and repair.Using the test oracle design framework to analyze these network defects,we can conclude that such defects involves network connection resource,which is intermittent and volatile.Therefore,we determine whether an application and resist the change of network connection state and maintain its normal function when facing adversary network conditions from the perspective of resource state management capabilities.ANIP constructs adversary network conditions based on original test cases,and simulates network condition changes by inserting network events.At runtime,the application’s resource state management capabilities can be evaluated by tracking application functions during and after the adversary network condition.ANIP determines whether the application has restored its normal functions by designing metamorphic relations for application be-haviors,and comparing application behaviors in two runs.The ANIP tool has triggered and detected network Defects from real-world Android applications,some of which are confirmed and fixed by developers.The two tools,Navy Droid and ANIP,focus on different specific defects in environmental adaptability defects,and propose effective approaches for specific defects.The test oracle design framework plays an important role in the construction of approach and the design of application specifications of the two tools,demonstrating the effectiveness of the test oracle design framework presented in this paper.
【Key words】 smartphone application; bug detection; environment adaptability;