arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2206.13828cs.SE
收藏

通过对输入数据结构的约束改进Python原生库的Tese实例生成

Improving Tese Case Generation for Python Native Libraries Through Constraints on Input Data Structures

Xin Zhang, Xutong Ma, Jiwen Yan, Baoquan Cui, Jun Yan, Jian Zhang

摘要:

现代Python项目使用本机库执行计算函数,并提供Python接口以提高执行速度;因此,测试这些库对于项目的健壮性至关重要。一个挑战是,现有的方法使用覆盖率来指导生成,但原生库作为没有执行信息的Python代码的黑盒运行。另一个原因是动态二进制插装降低了测试性能,因为它需要同时监控本机库和Python虚拟机。为了解决这些挑战,在本文中,我们提出了一个自动化的测试用例生成方法,在Python代码层工作。我们的见解是,原生库中的许多路径条件是通过与VM交互来处理输入数据结构。在我们的方法中,我们仪器的Python解释器来监视本地库和VM之间的交互,派生结构上的约束,然后使用约束来指导测试用例生成。我们在一个名为PyCing的工具中实现了我们的方法,并将其应用于六个广泛使用的Python项目。实验结果表明,在结构约束指导下,PyCing能够覆盖比现有测试用例和最先进工具更多的执行路径。此外,使用测试框架Pytest中的检查器,PyCing可以识别10个Python接口中的分段错误和9个接口中的内存泄漏。我们的仪器策略对测试效率也有可接受的影响。

英文摘要:

Modern Python projects execute computational functions using native libraries and give Python interfaces to boost execution speed; hence, testing these libraries becomes critical to the project's robustness. One challenge is that existing approaches use coverage to guide generation, but native libraries run as black boxes to Python code with no execution information. Another is that dynamic binary instrumentation reduces testing performance as it needs to monitor both native libraries and the Python virtual machine. To address these challenges, in this paper, we propose an automated test case generation approach that works at the Python code layer. Our insight is that many path conditions in native libraries are for processing input data structures through interacting with the VM. In our approach, we instrument the Python Interpreter to monitor the interactions between native libraries and VM, derive constraints on the structures, and then use the constraints to guide test case generation. We implement our approach in a tool named PyCing and apply it to six widely-used Python projects. The experimental results reveal that with the structure constraint guidance, PyCing can cover more execution paths than existing test cases and state-of-the-art tools. Also, with the checkers in the testing framework Pytest, PyCing can identify segmentation faults in 10 Python interfaces and memory leaks in 9. Our instrumentation strategy also has an acceptable influence on testing efficiency.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑