Font Size: a A A

Research On Program Constraint Modeling In Unit Coverage Testing

Posted on:2022-09-17Degree:DoctorType:Dissertation
Country:ChinaCandidate:M Z ZhangFull Text:PDF
GTID:1488306326979499Subject:Computer Science and Technology
Abstract/Summary:PDF Full Text Request
Software testing plays an important role in improving software reliability.Coverage testing is a basic white-box testing approach in software testing.In order to satisfy test adequacy,coverage testing requires test data to achieve the highest possible coverage.Compared with other automatic test data generation approaches,constraint-based test data generation approach is easier to generate test cases satisfying the given test objective,and the generated test data has more advantages in coverage testing.However,to achieve the above advantages,we need to generate precise constraints for the target program.Insufficient accuracy of constraint modeling will lead to under-constraint problems of input variables,which will affect the correctness and readability of the generated test data.The test data generated with under-constraint problems is unreadable and hard to achieve high coverage.In this thesis,we focus on solving the under-constraint problem and related problems in the process of program constraint modeling,the research work is carried out from three aspects:how to extract the implicit constraints in the program,how to improve the readability of test data,and how to alleviate the adverse effects of unreadable test data.The main contributions and innovations of this thesis are summarized as follows:1)Implicit constraint extraction based on rule-directed symbolic executionIn unit testing,when dangerous operations such as division and dereference act on the input variables,the input variables must satisfy preconditions to ensure that the function can be executed successfully,and these preconditions are not explicitly present in the individual function,these preconditions are implicit constraints of the input variables and cannot be extracted by the conventional symbolic execution.Test data that does not satisfy the implicit constraints may lead to runtime errors or crash,as a result,the expected coverage cannot be achieved.This paper proposes a rule-directed symbolic execution approach to extract implicit constraints.The basic idea of this approach is to use predefined rules to enhance conventional symbolic execution and solve the under-constraint problem caused by the inability to extract implicit constraints.First,the semantics of operators in C language are systematically analyzed.Four types of implicit constraint extraction rules are predefined and applied to the symbolic execution.The predefined rules provide a hierarchical match model to accurately identify and extract implicit constraints in statements.Secondly,according to the distribution characteristics of implicit constraints,the constraint modeling objects are extended.In addition to conventional branch statements,our approach also analyzes and models assignment statements and declaration statements.Finally,the concept of integrated path constraint is proposed.An integrated constraint not only specifies the condition that input variables must satisfy,but also provides missing input preconditions of individual functions.Valid test data can be generated by solving integrated path constraints,valid test data can achieve a high coverage and improve test adequacy.Experimental results show that the proposed method can accurately extract implicit constraints;compared with similar tools,the proposed method can effectively improve the coverage of programs with implicit constraints.2)Research on readable test data generationDue to the lack of constraints,under-constrained variables may generate unreadable test data for testers.We propose an approach to obtain heuristic information by mining constant information.The heuristic information is used to generate extra constraints and seed the test data generation process.Firstly,the related constants associated with the input variables and the input variables with under-constraint problems are collected.Then,aggregation analysis and rating analysis are proposed to deal with the mined constant information.Aggregation analysis obtains heuristic information by cleaning and centralizing related constants;rating analysis achieves the heuristic inference of the relevant constant based on the semantics of association operation,strong heuristic-related constants are selected as seed.Finally,an extra constraints generation approach is proposed,which uses heuristic information to generate constraints for under-constrained variables;a heuristic test data generation algorithm is proposed,which uses seed to guide readable test data generation.The experimental results show that compared with tool that does not consider test data readability,the proposed approach can improve the test data readability and the efficiency of test data generation.3)Oracle data selection based on static analysisUnreadable test data may make it difficult for testers to give default expected output in limited time.This paper proposes a path-sensitive oracle data selection approach.Our approach divides the test oracle problem into several sub-oracle problems by selecting multiple oracle data for the tester to observe,thus alleviating the difficulties brought by unreadable test data for test oracle construction.In addition,selecting multiple oracle data to observe also gets more opportunities to capture error states.This approach first introduces the critical path analysis,which ranks the program paths based on the possibility that potential faults may exist in them,the ranked path can provide useful insights to testers during oracle construction.Then,we propose a quantity and quality analysis approach to select oracle data.The quantity analysis reduces the number of oracle data for each path based on their substitution relationships.The quality analysis ranks oracle data in accordance with the fault-detection capability.The quantity and quality analysis determines a minimal set of oracle data that is likely to detect faults during testing.The experimental results indicate that compared with the output-only approach,our approach can find more faults in a shorter time.
Keywords/Search Tags:software testing, symbolic execution, static analysis, program constraint, oracle data
PDF Full Text Request
Related items