[go: up one dir, main page]

WO2024232193A1 - Information processing device, information processing method, and computer program - Google Patents

Information processing device, information processing method, and computer program Download PDF

Info

Publication number
WO2024232193A1
WO2024232193A1 PCT/JP2024/013516 JP2024013516W WO2024232193A1 WO 2024232193 A1 WO2024232193 A1 WO 2024232193A1 JP 2024013516 W JP2024013516 W JP 2024013516W WO 2024232193 A1 WO2024232193 A1 WO 2024232193A1
Authority
WO
WIPO (PCT)
Prior art keywords
function
test
execution
information processing
processing device
Prior art date
Application number
PCT/JP2024/013516
Other languages
French (fr)
Japanese (ja)
Inventor
涼太 湯川
Original Assignee
ソニーグループ株式会社
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ソニーグループ株式会社 filed Critical ソニーグループ株式会社
Publication of WO2024232193A1 publication Critical patent/WO2024232193A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software

Definitions

  • this disclosure relates to an information processing device and information processing method that perform processing related to program development, and a computer program.
  • testing is performed to detect program defects and ensure operation. For example, testing is performed by creating test cases with inputs and outputs described in the specifications or expected by the developer, and checking whether the program returns the correct output for the input. If the correct output is not returned for the input, or if an exception (fault) occurs and the program does not operate, it is determined to be a defect. The developer then analyzes the program to identify the cause and correct the program logic. To ensure high quality and reliability of the program, tests must be performed with high coverage.
  • the objective of this disclosure is to provide an information processing device, an information processing method, and a computer program that perform processing to generate high-coverage test code.
  • the present disclosure has been made in consideration of the above problems, and a first aspect thereof is: an analysis unit that analyzes source code to collect type information of the source code and generate object initialization functions; a symbolic execution driver generator that generates a symbolic execution driver using the type information and an object initialization function; a symbolic execution unit that executes the symbolic execution driver generated by the symbolic execution driver generation unit to generate a test case; a test code generation unit that generates a test code for applying the test cases generated by the symbol execution unit to a program under test and executing the program;
  • the information processing device includes:
  • the analysis unit performs static analysis on the program to be tested, which is written in a statically typed language, and examines the types of variables created by the function that calls the function to be tested and the functions that pass them, thereby narrowing down the types of arguments to be passed to the function to be tested.
  • the analysis unit also instruments the dynamically typed language program under test so that the types of variables passed to the function under test are output as an execution trace immediately before the function under test is called, passes input to the instrumented program, executes it, collects the execution trace, and analyzes the type information and objects of the variables passed to the function under test from the collected execution trace.
  • the analysis unit also performs instrumentation to output, as an execution trace, the methods that were called from when an object was created until it was deleted, and the order in which they were called, so that the method sequence for initializing each object can be collected, and analyzes the execution trace to generate an object initialization function.
  • the symbolic execution driver generation unit initializes and symbolizes variables to be passed to the function to be tested, and generates a symbolic execution driver consisting of code that simply calls the function to be tested.
  • the test code generation unit executes the symbol execution driver generated by the symbol execution driver generation unit on a symbol execution engine, and generates test code for the function to be tested using the test cases generated as input values.
  • a second aspect of the present disclosure is an analysis step of analyzing the source code to generate type information and object initialization functions for the source code; a symbolic execution driver generation step of generating a symbolic execution driver using the type information and an object initialization function; a symbolic execution step of executing the symbolic execution driver generated in the symbolic execution driver generation step to generate a test case; a test code generation step of generating test code for applying the test cases generated in the symbol execution step to a program under test and executing the program;
  • the information processing method includes the steps of:
  • a third aspect of the present disclosure is an analysis unit that analyzes the source code and generates type information and object initialization functions for the source code; a symbolic execution driver generator that generates a symbolic execution driver using the type information and an object initialization function; a symbolic execution unit that executes the symbolic execution driver generated by the symbolic execution driver generation unit to generate test cases; a test code generation unit that generates a test code for applying the test cases generated by the symbol execution unit to a program to be tested and executing the program; It is a computer program written in a computer-readable form to cause a computer to function as a
  • the computer program according to the third aspect of the present disclosure defines a computer program written in a computer-readable format to realize a specified process on a computer.
  • the computer program can be provided to a computer capable of executing various program codes in a computer-readable format via a storage medium or communication medium, such as an optical disk, magnetic disk, or semiconductor memory, or a communication medium such as a network.
  • an information processing device when testing a program, analyzes source code and automatically generates argument type information and object initialization functions to create meaningful test cases.
  • FIG. 1 is a diagram showing a functional configuration of an automatic test generation device 100 to which the present disclosure is applied.
  • FIG. 2 is a flowchart showing an example of a processing procedure for automatically generating test code for a source code.
  • FIG. 3 is a diagram showing an example of the hardware configuration of the information processing device 2000.
  • statically typed languages such as C/C++
  • ambiguous type expressions such as void pointers can be used.
  • dynamically typed languages there is no need to specify the type of arguments passed to functions, so values or objects of any type can be passed. The exact type of variable passed to a function cannot be known until the program is executed.
  • the user (such as the program developer) must add type annotations to each function that uses a void pointer or each function in a dynamically typed language. Without these annotations, meaningless tests that simply pass a null pointer to a function that uses a void pointer, tests that cause null pointer dereference exceptions, or huge test cases that use all types used in the program as input will be generated.
  • the linked list class provides methods such as add (adding and inserting an element), size (getting the number of elements), get (getting the object stored in an element), set (replacing an element), and remove (deleting an element).
  • a test support device uses annotations to automatically generate drivers and stubs for functions to be tested in a dynamic typed language, while generating correct test drivers and stubs even when incorrect annotations (comments in the source code) are added (see Patent Document 1).
  • a test driver is a program for calling and executing functions and classes to be tested.
  • a stub is a dummy function and class that is called by the functions and classes to be tested (stubs may be created so that tests can be performed even for functions and classes that are difficult to test because they access a network or database).
  • This test support device repeatedly modifies the driver so that the error is eliminated when an undefined method of an object given as a test case is called in the function to be tested, and ultimately generates a correct test driver.
  • it is a very cumbersome task for the user to add annotations to all functions to be tested, which places a heavy burden on the user.
  • test code with high coverage that reflects the user's design intent can be automatically generated, even if the user does not provide type information for the source code or initialization functions for objects.
  • An automatic test code generation tool to which the present disclosure is applied does not require the user to input type annotations or object initialization functions.
  • an automatic test code generation tool to which the present disclosure is applied can generate test code with restricted types for void pointers and function arguments in dynamically typed languages, and can generate test code that uses object initialization functions.
  • test code "test case,” and “coverage” are used with the following meanings:
  • Test code This is the source code for providing various test cases to the program and executing them.
  • Test case An input given to the program under test.
  • Coverage In this specification, “coverage” refers to line coverage, which is the percentage of which lines of source code are executable and which are not.
  • Source code and “program” both refer to computer programs, but the former refers to a data format that is easy for humans to understand and write, such as a programming language, while the latter program refers to a format that has been built into an executable format. Also, “function” and “method” are synonymous, but a function that belongs to an object is called a "method.”
  • FIG. 1 shows a schematic functional configuration of an automatic test generation device 100 to which the present disclosure is applied.
  • the automatic test generation device 100 inputs source code, and outputs test code for executing the source code by providing various test cases.
  • a downstream test execution device (not shown) can execute a high-coverage test of the source code using the test code generated by the automatic test generation device 100.
  • the automatic test generation device 100 can be realized using a general information processing device such as a personal computer (PC).
  • the automatic test generation device 100 may also be a device that is physically integrated with the test execution device.
  • the automatic test generation device 100 shown in FIG. 1 includes a type information generation unit 101, an object initialization function generation unit 102, a symbol execution driver generation unit 103, a symbol execution unit 104, and a test code generation unit 105.
  • the type information generation unit 101 is configured to analyze the source code of the test target and generate type information.
  • the object initialization function generation unit 102 is configured to analyze the source code of the test target and generate an object initialization function. Therefore, since the automatic test generation device 100 automatically generates type information and object initialization functions internally, it is possible to automatically generate meaningful test code with high coverage even if the user does not provide type information of the source code or initialization functions of objects.
  • the type information generating unit 101 first performs a static analysis to find out what type of variables are created in the function that calls the function to be tested and passed as arguments to the function to be tested, thereby narrowing down the types of variables to be passed to a certain number of functions.
  • the type information generation unit 101 refers to the line in the above source code where the function under test is called, and checks what type of variable is passed by the function that called the function under test.
  • the type information generation unit 101 checks line 7 and finds that the function under test swap is called by function function, and further checks line 5 and finds that function function declares the types of variables x and y that it passes to function swap under test. Therefore, the type information generation unit 101 can narrow down the type passed to function swap under test to type int.
  • B-1-2 Dynamic Analysis
  • the simple static analysis described in B-1-1 above is not enough to accurately narrow down the type for all cases. Also, if the source code to be tested is written in a dynamically typed language, any type of value or object can be stored in the same variable, so it is impossible to determine what type of value or object is passed to the function unless the program is actually run. For such functions, type information is collected by performing the dynamic analysis described in B-1-2.
  • the type information generation unit 101 instruments the program under test so that the types of variables to be passed to the functions under test are output as an execution trace immediately before calling each function under test.
  • the type information generation unit 101 passes input to the instrumented program and executes it.
  • the type information generation unit 101 can generate input to the program using test case generation techniques such as random generation, fuzzing, and symbolic execution.
  • test case generation techniques such as random generation, fuzzing, and symbolic execution.
  • the type information generation unit 101 generates such test cases and executes the program to be tested using the generated test cases as input for a certain period of time, and from the execution trace collected, analyzes what types of variables and objects are being passed to the function to be tested.
  • the function to be tested is the function add, which consists of the following code.
  • the arguments x and y of the function to be tested add are passed as int type
  • the arguments x and y of the function to be tested add are passed as float type.
  • the type information generation unit 101 performs instrumentation for the above add function so that the types of the variables passed to the function are output as an execution trace, and by inputting and executing a test case generated by a predetermined method, it is possible to obtain an execution trace such as the one shown below.
  • This execution trace includes a trace result in which an int type is passed to the arguments x and y of the test target function add, which corresponds to the fourth line of the source code, and a trace result in which a float type is passed to the arguments x and y of the test target function add, which corresponds to the fifth line of the source code.
  • an automatic test generation tool outputs such an execution trace as an intermediate product.
  • the type information generation unit 101 can obtain type information that the arguments x and y of the test target function add may be of type int or of float.
  • the symbolic execution driver generation unit 103 in the latter stage generates a symbolic execution driver using the type information collected by the type information generation unit 101 through static and dynamic analysis of the source code. However, details of the symbolic execution driver generation will be explained in Section B-3 below.
  • Fuzzing is a technique for testing the behavior of a program by repeatedly running the program while modifying randomly generated input values or input values received from the user to generate new input values. Fuzzing can be done in two ways: by modifying part of the input values to increase the coverage of the program, or by modifying part of the input values to reach a specific line in the program.
  • Symbolic execution is a method for comprehensively exploring the behavior of a program by treating the program inputs as symbolic values (symbols) rather than concrete values.
  • the program is executed while collecting the program's branching conditions, and when the search for each execution path is finished, the branching conditions collected up to that point are solved using a constraint solver, making it possible to generate input values that will take that execution path.
  • This section B-2 describes a method for the object initialization function generator 102 to automatically generate object initialization functions that are required to generate high-coverage tests for code to be tested in an object-oriented language.
  • the object initialization function generation unit 102 instruments the program to be tested, inputs input values generated using test case generation techniques such as random generation, fuzzing, and symbolic execution to the instrumented program, executes the program, and obtains an execution trace.
  • the object initialization function generation unit 102 records, as an execution trace, which methods of an object were called and in what order from the time the object was created to the time it was deleted, so that it can collect the method sequence for initializing each object. For this reason, the object initialization function generation unit 102 instruments the program to be tested so that it outputs the object type name, object identification information, and the called method name as an execution trace immediately before calling a method. The object initialization function generation unit 102 then passes input to the instrumented program, executes it, collects the execution trace, extracts the method sequence for initializing the object from the collected execution trace, and generates an object initialization function from the extracted method sequence.
  • an execution trace is collected for the following code.
  • an object s1 of the SampleClass class is generated on line 12
  • an object s2 of the SampleClass class is generated on line 13.
  • the methods init, setLocation, calc, and finalize of object s1 are called in order on lines 14, 16, 17, and 19, respectively
  • the methods init, calc, and finalize of object s2 are called in order on lines 15, 18, and 20, respectively.
  • the object initialization function generation unit 102 performs instrumentation on this code just before calling a method so that the object type name, object identification information, and the name of the called method are output as an execution trace.
  • the object initialization function generation unit 102 instruments the above code, inputs the generated test cases into the instrumented program, and executes them to collect the object type name (Class), object identification information (id), and called method name (function) as an execution trace, as shown below.
  • Class object type name
  • id object identification information
  • function method name
  • object type name is SampleClass.
  • objects s1 and s2 generated from SampleClass are automatically assigned object identification information "1" and "2", respectively.
  • the object initialization function generation unit 102 can extract, from the information obtained by the above execution trace, a method sequence that indicates what methods were called and in what order for the object to be passed to the function under test from the time the object to be passed to the function under test was generated until the function under test was called. By summarizing the above execution trace for each object's identification information, the object initialization function generation unit 102 can obtain the following two method sequences: method sequence 1 corresponding to object s1 and method sequence 2 corresponding to object s2.
  • Method sequence 1 init ⁇ setLocation ⁇ calc ⁇ finalize
  • Method sequence 2 init ⁇ calc ⁇ finalize
  • the process of acquiring the execution trace by the object initialization function generation unit 102 described in section B-2-1 can be performed together with the process performed by the type information generation unit 101 described in section B-1-2 above.
  • the automatic test generation tool outputs such an execution trace as an intermediate product (ibid.).
  • B-2-2 Creation of a new method sequence
  • the object initialization function generation unit 102 creates a new method sequence using the method described in B-2-2, and adds it to create an object initialization function.
  • B-2-2-2 Mutation In this method, a new method sequence is generated by modifying part of the method sequence extracted by the dynamic analysis described in B-2-1 above. There are three ways to modify part of the method sequence: adding a method, deleting a method, and modifying a method.
  • Adding a Method Randomly select one of the object's public methods and insert it at a random position in the method sequence.
  • Method deletion Randomly select one method from the sequence and delete it.
  • Method modification Randomly select one method from the set of methods and replace it with another public method.
  • B-2-2-3 Use of Machine Learning
  • the execution trace collected by the dynamic analysis described in B-2-1 above is used to learn what methods of the object passed to the test target function are called before the test target function is called. For example, by learning from naming conventions that when the test target function is remove**, functions such as add**, init**, and insert** tend to be called before calling such a method, even if the test target function does not appear in the execution trace, a sequence of methods that must be executed before calling the test target function can be generated.
  • the object initialization function generation unit 102 evaluates the new method sequence generated by modifying it using at least one of the above-mentioned random generation, mutation, and machine learning methods, deletes unnecessary method sequences that do not contribute to coverage, and leaves only method sequences that can increase coverage.
  • the object initialization function generation unit 102 generates a test driver using the newly generated method sequence, and performs fuzzing and symbolic execution on the test driver to measure coverage. Only those method sequences that cover lines that cannot be reached by existing method sequences are retained, and those that do not are deleted. The object initialization function generation unit 102 repeats this process for a fixed period of time, or until coverage no longer improves.
  • a method change is made to the method sequence 1: init ⁇ setLocation ⁇ calc ⁇ finalize shown in section B-2-1 above.
  • a mutation can be used to change the method setLocation included in method sequence 1 to another method, finalize, to generate a new method sequence 1': init ⁇ finalize ⁇ calc ⁇ finalize as shown below.
  • test driver like the one below is generated, and fuzzing and symbolic execution are performed on this test driver.
  • the object initialization function generation unit 102 generates an object initialization function that initializes an object using a newly generated method sequence according to the explanation in B-2-2 above.
  • the object initialization function generation unit 102 generates an object initialization function for each method sequence generated as explained in B-2-2 above.
  • the object initialization function generation unit 102 generates the following object initialization function for the above method sequence 1 (init ⁇ setLocation ⁇ calc ⁇ finalize):
  • the object initialization function generation unit 102 generates the following object initialization function for the above method sequence 2 (init ⁇ calc ⁇ finalize).
  • the symbol execution driver generation unit 103 generates code to be run on the symbol execution engine, i.e., a symbol execution driver, from the source code received as input, the type information generated by the type information generation unit 101 (see B-1 above), and the object initialization function generated by the object initialization function generation unit 102 (see B-2 above).
  • the symbolic execution driver is code that simply initializes and symbolizes variables to be passed to the function under test, and calls the function under test.
  • the symbolic execution driver generation unit 103 uses the type information generated by the type information generation unit 101 and the object initialization function generated by the object initialization function generation unit 102. If the function under test is a function that receives a void pointer as an argument, or is a function in a dynamically typed language, the symbolic execution driver generation unit 103 initializes variables with a type that may be passed to the function, based on the type information generated by the type information generation unit 101. If there is a possibility that multiple types may be passed, the symbolic execution driver generation unit 103 generates a symbolic execution driver separately for each type.
  • type information indicating that variables of type int and type float may be passed to the function under test can be obtained from the type information generation unit 101.
  • the symbol execution driver generation unit 103 generates a symbol execution driver for each of the int and float types separately.
  • the symbol execution driver generation unit 103 generates a symbol execution driver such as the one below, which passes an int type as an argument.
  • the symbol execution driver generation unit 103 also generates a symbol execution driver like the one below, which passes a float type as an argument.
  • the symbolic execution driver generation unit 103 checks whether or not there is a function that can initialize the object among the object initialization functions generated by the object initialization function generation unit 102 as described above. If such a function exists, the symbolic execution driver generation unit 103 calls the function to initialize the object, and inserts code into the symbolic execution driver that initializes and symbolizes variables passed as arguments to the object initialization function.
  • the symbol execution driver generation unit 103 generates, for example, the following code for the object initialization function of the above method sequence 1 (init ⁇ setLocation ⁇ calc ⁇ finalize).
  • the symbol execution driver generation unit 103 inserts into the symbol execution driver code that initializes and symbolizes variables passed as arguments to the object initialization function.
  • the symbolic execution unit 104 executes the symbolic execution driver generated by the symbolic execution driver generation unit 103 on the symbolic execution engine to generate test cases. Then, the test code generation unit 105 generates test code for the function to be tested using the test cases generated by the symbolic execution unit 105 as input values.
  • the test code generation unit 105 generates test code using the object initialization function generated by the object initialization function generation unit 102.
  • the test code generation unit 105 generates test code such as the following using the object initialization function generated by the object initialization function generation unit 102.
  • FIG. 2 shows, in the form of a flowchart, an example of a processing procedure for automatically generating test code from source code in the automatic test generation device 100 according to the present embodiment.
  • the processing procedure for generating test code will be described below with reference to Fig. 2.
  • the type information generation unit 101 first performs static analysis to find out what type of variables are created in the function that calls the function to be tested and what types are passed as arguments to the function to be tested, thereby narrowing down the types of variables passed to a certain number of functions and collecting type information (step S202).
  • the type information generating unit 101 When performing dynamic analysis on the source code to be tested (Yes in step S203), such as when simple static analysis alone is not sufficient to accurately narrow down the types for all cases, or when the source code to be tested is written in a dynamically typed language, the type information generating unit 101 performs a first instrumentation on the program to be tested so that the types of variables to be passed to the functions to be tested are output as an execution trace immediately before calling each function to be tested (step S204).
  • the object initialization function unit 102 also performs a second instrumentation on the program under test to output, as an execution trace, which methods of an object were called and in what order from when the object was created until when it was deleted, so that a method sequence for initializing each object can be collected (step S205).
  • step S206 inputs to the program are generated using test case generation techniques such as random generation, fuzzing, and symbolic execution.
  • the generated inputs are then passed to the program instrumented in steps S204 and S205, and the program is executed to obtain an execution trace as an intermediate product.
  • the execution trace is collected by generating test cases in steps S206 and S207 and executing the program to be tested with the generated test cases as input for a certain period of time.
  • the type information generation unit 101 obtains type information on the types of variables to be passed to the function under test from the execution trace (see, for example, Table 1) that describes the types of variables to be passed to the function under test (step S208).
  • the object initialization function generation unit 102 also collects a method sequence for initializing each object from an execution trace that records, in order, the type name of the called object, the object's identification information, and the called method name (step S209).
  • the object initialization function generation unit 102 generates a new method sequence using at least one of random generation, mutation, and use of a machine learning model (step S210).
  • step S210 among the newly generated method sequences, only those that can increase coverage more than the method sequence generated in step S209 may be kept, and the rest may be deleted.
  • the object initialization function generation unit 102 generates an object initialization function for each method sequence obtained in the preceding steps S209 and S210 (step S211).
  • the symbolic execution driver generation unit 103 generates a symbolic execution driver using the type information collected by the type information generation unit 101 through static and dynamic analysis of the source code (step S212). If there is a possibility that multiple types will be passed, the symbolic execution driver generation unit 103 generates a symbolic execution driver for each type separately. In addition, the symbolic execution driver generation unit 103 checks whether there is a function that can initialize the object among the object initialization functions generated by the object initialization function generation unit 102 as described above, and if such a function exists, it calls the function to initialize the object, and inserts code into the symbolic execution driver that initializes and symbolizes variables to be passed as arguments to the object initialization function.
  • the symbol execution unit 104 executes the symbol execution driver generated by the symbol execution driver generation unit 103 on the symbol execution engine to generate test cases (step S213).
  • the test code generation unit 105 generates test code for the function to be tested using the test cases generated by the symbol execution unit 105 as input values (step S214), and outputs this to the downstream test execution device, thereby terminating this process.
  • FIG. 3 shows an example of the hardware configuration of an information processing device 2000.
  • This information processing device 2000 includes a CPU (Central Processing Unit) 2001, a ROM (Read Only Memory) 2002, a RAM (Random Access Memory) 2003, a host bus 2004, a bridge 2005, an expansion bus 2006, an interface unit 2007, an input unit 2008, an output unit 2009, a storage unit 2010, a drive 2011, and a communication unit 2013.
  • a CPU Central Processing Unit
  • ROM Read Only Memory
  • RAM Random Access Memory
  • the CPU 2001 controls the overall operation of the information processing device 2000 in accordance with various programs.
  • the ROM 2002 stores in a non-volatile manner the programs (basic input/output system, etc.) and computational parameters used by the CPU 2001.
  • the RAM 2003 is used to load programs used in the execution of the CPU 2001, and to temporarily store parameters such as working data that change as appropriate during program execution.
  • Programs loaded into the RAM 2003 and executed by the CPU 2001 include, for example, various application programs and an operating system (OS).
  • OS operating system
  • the CPU 2001, ROM 2002, and RAM 2003 are interconnected by a host bus 2004 that is composed of a CPU bus and the like.
  • the CPU 2001 can execute various application programs in an execution environment provided by the OS through the cooperative operation of the ROM 2002 and RAM 2003, thereby realizing various functions and services.
  • the OS is, for example, Microsoft's Windows (registered trademark), Unix (registered trademark), or a successor OS to the OS.
  • the application programs also include an automatic test code generation tool, a test support program that uses the generated test code to support program testing, and the like.
  • the host bus 2004 is connected to the expansion bus 2006 via the bridge 2005.
  • the expansion bus 2006 is, for example, a PCI (Peripheral Component Interconnect) bus or PCI Express, and the bridge 2005 is based on the PCI standard.
  • PCI Peripheral Component Interconnect
  • the information processing device 2000 does not need to be configured such that the circuit components are separated by the host bus 2004, the bridge 2005, and the expansion bus 2006, and may be implemented such that almost all circuit components are interconnected by a single bus (not shown).
  • the interface unit 2007 connects peripheral devices such as an input unit 2008, an output unit 2009, a storage unit 2010, a drive 2011, and a communication unit 2013 in accordance with the standard of the expansion bus 2006.
  • peripheral devices such as an input unit 2008, an output unit 2009, a storage unit 2010, a drive 2011, and a communication unit 2013 in accordance with the standard of the expansion bus 2006.
  • the information processing device 2000 may further include peripheral devices not shown.
  • the peripheral devices may be built into the main body of the information processing device 2000, or some of the peripheral devices may be externally connected to the main body of the information processing device 2000.
  • the input unit 2008 is composed of an input control circuit that generates an input signal based on an input from a user and outputs it to the CPU 2001. If the information processing device 2000 is a personal computer, the input unit 2008 may include a keyboard, a mouse, a touch panel, and may also include a camera and a microphone.
  • the output unit 2009 includes display devices such as a liquid crystal display (LCD) device, an organic EL (Electro-Luminescence) display device, and an LED (Light Emitting Diode).
  • the storage unit 2010 stores files such as programs (applications, OS, etc.) executed by the CPU 2001 and various data.
  • the storage unit 2010 is configured with a large-capacity storage device such as an SSD (Solid State Drive) or HDD (Hard Disk Drive), but may also include an external storage device.
  • SSD Solid State Drive
  • HDD Hard Disk Drive
  • the removable storage medium 2012 is a storage medium configured in a cartridge format, such as a microSD card.
  • the drive 2011 performs read and write operations on the inserted removable storage medium 113.
  • the drive 2011 outputs data read from the removable storage medium 2012 to the RAM 2003 or the storage unit 2010, and writes data on the RAM 2003 or the storage unit 2010 to the removable storage medium 2012.
  • the communication unit 2013 is a device that performs wireless communication such as Wi-Fi (registered trademark), Bluetooth (registered trademark), and cellular communication networks such as 4G and 5G.
  • the communication unit 2013 may also have terminals such as a Universal Serial Bus (USB) and a High-Definition Multimedia Interface (HDMI (registered trademark)), and may further have a function of performing HDMI (registered trademark) communication with USB devices such as scanners and printers, displays, etc.
  • USB Universal Serial Bus
  • HDMI High-Definition Multimedia Interface
  • the information processing device 2000 can also operate as a test execution device that uses test code generated by the automatic test generation device 100 to test a test target program. Also, one information processing device 2000 can operate as both the automatic test generation device 100 and the test execution device.
  • the information processing device 2000 is configured using, for example, a PC, and operates as the automatic test generation device 100 and the test execution device by executing a specific computer program.
  • the present disclosure can be applied to an automatic test generation tool for programs whose source code is written in a variety of programming languages, including statically typed languages, dynamically typed languages, and object-oriented languages, to free users from burdensome and extremely cumbersome tasks such as interpreting the types of variables used in the source code and adding object initialization functions.
  • the series of processes described in this specification can be executed by hardware, software, or a combination of hardware and software.
  • a program recording the processing sequence related to the realization of this disclosure is installed in memory within a computer built into dedicated hardware and executed. It is also possible to install a program in a general-purpose computer capable of executing various processes and execute the processes related to the realization of this disclosure.
  • the program can be stored in advance in a recording medium installed in the computer, such as a HDD, SSD, or ROM.
  • a recording medium installed in the computer
  • the program can be temporarily or permanently stored in a removable recording medium, such as a flexible disk, a CD-ROM (Compact Disc Read Only Memory), an MO (Magneto optical) disk, a DVD (Digital Versatile Disc), a BD (Blu-Ray Disc (registered trademark)), a magnetic disk, or a USB (Universal Serial Bus) memory.
  • a program related to the realization of the present disclosure can be provided as so-called package software.
  • the program may also be transferred wirelessly or wired from a download site to a computer via a network such as a WAN (Wide Area Network) such as a cellular network, a LAN (Local Area Network), or the Internet.
  • a network such as a WAN (Wide Area Network) such as a cellular network, a LAN (Local Area Network), or the Internet.
  • the computer can receive the program transferred in this way and install it on a large-capacity storage device such as an HDD or SSD within the computer.
  • An information processing device comprising:
  • the analysis unit performs a static analysis of a program to be tested in a statically typed language, and investigates the types of variables created by a function that calls the function to be tested and the functions that pass the variables, thereby narrowing down the types of arguments to be passed to the function to be tested.
  • the analysis unit instruments a program to be tested in a dynamically typed language so as to output, as an execution trace, the types of variables to be passed to the function to be tested immediately before calling the function to be tested, passes an input to the instrumented program, executes the program, and collects an execution trace; and analyzes type information and objects of the variables to be passed to the function to be tested from the collected execution trace.
  • the information processing device according to any one of (1) or (2) above.
  • the analysis unit generates inputs to the program under test using at least one of random generation, fuzzing, and symbolic execution;
  • the information processing device according to (3) above.
  • the analysis unit uses a technique for efficiently searching to reach a specific line of a program to find an input that executes a function under test and obtains an execution trace.
  • the analysis unit performs instrumentation to output, as an execution trace, methods that are called from when an object is created until it is deleted and the order in which the methods are called, so that a method sequence for initializing each object can be collected, and generates an object initialization function by analyzing the execution trace.
  • the information processing device according to any one of (1) to (3) above.
  • the analysis unit instruments a test target program in an object-oriented language so as to output an object type name, object identification information, and the called method name as an execution trace immediately before invoking a method, passes an input to the instrumented program, executes the program, and collects an execution trace, extracts a method sequence for initializing the object from the collected execution trace, and generates an object initialization function from the extracted method sequence.
  • the information processing device according to (4) above.
  • the analysis unit extracts, from the execution trace, a method sequence indicating what methods were called and in what order for the object to be passed to the function under test from the time the object was generated until the function under test was called;
  • the information processing device according to (4) above.
  • the analysis unit further generates a new method sequence and adds the new method sequence to the method sequence extracted from the execution trace, thereby generating an object initialization function.
  • the analysis unit executes the test driver generated using the new method sequence to measure coverage, and keeps only the method sequence that covers lines that cannot be reached by the existing method sequence, and deletes the method sequence that does not cover the lines.
  • the information processing device according to (6) above.
  • the analysis unit randomly generates a new method sequence from among public methods of an object to be passed to a function under test.
  • the information processing device according to (6) above.
  • the analysis unit modifies a part of the method sequence extracted from the execution trace to generate a new method sequence.
  • the analysis unit modifies the method sequence extracted from the execution trace by adding a part of methods randomly selected from public methods of the object.
  • the analysis unit modifies the method sequence extracted from the execution trace by deleting some of the methods selected at random.
  • the information processing device according to (8) above.
  • the analysis unit replaces a randomly selected part of methods with another public method to modify the method sequence extracted from the execution trace.
  • the information processing device according to (8) above.
  • the analysis unit generates a sequence of methods that need to be executed before calling the function to be tested by using machine learning that learns, from the execution trace, which method of an object to be passed to the function to be tested is to be called.
  • the information processing device according to (6) above.
  • the analysis unit measures coverage by performing fuzzing or symbolic execution on the test driver generated using the new method sequence created by adding the changes, and leaves only the method sequence that covers lines that cannot be reached by the existing method sequence.
  • the information processing device according to any one of (8) to (12) above.
  • the symbolic execution driver generation unit initializes and symbolizes variables to be passed to the function under test, and generates a symbolic execution driver consisting of a code for simply calling the function under test. 14.
  • the information processing device according to claim 13,
  • the symbolic execution driver generation unit initializes and symbolizes variables with a type that may be passed to the function to be tested based on the collected type information, thereby generating a symbolic execution driver.
  • the symbol execution driver generation unit initializes the object by calling a function capable of initializing the object in the generated object initialization function, and inserts a code for initializing and symbolizing a variable to be passed as an argument of the object initialization function into the symbol execution driver.
  • the test code generation unit generates a test code for a function to be tested by executing the symbol execution driver generated by the symbol execution driver generation unit on a symbol execution engine and using the test case generated as an input value.
  • the information processing device is a
  • the test code generation unit generates test code using the object initialization function generated by the analysis unit, as necessary.
  • the information processing device according to (17) above.
  • an analysis unit that analyzes source code and generates type information and an object initialization function for the source code; a symbolic execution driver generator that generates a symbolic execution driver using the type information and an object initialization function; a symbolic execution unit that executes the symbolic execution driver generated by the symbolic execution driver generation unit to generate test cases; a test code generation unit that generates a test code for applying the test cases generated by the symbol execution unit to a program to be tested and executing the program;
  • 100 Automatic test generation device
  • 101 Type information generation unit
  • 102 Object initialization function generation unit
  • 103 Symbol execution driver generation unit
  • 104 Symbol execution unit

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

Provided is an information processing device that generates a test code having high coverage. This information processing device is equipped with: an analysis unit that analyzes a source code so as to collect type information for the source code and generate an object initialization function; a symbol execution driver generation unit that uses the type information and the object initialization function to generate a symbol execution driver; a symbol execution unit that executes the symbol execution driver generated by the symbol execution driver generation unit so as to generate a test case; and a test code generation unit that generates test code for feeding the test case generated by the symbol execution unit into a program to be tested and executing the same.

Description

情報処理装置及び情報処理方法、並びにコンピュータプログラムInformation processing device, information processing method, and computer program

 本明細書で開示する技術(以下、「本開示」とする)は、プログラム開発に関する処理を実施する情報処理装置及び情報処理方法、並びにコンピュータプログラムに関する。 The technology disclosed in this specification (hereinafter referred to as "this disclosure") relates to an information processing device and information processing method that perform processing related to program development, and a computer program.

 ソフトウェア開発において、仕様書と異なる、又は開発者が想定していないプログラムの動作は不具合であり、リリース前に修正してすべての不具合をなくす必要がある。プログラムの不具合を検出して動作を保証するために、テストが実施される。例えば、テストは、仕様書に記述され又は開発者が期待する入力と出力をテストケースとして作成して、プログラムが入力に対して正しい出力を返すかを確認することで実施される。入力に対して正しい出力が返されない、又は例外(故障)が発生してプログラムが動作しない場合には不具合と判断される。そして、開発者は、プログラムを解析して原因箇所を特定し、プログラムのロジックを修正する。プログラムの高品質及び高信頼性を担保するためには、高いカバレッジでテストを実行する必要がある。 In software development, program behavior that differs from the specifications or is not expected by the developer is a defect, and all defects must be corrected and eliminated before release. Testing is performed to detect program defects and ensure operation. For example, testing is performed by creating test cases with inputs and outputs described in the specifications or expected by the developer, and checking whether the program returns the correct output for the input. If the correct output is not returned for the input, or if an exception (fault) occurs and the program does not operate, it is determined to be a defect. The developer then analyzes the program to identify the cause and correct the program logic. To ensure high quality and reliability of the program, tests must be performed with high coverage.

特開2018-45325号公報JP 2018-45325 A

 本開示の目的は、高カバレッジなテストコードを生成するための処理を実施する情報処理装置及び情報処理方法、並びにコンピュータプログラムを提供することにある。 The objective of this disclosure is to provide an information processing device, an information processing method, and a computer program that perform processing to generate high-coverage test code.

 本開示は、上記課題を参酌してなされたものであり、その第1の側面は、
 ソースコードを解析して、ソースコードの型情報の収集及びオブジェクト初期化関数の生成を行う解析部と、
 前記型情報及びオブジェクト初期化関数を用いて記号実行ドライバを生成する記号実行ドライバ生成部と、
 前記記号実行ドライバ生成部が生成した記号実行ドライバを実行してテストケースを生成する記号実行部と、
 前記記号実行部が生成したテストケースをテスト対象のプログラムに与えて実行するためのテストコードを生成するテストコード生成部と、
を具備する情報処理装置である。
The present disclosure has been made in consideration of the above problems, and a first aspect thereof is:
an analysis unit that analyzes source code to collect type information of the source code and generate object initialization functions;
a symbolic execution driver generator that generates a symbolic execution driver using the type information and an object initialization function;
a symbolic execution unit that executes the symbolic execution driver generated by the symbolic execution driver generation unit to generate a test case;
a test code generation unit that generates a test code for applying the test cases generated by the symbol execution unit to a program under test and executing the program;
The information processing device includes:

 前記解析部は、静的型付け言語のテスト対象プログラムに対し静的解析を行い、テスト対象の関数を呼び出している関数で作る変数の型及び渡している関数を調査して、テスト対象の関数に渡される引数の型を絞り込む。 The analysis unit performs static analysis on the program to be tested, which is written in a statically typed language, and examines the types of variables created by the function that calls the function to be tested and the functions that pass them, thereby narrowing down the types of arguments to be passed to the function to be tested.

 また、前記解析部は、動的型付け言語のテスト対象プログラムに対して、テスト対象の関数を呼び出す直前に、テスト対象の関数に渡す変数の型を実行トレースとして出力するように計装を行い、計装したプログラムに入力を渡して実行して実行トレースを収集し、収集した実行トレースから、テスト対象の関数に渡されている変数の型情報及びオブジェクトを解析する。 The analysis unit also instruments the dynamically typed language program under test so that the types of variables passed to the function under test are output as an execution trace immediately before the function under test is called, passes input to the instrumented program, executes it, collects the execution trace, and analyzes the type information and objects of the variables passed to the function under test from the collected execution trace.

 また、前記解析部は、各オブジェクトを初期化するためのメソッド系列を収集できるように、オブジェクトが生成されてから削除されるまでの間に呼び出したメソッド及び呼び出した順序を実行トレースとして出力するように計装を行い、実行トレースを解析してオブジェクト初期化関数を生成する。 The analysis unit also performs instrumentation to output, as an execution trace, the methods that were called from when an object was created until it was deleted, and the order in which they were called, so that the method sequence for initializing each object can be collected, and analyzes the execution trace to generate an object initialization function.

 前記記号実行ドライバ生成部は、テスト対象の関数に渡す変数を初期化してシンボル化し、テスト対象の関数を呼び出すだけのコードからなる記号実行ドライバを生成する。 The symbolic execution driver generation unit initializes and symbolizes variables to be passed to the function to be tested, and generates a symbolic execution driver consisting of code that simply calls the function to be tested.

 前記テストコード生成部は、前記記号実行ドライバ生成部が生成した記号実行ドライバを記号実行エンジン上で実行して生成したテストケースを入力値としてテスト対象の関数に対するテストコードを生成する。 The test code generation unit executes the symbol execution driver generated by the symbol execution driver generation unit on a symbol execution engine, and generates test code for the function to be tested using the test cases generated as input values.

 また、本開示の第2の側面は、
 ソースコードを解析して、ソースコードの型情報及びオブジェクト初期化関数を生成する解析ステップと、
 前記型情報及びオブジェクト初期化関数を用いて記号実行ドライバを生成する記号実行ドライバ生成ステップと、
 前記記号実行ドライバ生成ステップにおいて生成した記号実行ドライバを実行してテストケースを生成する記号実行ステップと、
 前記記号実行ステップにおいて生成したテストケースをテスト対象のプログラムに与えて実行するためのテストコードを生成するテストコード生成ステップと、
を有する情報処理方法である。
In addition, a second aspect of the present disclosure is
an analysis step of analyzing the source code to generate type information and object initialization functions for the source code;
a symbolic execution driver generation step of generating a symbolic execution driver using the type information and an object initialization function;
a symbolic execution step of executing the symbolic execution driver generated in the symbolic execution driver generation step to generate a test case;
a test code generation step of generating test code for applying the test cases generated in the symbol execution step to a program under test and executing the program;
The information processing method includes the steps of:

 また、本開示の第3の側面は、
 ソースコードを解析して、ソースコードの型情報及びオブジェクト初期化関数を生成する解析部、
 前記型情報及びオブジェクト初期化関数を用いて記号実行ドライバを生成する記号実行ドライバ生成部、
 前記記号実行ドライバ生成部が生成した記号実行ドライバを実行してテストケースを生成する記号実行部、
 前記記号実行部が生成したテストケースをテスト対象のプログラムに与えて実行するためのテストコードを生成するテストコード生成部、
としてコンピュータを機能させるようにコンピュータ可読形式で記述されたコンピュータプログラムである。
In addition, a third aspect of the present disclosure is
an analysis unit that analyzes the source code and generates type information and object initialization functions for the source code;
a symbolic execution driver generator that generates a symbolic execution driver using the type information and an object initialization function;
a symbolic execution unit that executes the symbolic execution driver generated by the symbolic execution driver generation unit to generate test cases;
a test code generation unit that generates a test code for applying the test cases generated by the symbol execution unit to a program to be tested and executing the program;
It is a computer program written in a computer-readable form to cause a computer to function as a

 本開示の第3の側面に係るコンピュータプログラムは、コンピュータ上で所定の処理を実現するようにコンピュータ可読形式で記述されたコンピュータプログラムを定義したものである。コンピュータプログラムは、さまざまなプログラムコードを実行可能なコンピュータに対して、コンピュータ可読な形式で提供する記憶媒体、通信媒体、例えば、光ディスクや磁気ディスク、半導体メモリなどの記憶媒体、あるいは、ネットワークなどの通信媒体によって提供可能である。そして、本開示の第3の側面に係るコンピュータプログラムをいずれかの媒体経由でコンピュータにインストールすることによって、コンピュータ上では協働的作用が発揮され、本開示の第1の側面に係る情報処理装置と同様の作用効果を得ることができる。 The computer program according to the third aspect of the present disclosure defines a computer program written in a computer-readable format to realize a specified process on a computer. The computer program can be provided to a computer capable of executing various program codes in a computer-readable format via a storage medium or communication medium, such as an optical disk, magnetic disk, or semiconductor memory, or a communication medium such as a network. By installing the computer program according to the third aspect of the present disclosure on a computer via any of the media, a cooperative effect is exerted on the computer, and the same effect as that of the information processing device according to the first aspect of the present disclosure can be obtained.

 本開示によれば、プログラムのテストに際して、ソースコードを解析して引数の型情報及びオブジェクトの初期化関数を自動生成して、意味のあるテストケースを作成する情報処理装置及び情報処理方法、並びにコンピュータプログラムを提供することができる。 According to the present disclosure, it is possible to provide an information processing device, information processing method, and computer program that, when testing a program, analyzes source code and automatically generates argument type information and object initialization functions to create meaningful test cases.

 なお、本明細書に記載された効果は、あくまでも例示であり、本開示によりもたらされる効果はこれに限定されるものではない。また、本開示が、上記の効果以外に、さらに付加的な効果を奏する場合もある。 Note that the effects described in this specification are merely examples, and the effects brought about by this disclosure are not limited to these. Furthermore, this disclosure may have additional effects in addition to the effects described above.

 本開示のさらに他の目的、特徴や利点は、後述する実施形態や添付する図面に基づくより詳細な説明によって明らかになるであろう。 Further objects, features and advantages of the present disclosure will become apparent from the following detailed description based on the embodiments and the accompanying drawings.

図1は、本開示を適用したテスト自動生成装置100の機能的構成を示した図である。FIG. 1 is a diagram showing a functional configuration of an automatic test generation device 100 to which the present disclosure is applied. 図2は、ソースコードのテストコードを自動生成するための処理手順の一例を示したフローチャートである。FIG. 2 is a flowchart showing an example of a processing procedure for automatically generating test code for a source code. 図3は、情報処理装置2000のハードウェア構成例を示した図である。FIG. 3 is a diagram showing an example of the hardware configuration of the information processing device 2000.

 以下、図面を参照しながら本開示の実施形態について、以下の順に従って説明する。 The following describes the embodiments of the present disclosure with reference to the drawings in the following order:

A.概要
B.テスト自動生成ツールの構成
 B-1.型情報の生成
  B-1-1.静的解析
  B-1-2.動的解析
 B-2.オブジェクト初期化関数の生成
  B-2-1.動的解析
  B-2-2.新しいメソッド系列の生成
   B-2-2-1.ランダム生成
   B-2-2-2.ミューテーション
   B-2-2-3.機械学習の利用
   B-2-2-4.生成したメソッド系列の評価
  B-2-3.オブジェクト初期化関数の生成
 B-3.記号実行ドライバの生成
 B-4.記号実行及びテストコードの生成
C.テストコード生成処理手順
D.情報処理装置の構成
A. Overview B. Configuration of automatic test generation tool B-1. Generation of type information B-1-1. Static analysis B-1-2. Dynamic analysis B-2. Generation of object initialization functions B-2-1. Dynamic analysis B-2-2. Generation of new method sequences B-2-2-1. Random generation B-2-2-2. Mutation B-2-2-3. Use of machine learning B-2-2-4. Evaluation of generated method sequences B-2-3. Generation of object initialization functions B-3. Generation of symbolic execution driver B-4. Symbolic execution and test code generation C. Test code generation processing procedure D. Configuration of information processing device

A.概要
 C/C++などの静的型付け言語の場合、voidポインタのように曖昧な型表現を行うことができる。また、動的型付け言語の場合、関数に渡す引数の型を指定する必要がないため、どのような型の値やオブジェクトでも取り得る。実際にどのような型の変数が関数に渡されるかは、プログラムを実行してみないと正確には分からない。
A. Overview In statically typed languages such as C/C++, ambiguous type expressions such as void pointers can be used. In dynamically typed languages, there is no need to specify the type of arguments passed to functions, so values or objects of any type can be passed. The exact type of variable passed to a function cannot be known until the program is executed.

 高カバレッジの有効なテストコードを自動生成するには、voidポインタを使用している関数や動的型付け言語の関数の各々に対して、ユーザ(プログラムの開発者など)が型注釈を付与する必要がある。この注釈がない場合、voidポインタを使用する関数にはnullポインタが渡されるだけの、あまり意味のないテストやnullポインタ参照の例外を引き起こしてしまうようなテストが生成されてしまうか、プログラム内で使用されるすべての型を入力とするような厖大なテストケースが生成されてしまう。 To automatically generate effective test code with high coverage, the user (such as the program developer) must add type annotations to each function that uses a void pointer or each function in a dynamically typed language. Without these annotations, meaningless tests that simply pass a null pointer to a function that uses a void pointer, tests that cause null pointer dereference exceptions, or huge test cases that use all types used in the program as input will be generated.

 オブジェクト指向言語の場合、テスト対象のクラスのオブジェクトを適切に初期化したり、テスト対象の関数に渡すクラスのオブジェクトを適切に初期化したりしないと、テストするクラスや関数の処理が正しく実行されないことがある。例えば、linked list(双方向リスト)のクラスについて考えてみる。Linked listクラスには、add(要素の追加及び挿入)、size(要素数の取得)、get(要素に格納されているオブジェクトの取得)、set(要素の置き換え)、remove(要素の削除)などのメソッドが用意されている。このうちremoveメソッド(linked listからノードを1つ削除するメソッド)に対するテストを生成する場合、removeメソッドを実行する前に、addメソッドを実行してlinked listにノードを1つ追加し、linked listが空でない状態にしなければ、removeメソッドの中の、本来テストしたい処理(ノードを削除する処理)が実行されない。しかしながら、あるメソッドのテストを実行する前に、オブジェクトをどのように初期化すればよいのかは、プログラムを実際に実行して解析してみないと、正確には分からない。すなわち、オブジェクト指向言語の場合は、本来テストしたいふるまいが行われず、意味のないテストケースばかり生成されてしまう。このため、ユーザがオブジェクトの初期化に使用する関数を作成して、テストコード自動生成ツールに渡す必要がある。 In object-oriented languages, if the object of the class being tested or the object of the class being passed to the function being tested is not properly initialized, the processing of the class or function being tested may not be executed correctly. For example, consider the linked list (bidirectional list) class. The linked list class provides methods such as add (adding and inserting an element), size (getting the number of elements), get (getting the object stored in an element), set (replacing an element), and remove (deleting an element). When generating a test for the remove method (a method that deletes one node from the linked list), you must execute the add method to add one node to the linked list before executing the remove method, so that the linked list is not empty, otherwise the processing you actually want to test in the remove method (processing to delete a node) will not be executed. However, it is not possible to know exactly how to initialize an object before testing a method without actually running and analyzing the program. In other words, in the case of object-oriented languages, the behavior you actually want to test is not performed, and meaningless test cases are generated. For this reason, users need to create functions to be used for object initialization and pass them to the automatic test code generation tool.

 要するに、ユーザの設計意図を汲んだ、カバレッジの高い、意味のあるテストを自動生成するには、ユーザから型情報の注釈やオブジェクトの初期化関数を入力してもらう必要がある。しかしながら、テスト対象のすべての関数に対してユーザが型情報やオブジェクトの初期化関数を与えるのは、非常に煩雑な作業になり、ユーザにとって負担が大きい。 In short, to automatically generate meaningful tests with high coverage that reflect the user's design intent, it is necessary for the user to input type information annotations and object initialization functions. However, it is a very cumbersome task for the user to provide type information and object initialization functions for all functions to be tested, and it places a heavy burden on the user.

 例えば、動的型付け言語のテスト対象関数に対して、アノテーションを利用してドライバ及びスタブを自動生成しつつ、間違ったアノテーション(ソースコード内のコメント)が付与されている場合でも、正しいテストドライバ及びスタブを生成するテスト支援装置が提案されている(特許文献1を参照のこと)。ここで、テストドライバは、テスト対象関数及びクラスを呼び出して実行するためのプログラムである。また、スタブは、テスト対象関数及びクラスが呼び出す、ダミーの関数及びクラスである(ネットワークやデータベースなどにアクセスするため、テストを行うのが難しい関数やクラスの場合でもテストを行えるように、スタブを作る場合がある)。このテスト支援装置は、テスト対象の関数内で、テストケースとして与えたオブジェクトの未定義なメソッドが呼び出された場合に、そのエラーがなくなるようにドライバを修正することを繰り返し、最終的に正しいテストドライバを生成するものである。しかしながら、そもそもユーザがすべてのテスト対象の関数に対してアノテーションを付与することは、非常に煩雑な作業であり、ユーザにとって負担が大きい。 For example, a test support device has been proposed that uses annotations to automatically generate drivers and stubs for functions to be tested in a dynamic typed language, while generating correct test drivers and stubs even when incorrect annotations (comments in the source code) are added (see Patent Document 1). Here, a test driver is a program for calling and executing functions and classes to be tested. Also, a stub is a dummy function and class that is called by the functions and classes to be tested (stubs may be created so that tests can be performed even for functions and classes that are difficult to test because they access a network or database). This test support device repeatedly modifies the driver so that the error is eliminated when an undefined method of an object given as a test case is called in the function to be tested, and ultimately generates a correct test driver. However, it is a very cumbersome task for the user to add annotations to all functions to be tested, which places a heavy burden on the user.

 そこで、本開示では、ソースコードを解析することによって、型情報やオブジェクトの初期化関数を自動生成することによって、カバレッジの高いテストコードを自動生成する技術について提案する。本開示によれば、ユーザがソースコードの型情報やオブジェクトの初期化関数を与えなくても、ユーザの設計意図を汲んだ、カバレッジの高い、意味のあるテストコードを自動生成することができる。 In this disclosure, we propose a technology for automatically generating high-coverage test code by analyzing source code and automatically generating type information and object initialization functions. According to this disclosure, meaningful test code with high coverage that reflects the user's design intent can be automatically generated, even if the user does not provide type information for the source code or initialization functions for objects.

 本開示を適用したテストコード自動生成ツールによれば、ユーザからの型注釈やオブジェクト初期化関数の入力が不要である。また、本開示を適用したテストコード自動生成ツールによれば、voidポインタや動的型付け言語の関数の引数について、型を限定したテストコードを生成したり、オブジェクト初期化関数を使用したテストコードを生成したりすることができる。  An automatic test code generation tool to which the present disclosure is applied does not require the user to input type annotations or object initialization functions. In addition, an automatic test code generation tool to which the present disclosure is applied can generate test code with restricted types for void pointers and function arguments in dynamically typed languages, and can generate test code that uses object initialization functions.

 なお、本明細書中では、「テストコード」、「テストケース」、及び「カバレッジ」の各用語はそれぞれ以下の意味で使用されるものとする。 In this specification, the terms "test code," "test case," and "coverage" are used with the following meanings:

テストコード:さまざまなテストケースをプログラムに与えて実行するためのソースコードである。
テストケース:テスト対象のプログラムに与える入力である。
カバレッジ:本明細書中では「カバレッジ」はラインカバレッジを指す。ラインカバレッジは、ソースコードのどの行が実行できて、どの行が実行できていないかをパーセンテージで表した値である。
Test code: This is the source code for providing various test cases to the program and executing them.
Test case: An input given to the program under test.
Coverage: In this specification, "coverage" refers to line coverage, which is the percentage of which lines of source code are executable and which are not.

 「ソースコード」と「プログラム」は、いずれもコンピュータプログラムのことであるが、前者のソースコードはプログラミング言語など人間が理解及び記述し易いデータ形式のものを指し、後者のプログラムは実行可能形式にビルドされた形式のものを指す。また、「関数」と「メソッド」は同義であるが、オブジェクトに属する関数を「メソッド」と呼ぶ。 "Source code" and "program" both refer to computer programs, but the former refers to a data format that is easy for humans to understand and write, such as a programming language, while the latter program refers to a format that has been built into an executable format. Also, "function" and "method" are synonymous, but a function that belongs to an object is called a "method."

B.テスト自動生成ツールの構成
 図1には、本開示を適用したテスト自動生成装置100の機能的構成を模式的に示している。テスト自動生成装置100は、ソースコードを入力して、ソースコードにさまざまなテストケースを与えて実行するためのテストコードを出力する。後段のテスト実施装置(図示しない)では、テスト自動生成装置100が生成したテストコードを使って、高カバレッジなソースコードのテストを実施することができる。テスト自動生成装置100は、例えばパーソナルコンピュータ(PC)などの一般的な情報処理装置を用いて実現することができる。また、テスト自動生成装置100は、テスト実施装置と物理的に一体の装置であってもよい。
B. Configuration of the Automatic Test Generation Tool FIG. 1 shows a schematic functional configuration of an automatic test generation device 100 to which the present disclosure is applied. The automatic test generation device 100 inputs source code, and outputs test code for executing the source code by providing various test cases. A downstream test execution device (not shown) can execute a high-coverage test of the source code using the test code generated by the automatic test generation device 100. The automatic test generation device 100 can be realized using a general information processing device such as a personal computer (PC). The automatic test generation device 100 may also be a device that is physically integrated with the test execution device.

 図1に示すテスト自動生成装置100は、型情報生成部101と、オブジェクト初期化関数生成部102と、記号実行ドライバ生成部103と、記号実行部104と、テストコード生成部105を備えている。 The automatic test generation device 100 shown in FIG. 1 includes a type information generation unit 101, an object initialization function generation unit 102, a symbol execution driver generation unit 103, a symbol execution unit 104, and a test code generation unit 105.

 型情報生成部101は、テスト対象のソースコードを解析して、型情報を生成するように構成されている。同様に、オブジェクト初期化関数生成部102は、テスト対象のソースコードを解析して、オブジェクト初期化関数を生成するように構成されている。したがって、テスト自動生成装置100は、内部で型情報やオブジェクトの初期化関数を自動生成するので、ユーザがソースコードの型情報やオブジェクトの初期化関数を与えなくても、カバレッジの高い、意味のあるテストコードを自動生成することができる。 The type information generation unit 101 is configured to analyze the source code of the test target and generate type information. Similarly, the object initialization function generation unit 102 is configured to analyze the source code of the test target and generate an object initialization function. Therefore, since the automatic test generation device 100 automatically generates type information and object initialization functions internally, it is possible to automatically generate meaningful test code with high coverage even if the user does not provide type information of the source code or initialization functions of objects.

B-1.型情報の生成
 このB-1項では、高カバレッジで無駄の少ないテストを生成するために必要な型情報を、型情報生成部101がどのようにして生成するかについて説明する。
B-1. Generation of Type Information In this section B-1, we will explain how the type information generator 101 generates type information necessary for generating tests with high coverage and little waste.

B-1-1.静的解析
 テスト対象のソースコードが静的型付け言語で記述されている場合、型情報生成部101は、まず静的解析を行い、テスト対象の関数を呼び出している関数で、どのような型の変数を作成し、それを引数としてテスト対象の関数に渡しているかを調べることで、ある程度の関数に対して渡される変数の型を絞り込むことができる。
B-1-1. When the source code to be tested for static analysis is written in a statically typed language, the type information generating unit 101 first performs a static analysis to find out what type of variables are created in the function that calls the function to be tested and passed as arguments to the function to be tested, thereby narrowing down the types of variables to be passed to a certain number of functions.

 例えば、以下に示すコードからなる関数swapについて考えてみる。この関数swapは、引数にvoidポインタを取る。 For example, consider the function swap, which has the code shown below. This function swap takes a void pointer as an argument.

 voidポインタには任意の型が許容されるが、型情報生成部101は、上記のソースコード内でテスト対象の関数が呼び出されている行を参照して、そのテスト対象の関数の呼び出し元の関数がどのような型の変数を渡しているかを調べる。上記のソースコードの例では、型情報生成部101は、7行目を調べて関数functionによってテスト対象の関数swapが呼び出されていることが判明し、さらに5行目を調べて関数functionがテスト対象の関数swapに引き渡している変数x及びyの型を宣言していることが判明する。したがって、型情報生成部101は、テスト対象の関数swapに渡される型をint型に絞り込むことができる。 Any type is allowed for a void pointer, but the type information generation unit 101 refers to the line in the above source code where the function under test is called, and checks what type of variable is passed by the function that called the function under test. In the above source code example, the type information generation unit 101 checks line 7 and finds that the function under test swap is called by function function, and further checks line 5 and finds that function function declares the types of variables x and y that it passes to function swap under test. Therefore, the type information generation unit 101 can narrow down the type passed to function swap under test to type int.

B-1-2.動的解析
 上記B-1-1項で説明した単純な静的解析だけでは、すべてのケースに対して正確に型を絞り込むことはできない。また、テスト対象のソースコードが動的型付け言語で記述されている場合は、同一の変数にあらゆる型の値やオブジェクトを格納することができるため、実際にプログラムを動かさなければ、関数にどのような型の値やオブジェクトが渡されるのかを判別できない。そのような関数に対しては、このB-1-2項で示す動的解析を行うことで、型情報を収集する。
B-1-2. Dynamic AnalysisThe simple static analysis described in B-1-1 above is not enough to accurately narrow down the type for all cases. Also, if the source code to be tested is written in a dynamically typed language, any type of value or object can be stored in the same variable, so it is impossible to determine what type of value or object is passed to the function unless the program is actually run. For such functions, type information is collected by performing the dynamic analysis described in B-1-2.

 動的解析を行う場合、まず、型情報生成部101は、テスト対象のプログラムに対して、各テスト対象の関数を呼び出す直前に、テスト対象の関数に渡す変数の型を実行トレースとして出力するように、計装を行う。次いで、型情報生成部101は、計装したプログラムに入力を渡して実行する。このとき、型情報生成部101は、ランダム生成、Fuzzing、記号実行などのテストケース生成手法を用いて、プロクラムへの入力を生成することができる。Fuzzing及び記号実行を用いてプログラムへの入力を生成する場合、プログラムの特定の行に到達するように探索を効率的に行う手法があり、そのような手法を利用することで、テスト対象の関数を実行する入力を発見して、実行トレースを効率的に取得することができる。 When performing dynamic analysis, first, the type information generation unit 101 instruments the program under test so that the types of variables to be passed to the functions under test are output as an execution trace immediately before calling each function under test. Next, the type information generation unit 101 passes input to the instrumented program and executes it. At this time, the type information generation unit 101 can generate input to the program using test case generation techniques such as random generation, fuzzing, and symbolic execution. When generating input to a program using fuzzing and symbolic execution, there are techniques for efficiently searching to reach a specific line of the program, and by using such techniques, it is possible to find the input that executes the function under test and efficiently obtain an execution trace.

 そして、型情報生成部101は、このようなテストケースの生成と生成したテストケースを入力とするテスト対象のプログラムの実行を一定時間行うことで収集した実行トレースから、テスト対象の関数にどのような変数の型及びオブジェクトが渡されているのかを解析する。 Then, the type information generation unit 101 generates such test cases and executes the program to be tested using the generated test cases as input for a certain period of time, and from the execution trace collected, analyzes what types of variables and objects are being passed to the function to be tested.

 例えば、以下のようなコードからなる関数addがテスト対象の関数であるとする。このコードの4行目ではテスト対象関数addの引数x及びyにはint型が渡され、5行目では、テスト対象関数addの引数x及びyにはfloat型が渡されている。 For example, suppose the function to be tested is the function add, which consists of the following code. In the fourth line of this code, the arguments x and y of the function to be tested add are passed as int type, and in the fifth line, the arguments x and y of the function to be tested add are passed as float type.

 型情報生成部101は、上記のadd関数に対し、当該関数に渡す変数の型を実行トレースとして出力するように、計装を行い、且つ所定の手法で生成したテストケースを入力して実行することで、以下のような実行トレースを取得することができる。この実行トレースは、ソースコードの4行目に対応する、テスト対象関数addの引数x及びyにint型が渡されたトレース結果と、ソースコードの5行目に対応する、テスト対象関数addの引数x及びyにfloat型が渡されたトレース結果が含まれている。テスト自動生成ツールが中間生成物としてこのような実行トレースを出力することは、本開示の特徴の1つである。 The type information generation unit 101 performs instrumentation for the above add function so that the types of the variables passed to the function are output as an execution trace, and by inputting and executing a test case generated by a predetermined method, it is possible to obtain an execution trace such as the one shown below. This execution trace includes a trace result in which an int type is passed to the arguments x and y of the test target function add, which corresponds to the fourth line of the source code, and a trace result in which a float type is passed to the arguments x and y of the test target function add, which corresponds to the fifth line of the source code. One of the features of this disclosure is that an automatic test generation tool outputs such an execution trace as an intermediate product.

 したがって、型情報生成部101は、上記の実行トレースから、テスト対象の関数addの引数x及びyにはint型を渡す場合とfloat型を渡す場合があるという型情報を取得することができる。 Therefore, from the above execution trace, the type information generation unit 101 can obtain type information that the arguments x and y of the test target function add may be of type int or of float.

 後段の記号実行ドライバ生成部103は、型情報生成部101がソースコードに対する静的解析及び動的解析を通じて収集した型情報を使って、記号実行ドライバの生成を行う。但し、記号実行ドライバの生成の詳細については、後述のB-3項で説明する。 The symbolic execution driver generation unit 103 in the latter stage generates a symbolic execution driver using the type information collected by the type information generation unit 101 through static and dynamic analysis of the source code. However, details of the symbolic execution driver generation will be explained in Section B-3 below.

 なお、Fuzzingは、ランダムに生成した入力値や、ユーザから受け取った入力値に変更を加えて、新しい入力値を生成しながら、何度もプログラムを実行して、プログラムのふるまいをテストする手法である。Fuzzingには、プログラムのカバレッジを高めるように入力値の一部を変更する方法や、プログラムの特定の行に到達するように入力値の一部を変更する方法などがある。 Fuzzing is a technique for testing the behavior of a program by repeatedly running the program while modifying randomly generated input values or input values received from the user to generate new input values. Fuzzing can be done in two ways: by modifying part of the input values to increase the coverage of the program, or by modifying part of the input values to reach a specific line in the program.

 また、記号実行は、プログラムの入力に具体的な値を入れずに、記号値(シンボル)として扱い、プログラムのふるまいを網羅的に探索する手法である。プログラムの分岐の条件を集めながらプログラムを実行し、各実行パスの探索終了時に、それまで集めた分岐の条件を制約ソルバで解決することで、その実行パスを通るような入力値を生成することができる。 Symbolic execution is a method for comprehensively exploring the behavior of a program by treating the program inputs as symbolic values (symbols) rather than concrete values. The program is executed while collecting the program's branching conditions, and when the search for each execution path is finished, the branching conditions collected up to that point are solved using a constraint solver, making it possible to generate input values that will take that execution path.

B-2.オブジェクト初期化関数の生成
 このB-2項では、オブジェクト初期化関数生成部102が、オブジェクト指向言語のテスト対象のコードに対して、高カバレッジなテストを生成するために必要になる、オブジェクト初期化関数を自動生成する方法について説明する。
B-2. Generation of Object Initialization Functions This section B-2 describes a method for the object initialization function generator 102 to automatically generate object initialization functions that are required to generate high-coverage tests for code to be tested in an object-oriented language.

B-2-1.動的解析
 上記B-1-2項で説明したのと同様に、オブジェクト初期化関数生成部102は、テスト対象のプログラムに対して計装を行い、ランダム生成、Fuzzing、記号実行などのテストケース生成手法を用いて生成した入力値を計装したプログラムに入力して実行し、実行トレースを取得する。
B-2-1. Dynamic Analysis As explained in B-1-2 above, the object initialization function generation unit 102 instruments the program to be tested, inputs input values generated using test case generation techniques such as random generation, fuzzing, and symbolic execution to the instrumented program, executes the program, and obtains an execution trace.

 但し、オブジェクト初期化関数生成部102は、各オブジェクトを初期化するためのメソッド系列を収集できるように、あるオブジェクトが生成されてから削除されるまでの間にそのオブジェクトのどのメソッドをどんな順序で呼び出したかを実行トレースとして記録する。このため、オブジェクト初期化関数生成部102は、テスト対象のプログラムに対して、メソッドを呼び出す直前に、オブジェクトの型名、オブジェクトの識別情報、及び呼び出したメソッド名を実行トレースとして出力するように計装を行う。そして、オブジェクト初期化関数生成部102は、計装したプログラムに入力を渡して実行して実行トレースを収集し、収集した実行トレースからオブジェクトを初期化するためのメソッド系列を抽出し、抽出したメソッド系列からオブジェクト初期化関数を生成する。 However, the object initialization function generation unit 102 records, as an execution trace, which methods of an object were called and in what order from the time the object was created to the time it was deleted, so that it can collect the method sequence for initializing each object. For this reason, the object initialization function generation unit 102 instruments the program to be tested so that it outputs the object type name, object identification information, and the called method name as an execution trace immediately before calling a method. The object initialization function generation unit 102 then passes input to the instrumented program, executes it, collects the execution trace, extracts the method sequence for initializing the object from the collected execution trace, and generates an object initialization function from the extracted method sequence.

 一例として、以下のコードに対して実行トレースを収集する場合について説明する。このコード中、12行目でSampleClassクラスのオブジェクトs1が生成され、13行目でSampleClassクラスのオブジェクトs2が生成される。また、14行目、16行目、17行目、19行目でそれぞれオブジェクトs1のメソッドinit、setLocation、calc、finalizeが順に呼び出され、15行目、18行目、20行目でそれぞれオブジェクトs2のメソッドinit、calc、finalizeが順に呼び出される。オブジェクト初期化関数生成部102は、このコードに対して、オブジェクトの型名、オブジェクトの識別情報、及び呼び出したメソッド名を実行トレースとして出力するように、メソッドを呼び出す直前に計装を行う。 As an example, we will explain the case where an execution trace is collected for the following code. In this code, an object s1 of the SampleClass class is generated on line 12, and an object s2 of the SampleClass class is generated on line 13. Furthermore, the methods init, setLocation, calc, and finalize of object s1 are called in order on lines 14, 16, 17, and 19, respectively, and the methods init, calc, and finalize of object s2 are called in order on lines 15, 18, and 20, respectively. The object initialization function generation unit 102 performs instrumentation on this code just before calling a method so that the object type name, object identification information, and the name of the called method are output as an execution trace.

 オブジェクト初期化関数生成部102は、上記のコードに対して計装を行い、生成したテストケースを計装後のプログラムに入力して実行することにより、実行トレースとして、以下のようにオブジェクトの型名(Class)、オブジェクトの識別情報(id)、及び呼び出したメソッド名(function)を収集する。但し、オブジェクトの型名はSampleClassである。また、SampleClassから生成した各オブジェクトs1及びs2にそれぞれオブジェクトの識別情報として「1」及び「2」が自動的に割り振られたとする。 The object initialization function generation unit 102 instruments the above code, inputs the generated test cases into the instrumented program, and executes them to collect the object type name (Class), object identification information (id), and called method name (function) as an execution trace, as shown below. Note that the object type name is SampleClass. Also, let us assume that objects s1 and s2 generated from SampleClass are automatically assigned object identification information "1" and "2", respectively.

 オブジェクト初期化関数生成部102は、上記の実行トレースによって取得した情報から、テスト対象の関数に渡すオブジェクトが生成されてからテスト対象の関数が呼び出されるまでの間にそのオブジェクトに対してどのようなメソッドをどのような順序で呼び出したかを表したメソッド系列を抽出することができる。上記の実行トレースをオブジェクトの識別情報毎にまとめると、オブジェクト初期化関数生成部102は、1に対応するメソッド系列1と、オブジェクトs2に対応するメソッド系列2という、以下の2つのメソッド系列を得ることができる。 The object initialization function generation unit 102 can extract, from the information obtained by the above execution trace, a method sequence that indicates what methods were called and in what order for the object to be passed to the function under test from the time the object to be passed to the function under test was generated until the function under test was called. By summarizing the above execution trace for each object's identification information, the object initialization function generation unit 102 can obtain the following two method sequences: method sequence 1 corresponding to object s1 and method sequence 2 corresponding to object s2.

メソッド系列1:init→setLocation→calc→finalize 
メソッド系列2:init→calc→finalize
Method sequence 1: init → setLocation → calc → finalize
Method sequence 2: init → calc → finalize

 なお、このB-2-1項で説明するオブジェクト初期化関数生成部102が実行トレースを取得する処理は、上記B-1-2項で説明した型情報生成部101が行う処理とまとめて行うことができる。テスト自動生成ツールが中間生成物としてこのような実行トレースを出力することは、本開示の特徴の1つである(同上)。 Note that the process of acquiring the execution trace by the object initialization function generation unit 102 described in section B-2-1 can be performed together with the process performed by the type information generation unit 101 described in section B-1-2 above. One of the features of the present disclosure is that the automatic test generation tool outputs such an execution trace as an intermediate product (ibid.).

B-2-2.新しいメソッド系列の生成
 上記B-2-1項での実行トレースからの情報のみでは不十分な場合がある。このため、オブジェクト初期化関数生成部102は、このB-2-2項で説明する方法で新しいメソッド系列を生成し、それを加えてオブジェクト初期化関数の生成を行う。
B-2-2. Creation of a new method sequence There are cases where the information from the execution trace described in B-2-1 above is insufficient. For this reason, the object initialization function generation unit 102 creates a new method sequence using the method described in B-2-2, and adds it to create an object initialization function.

 メソッド系列を生成する方法として、ランダム生成、ミューテーション、及び機械学習を利用する方法の3通りが挙げられる。以下、各生成方法について説明する。 There are three ways to generate a method sequence: random generation, mutation, and machine learning. Each generation method is explained below.

B-2-2-1.ランダム生成
 この方法では、テスト対象の関数に渡すオブジェクトのpublicメソッドの中から、ランダムに系列を生成する。
B-2-2-1. Random Generation In this method, a sequence is randomly generated from among the public methods of the object passed to the function under test.

B-2-2-2.ミューテーション
 この方法では、上記B-2-1項で説明した動的解析により抽出したメソッド系列の一部に変更を加えて、新しいメソッド系列を生成する。メソッド系列の一部に変更を加える方法として、メソッドの追加、メソッドの削除、及びメソッドの変更の3通りが挙げられる。
B-2-2-2. Mutation In this method, a new method sequence is generated by modifying part of the method sequence extracted by the dynamic analysis described in B-2-1 above. There are three ways to modify part of the method sequence: adding a method, deleting a method, and modifying a method.

メソッドの追加:オブジェクトのpublicメソッドの中からランダムに1つを選択し、それをメソッド系列のランダムな位置に挿入する。
メソッドの削除:メソッド系列の中からランダムに1つを選択し、それを削除する。
メソッドの変更:メソッド系列の中からランダムに1つを選択し、それを別のpublicメソッドに置き換える。
Adding a Method: Randomly select one of the object's public methods and insert it at a random position in the method sequence.
Method deletion: Randomly select one method from the sequence and delete it.
Method modification: Randomly select one method from the set of methods and replace it with another public method.

B-2-2-3.機械学習の利用
 この方法では、上記B-2-1項で説明した動的解析で集めた実行トレースから、テスト対象の関数が呼び出されるまでの間に、テスト対象の関数に渡すオブジェクトのどのようなメソッドが呼ばれるかを学習する。例えば、命名規則などから、テスト対象の関数がremove**の場合、そのようなメソッドを呼び出す前にadd***やinit***、insert***などといった関数が呼ばれる傾向にあることを学習することで、テスト対象の関数が実行トレースに出現しない場合でも、そのテスト対象の関数を呼び出す前に実行する必要のあるメソッドの系列を生成することができる。
B-2-2-3. Use of Machine Learning In this method, the execution trace collected by the dynamic analysis described in B-2-1 above is used to learn what methods of the object passed to the test target function are called before the test target function is called. For example, by learning from naming conventions that when the test target function is remove**, functions such as add**, init**, and insert** tend to be called before calling such a method, even if the test target function does not appear in the execution trace, a sequence of methods that must be executed before calling the test target function can be generated.

B-2-2-4.生成したメソッド系列の評価
 オブジェクト初期化関数生成部102は、上述したようなランダム生成、ミューテーション、及び機械学習のうち少なくともいずれか1つの方法で変更を加えて生成された新しいメソッド系列を評価して、カバレッジに寄与しない無駄なメソッド系列は削除し、カバレッジを高めることができるメソッド系列だけを残すようにする。
B-2-2-4. Evaluation of generated method sequence The object initialization function generation unit 102 evaluates the new method sequence generated by modifying it using at least one of the above-mentioned random generation, mutation, and machine learning methods, deletes unnecessary method sequences that do not contribute to coverage, and leaves only method sequences that can increase coverage.

 具体的には、オブジェクト初期化関数生成部102は、新しく生成したメソッド系列を使ったテストドライバを生成し、そのテストドライバに対してfuzzing及び記号実行などを行い、カバレッジを測定する。既存のメソッド系列では到達できない行をカバーしているメソッド系列だけを残し、そうでない場合は削除する。オブジェクト初期化関数生成部102は、このような処理を一定時間繰り返すか、又はカバレッジが向上しなくなるまで繰り返す。 Specifically, the object initialization function generation unit 102 generates a test driver using the newly generated method sequence, and performs fuzzing and symbolic execution on the test driver to measure coverage. Only those method sequences that cover lines that cannot be reached by existing method sequences are retained, and those that do not are deleted. The object initialization function generation unit 102 repeats this process for a fixed period of time, or until coverage no longer improves.

 例えば、上記B-2-1項で例示したメソッド系列1:init→setLocation→calc→finalizeに対してメソッドの変更を行った場合について考えてみる。一例として、ミューテーション(メソッドの変更)によりメソッド系列1に含まれるメソッドsetLocationを別のメソッドfinalizeに変更して、以下に示すような新しいメソッド系列1´:init→finalize→calc→finalizeを生成することができる。 For example, consider the case where a method change is made to the method sequence 1: init → setLocation → calc → finalize shown in section B-2-1 above. As an example, a mutation (method change) can be used to change the method setLocation included in method sequence 1 to another method, finalize, to generate a new method sequence 1': init → finalize → calc → finalize as shown below.

メソッド系列1´:init→finalize→calc→finalize Method sequence 1': init → finalize → calc → finalize

 calcメソッドがテスト生成対象関数である場合、以下のようなテストドライバを生成し、このテストドライバに対してfuzzing及び記号実行などを行う。 If the calc method is a function for which tests are to be generated, a test driver like the one below is generated, and fuzzing and symbolic execution are performed on this test driver.

 このとき、calcのカバレッジを測定する。calcメソッドの未到達な行をカバーできる場合は、新しいメソッド系列1´がSampleClassのメソッド系列として追加される。他方、calcメソッドの未到達な行をカバーできない場合は、この新しいメソッド系列1´は削除され、今後新しいメソッド系列を作る際に、メソッド系列1´と同じになるような変更は行わないようにする。 At this time, the coverage of calc is measured. If the unreached lines of the calc method can be covered, new method sequence 1' is added as a method sequence of SampleClass. On the other hand, if the unreached lines of the calc method cannot be covered, this new method sequence 1' is deleted, and in the future, when creating a new method sequence, no changes will be made to make it the same as method sequence 1'.

B-2-3.オブジェクト初期化関数の生成
 オブジェクト初期化関数生成部102は、上記B-2-2項の説明に従って新しく生成したメソッド系列を使って、オブジェクトを初期化するオブジェクト初期化関数を生成する。上記のSampleClassの例におけるcalcメソッドがテスト生成対象の関数である場合、オブジェクト初期化関数生成部102は、上記B-2-2項で説明した通りに生成したそれぞれのメソッド系列に対してオブジェクト初期化関数を生成する。具体的には、オブジェクト初期化関数生成部102は、上記のメソッド系列1(init→setLocation→calc→finalize)に対して、以下のようなオブジェクト初期化関数を生成する。
B-2-3. Generation of Object Initialization Function The object initialization function generation unit 102 generates an object initialization function that initializes an object using a newly generated method sequence according to the explanation in B-2-2 above. When the calc method in the above SampleClass example is the function for which test generation is to be performed, the object initialization function generation unit 102 generates an object initialization function for each method sequence generated as explained in B-2-2 above. Specifically, the object initialization function generation unit 102 generates the following object initialization function for the above method sequence 1 (init→setLocation→calc→finalize):

 また、オブジェクト初期化関数生成部102は、上記のメソッド系列2(init→calc→finalize)に対して、以下のようなオブジェクト初期化関数を生成する。 In addition, the object initialization function generation unit 102 generates the following object initialization function for the above method sequence 2 (init→calc→finalize).

B-3.記号実行ドライバの生成
 記号実行ドライバ生成部103は、入力として受け取ったソースコードと、型情報生成部101が生成した型情報(上記B-1項を参照のこと)と、オブジェクト初期化関数生成部102が生成したオブジェクト初期化関数(上記B-2項を参照のこと)から、記号実行エンジン上で動かすコード、すなわち記号実行ドライバを生成する。
B-3. Generation of Symbol Execution Driver The symbol execution driver generation unit 103 generates code to be run on the symbol execution engine, i.e., a symbol execution driver, from the source code received as input, the type information generated by the type information generation unit 101 (see B-1 above), and the object initialization function generated by the object initialization function generation unit 102 (see B-2 above).

 記号実行ドライバは、テスト対象の関数に渡す変数を初期化してシンボル化し、テスト対象の関数を呼び出すだけのコードである。記号実行ドライバ生成部103は、記号実行ドライバを生成する際に、型情報生成部101が生成した型情報と、オブジェクト初期化関数生成部102が生成したオブジェクト初期化関数を使用する。テスト対象の関数がvoidポインタを引数として受け取る関数や、動的型付け言語の関数の場合には、記号実行ドライバ生成部103は、型情報生成部101が生成した型情報に基づいて、関数に渡される可能性のある型で変数を初期化する。複数の型が渡される可能性がある場合、記号実行ドライバ生成部103は、それぞれの型毎に個別に記号実行ドライバを生成する。 The symbolic execution driver is code that simply initializes and symbolizes variables to be passed to the function under test, and calls the function under test. When generating a symbolic execution driver, the symbolic execution driver generation unit 103 uses the type information generated by the type information generation unit 101 and the object initialization function generated by the object initialization function generation unit 102. If the function under test is a function that receives a void pointer as an argument, or is a function in a dynamically typed language, the symbolic execution driver generation unit 103 initializes variables with a type that may be passed to the function, based on the type information generated by the type information generation unit 101. If there is a possibility that multiple types may be passed, the symbolic execution driver generation unit 103 generates a symbolic execution driver separately for each type.

 上記B-1-2項で示したadd関数の例では、テスト対象の関数にはint型及びfloat型の変数が渡される可能性があるという型情報を、型情報生成部101から取得することができる。この場合、記号実行ドライバ生成部103は、int型及びfloat型の各々に対して個別に記号実行ドライバを生成する。すなわち、記号実行ドライバ生成部103は、引数としてint型を渡す、以下のような記号実行ドライバを生成する。 In the example of the add function shown in section B-1-2 above, type information indicating that variables of type int and type float may be passed to the function under test can be obtained from the type information generation unit 101. In this case, the symbol execution driver generation unit 103 generates a symbol execution driver for each of the int and float types separately. In other words, the symbol execution driver generation unit 103 generates a symbol execution driver such as the one below, which passes an int type as an argument.

 また、記号実行ドライバ生成部103は、引数としてfloat型を渡す、以下のような記号実行ドライバを生成する。 The symbol execution driver generation unit 103 also generates a symbol execution driver like the one below, which passes a float type as an argument.

 また、記号実行ドライバ生成部103は、テスト対象の関数の引数としてオブジェクトを渡す場合には、オブジェクト初期化関数生成部102が上記の通り生成したオブジェクト初期化関数の中にそのオブジェクトを初期化できる関数があるかどうかを確認する。そして、そのような関数が存在する存在する場合には、記号実行ドライバ生成部103は、その関数を呼び出してオブジェクトを初期化し、オブジェクト初期化関数の引数として渡す変数を初期化してシンボル化するコードを記号実行ドライバに挿入する。 In addition, when an object is passed as an argument to the function to be tested, the symbolic execution driver generation unit 103 checks whether or not there is a function that can initialize the object among the object initialization functions generated by the object initialization function generation unit 102 as described above. If such a function exists, the symbolic execution driver generation unit 103 calls the function to initialize the object, and inserts code into the symbolic execution driver that initializes and symbolizes variables passed as arguments to the object initialization function.

 上記のSampleClassの例の場合、記号実行ドライバ生成部103は、上記のメソッド系列1(init→setLocation→calc→finalize)のオブジェクト初期化関数に対して、例えば以下のようなコードを生成する。記号実行ドライバ生成部103は、オブジェクト初期化関数の引数として渡す変数を初期化してシンボル化するコードを記号実行ドライバに挿入する。 In the case of the above SampleClass example, the symbol execution driver generation unit 103 generates, for example, the following code for the object initialization function of the above method sequence 1 (init → setLocation → calc → finalize). The symbol execution driver generation unit 103 inserts into the symbol execution driver code that initializes and symbolizes variables passed as arguments to the object initialization function.

B-4.記号実行及びテストコードの生成
 記号実行部104は、記号実行ドライバ生成部103が生成した記号実行ドライバを記号実行エンジン上で実行して、テストケースを生成する。そして、テストコード生成部105は、記号実行部105が生成したテストケースを入力値として、テスト対象の関数に対するテストコードを生成する。
B-4. Symbolic Execution and Test Code Generation The symbolic execution unit 104 executes the symbolic execution driver generated by the symbolic execution driver generation unit 103 on the symbolic execution engine to generate test cases. Then, the test code generation unit 105 generates test code for the function to be tested using the test cases generated by the symbolic execution unit 105 as input values.

 このとき、必要であれば、テストコード生成部105は、オブジェクト初期化関数生成部102が生成したオブジェクト初期化関数を使用したテストコードを生成する。上記のSampleClassの例の場合、テストコード生成部105は、オブジェクト初期化関数生成部102が生成したオブジェクト初期化関数を使用して、以下のようなテストコードを生成する。 At this time, if necessary, the test code generation unit 105 generates test code using the object initialization function generated by the object initialization function generation unit 102. In the case of the above SampleClass example, the test code generation unit 105 generates test code such as the following using the object initialization function generated by the object initialization function generation unit 102.

C.テストコード生成処理手順
 図2には、本実施形態に係るテスト自動生成装置100において、ソースコードのテストコードを自動生成するための処理手順の一例をフローチャートの形式で示している。以下、図2を参照しながら、テストコードを生成するための処理手順について説明する。
C. Test Code Generation Processing Procedure Fig. 2 shows, in the form of a flowchart, an example of a processing procedure for automatically generating test code from source code in the automatic test generation device 100 according to the present embodiment. The processing procedure for generating test code will be described below with reference to Fig. 2.

 テスト対象のソースコードが静的型付け言語で記述されていて、テスト対象のソースコードに対して静的解析を行う場合(ステップS201のYes)、型情報生成部101は、まず静的解析を行い、テスト対象の関数を呼び出している関数で、どのような型の変数を作成し、それを引数としてテスト対象の関数に渡しているかを調べることで、ある程度の関数に対して渡される変数の型を絞り込んで、型情報を収集する(ステップS202)。 If the source code to be tested is written in a statically typed language and static analysis is to be performed on the source code to be tested (Yes in step S201), the type information generation unit 101 first performs static analysis to find out what type of variables are created in the function that calls the function to be tested and what types are passed as arguments to the function to be tested, thereby narrowing down the types of variables passed to a certain number of functions and collecting type information (step S202).

 単純な静的解析だけでは、すべてのケースに対して正確に型を絞り込むことはできない場合や、テスト対象のソースコードが動的型付け言語で記述されている場合など、テスト対象のソースコードに対して動的解析を行う場合(ステップS203のYes)、型情報生成部101は、テスト対象のプログラムに対して、各テスト対象の関数を呼び出す直前に、テスト対象の関数に渡す変数の型を実行トレースとして出力するように、第1の計装を行う(ステップS204)。 When performing dynamic analysis on the source code to be tested (Yes in step S203), such as when simple static analysis alone is not sufficient to accurately narrow down the types for all cases, or when the source code to be tested is written in a dynamically typed language, the type information generating unit 101 performs a first instrumentation on the program to be tested so that the types of variables to be passed to the functions to be tested are output as an execution trace immediately before calling each function to be tested (step S204).

 また、オブジェクト初期化関数部102は、各オブジェクトを初期化するためのメソッド系列を収集できるように、あるオブジェクトが生成されてから削除されるまでの間にそのオブジェクトのどのメソッドをどんな順序で呼び出したかを実行トレースとして出力するように、テスト対象のプログラムに対して第2の計装を行う(ステップS205)。 The object initialization function unit 102 also performs a second instrumentation on the program under test to output, as an execution trace, which methods of an object were called and in what order from when the object was created until when it was deleted, so that a method sequence for initializing each object can be collected (step S205).

 次いで、ランダム生成、Fuzzing、記号実行などのテストケース生成手法を用いてプロクラムへの入力を生成する(ステップS206)。そして、生成したステップS204及びS205で計装したプログラムに渡してプログラムを実行して、中間生成物として実行トレースを取得する。実際には、ステップS206及びS207におけるテストケースの生成と生成したテストケースを入力とするテスト対象のプログラムの実行を一定時間行うことで、実行トレースを収集する。 Next, inputs to the program are generated using test case generation techniques such as random generation, fuzzing, and symbolic execution (step S206). The generated inputs are then passed to the program instrumented in steps S204 and S205, and the program is executed to obtain an execution trace as an intermediate product. In practice, the execution trace is collected by generating test cases in steps S206 and S207 and executing the program to be tested with the generated test cases as input for a certain period of time.

 型情報生成部101は、テスト対象の関数に渡す変数の型を記述した実行トレース(例えば[表1]を参照のこと)から、テスト対象の関数に渡す変数の型に関する型情報を取得する(ステップS208)。 The type information generation unit 101 obtains type information on the types of variables to be passed to the function under test from the execution trace (see, for example, Table 1) that describes the types of variables to be passed to the function under test (step S208).

 また、オブジェクト初期化関数生成部102は、呼び出されたオブジェクトの型名、オブジェクトの識別情報、及び呼び出したメソッド名を順に記録した実行トレースから、各オブジェクトを初期化するためのメソッド系列を収集する。(ステップS209)。 The object initialization function generation unit 102 also collects a method sequence for initializing each object from an execution trace that records, in order, the type name of the called object, the object's identification information, and the called method name (step S209).

 さらに、オブジェクト初期化関数生成部102は、ランダム生成、ミューテーション、及び機械学習モデルの利用のうち少なくともいずれかの方法を用いて、新しいメソッド系列を生成する(ステップS210)。ステップS210では、新しく生成したメソッド系列のうち、ステップS209で生成したメソッド系列よりもカバレッジを高めることができるもののみを残し、それ以外は削除するようにしてもよい。 Furthermore, the object initialization function generation unit 102 generates a new method sequence using at least one of random generation, mutation, and use of a machine learning model (step S210). In step S210, among the newly generated method sequences, only those that can increase coverage more than the method sequence generated in step S209 may be kept, and the rest may be deleted.

 次いで、オブジェクト初期化関数生成部102は、先行ステップS209及びS210で取得したそれぞれのメソッド系列に対してオブジェクト初期化関数を生成する(ステップS211)。 Then, the object initialization function generation unit 102 generates an object initialization function for each method sequence obtained in the preceding steps S209 and S210 (step S211).

 次いで、記号実行ドライバ生成部103は、型情報生成部101がソースコードに対する静的解析及び動的解析を通じて収集した型情報を使って、記号実行ドライバの生成を行う(ステップS212)。複数の型が渡される可能性がある場合、記号実行ドライバ生成部103は、それぞれの型毎に個別に記号実行ドライバを生成する。また、記号実行ドライバ生成部103は、オブジェクト初期化関数生成部102が上記の通り生成したオブジェクト初期化関数の中にそのオブジェクトを初期化できる関数があるかどうかを確認し、そのような関数が存在する存在する場合には、その関数を呼び出してオブジェクトを初期化し、オブジェクト初期化関数の引数として渡す変数を初期化してシンボル化するコードを記号実行ドライバに挿入する。 Then, the symbolic execution driver generation unit 103 generates a symbolic execution driver using the type information collected by the type information generation unit 101 through static and dynamic analysis of the source code (step S212). If there is a possibility that multiple types will be passed, the symbolic execution driver generation unit 103 generates a symbolic execution driver for each type separately. In addition, the symbolic execution driver generation unit 103 checks whether there is a function that can initialize the object among the object initialization functions generated by the object initialization function generation unit 102 as described above, and if such a function exists, it calls the function to initialize the object, and inserts code into the symbolic execution driver that initializes and symbolizes variables to be passed as arguments to the object initialization function.

 次いで、記号実行部104は、記号実行ドライバ生成部103が生成した記号実行ドライバを記号実行エンジン上で実行して、テストケースを生成する(ステップS213)。 Then, the symbol execution unit 104 executes the symbol execution driver generated by the symbol execution driver generation unit 103 on the symbol execution engine to generate test cases (step S213).

 テストコード生成部105は、記号実行部105が生成したテストケースを入力値として、テスト対象の関数に対するテストコードを生成すると(ステップS214)、これを後段のテスト実施装置に出力して、本処理を終了する。 The test code generation unit 105 generates test code for the function to be tested using the test cases generated by the symbol execution unit 105 as input values (step S214), and outputs this to the downstream test execution device, thereby terminating this process.

D.情報処理装置の構成
 このD項では、テスト自動生成装置100として動作することができる情報処理装置のハードウェア構成について説明する。
D. Configuration of Information Processing Device In this section D, the hardware configuration of an information processing device that can operate as the automatic test generation device 100 will be described.

 図3には、情報処理装置2000のハードウェア構成例を示している。この情報処理装置2000は、CPU(Central Processing Unit)2001と、ROM(Read Only Memory)2002と、RAM(Random Access Memory)2003と、ホストバス2004と、ブリッジ2005と、拡張バス2006と、インターフェース部2007と、入力部2008と、出力部2009と、ストレージ部2010と、ドライブ2011と、通信部2013を含んでいる。 FIG. 3 shows an example of the hardware configuration of an information processing device 2000. This information processing device 2000 includes a CPU (Central Processing Unit) 2001, a ROM (Read Only Memory) 2002, a RAM (Random Access Memory) 2003, a host bus 2004, a bridge 2005, an expansion bus 2006, an interface unit 2007, an input unit 2008, an output unit 2009, a storage unit 2010, a drive 2011, and a communication unit 2013.

 CPU2001は、各種プログラムに従って情報処理装置2000の動作全般を制御する。ROM2002は、CPU2001が使用するプログラム(基本入出力システムなど)や演算パラメータを不揮発的に格納している。RAM2003は、CPU2001の実行において使用するプログラムをロードしたり、プログラム実行において適宜変化する作業データなどのパラメータを一時的に格納したりするのに使用される。RAM2003にロードしてCPU2001において実行するプログラムは、例えば各種アプリケーションプログラムやオペレーティングシステム(OS)などである。 The CPU 2001 controls the overall operation of the information processing device 2000 in accordance with various programs. The ROM 2002 stores in a non-volatile manner the programs (basic input/output system, etc.) and computational parameters used by the CPU 2001. The RAM 2003 is used to load programs used in the execution of the CPU 2001, and to temporarily store parameters such as working data that change as appropriate during program execution. Programs loaded into the RAM 2003 and executed by the CPU 2001 include, for example, various application programs and an operating system (OS).

 CPU2001とROM2002とRAM2003は、CPUバスなどから構成されるホストバス2004により相互に接続されている。そして、CPU2001は、ROM2002及びRAM2003の協働的な動作により、OSが提供する実行環境下で各種アプリケーションプログラムを実行して、さまざまな機能やサービスを実現することができる。情報処理装置2000がパーソナルコンピュータの場合、OSは例えば米マイクロソフト社のWindows(登録商標)や、Unix(登録商標)及びその後継OSである。また、アプリケーションプログラムには、テストコード自動生成ツールや、生成したテストコードを用いてプログラムのテストを支援するテスト支援プログラムなどが含まれるものとする。 The CPU 2001, ROM 2002, and RAM 2003 are interconnected by a host bus 2004 that is composed of a CPU bus and the like. The CPU 2001 can execute various application programs in an execution environment provided by the OS through the cooperative operation of the ROM 2002 and RAM 2003, thereby realizing various functions and services. If the information processing device 2000 is a personal computer, the OS is, for example, Microsoft's Windows (registered trademark), Unix (registered trademark), or a successor OS to the OS. The application programs also include an automatic test code generation tool, a test support program that uses the generated test code to support program testing, and the like.

 ホストバス2004は、ブリッジ2005を介して拡張バス2006に接続されている。拡張バス2006は、例えばPCI(Peripheral Component Interconnect)バス又はPCI Expressであり、ブリッジ2005はPCI規格に基づく。但し、情報処理装置2000がホストバス2004、ブリッジ2005及び拡張バス2006によって回路コンポーネントを分離される構成する必要はなく、単一のバス(図示しない)によってほぼすべての回路コンポーネントが相互接続される実装であってもよい。 The host bus 2004 is connected to the expansion bus 2006 via the bridge 2005. The expansion bus 2006 is, for example, a PCI (Peripheral Component Interconnect) bus or PCI Express, and the bridge 2005 is based on the PCI standard. However, the information processing device 2000 does not need to be configured such that the circuit components are separated by the host bus 2004, the bridge 2005, and the expansion bus 2006, and may be implemented such that almost all circuit components are interconnected by a single bus (not shown).

 インターフェース部2007は、拡張バス2006の規格に則って、入力部2008、出力部2009、ストレージ部2010、ドライブ2011、及び通信部2013といった周辺装置を接続する。但し、図3に示す周辺装置がすべて必須であるとは限らず、また図示しない周辺装置を情報処理装置2000がさらに含んでもよい。また、周辺装置は情報処理装置2000の本体に内蔵されていてもよいし、一部の周辺装置は情報処理装置2000本体に外付け接続されていてもよい。 The interface unit 2007 connects peripheral devices such as an input unit 2008, an output unit 2009, a storage unit 2010, a drive 2011, and a communication unit 2013 in accordance with the standard of the expansion bus 2006. However, not all of the peripheral devices shown in FIG. 3 are necessarily required, and the information processing device 2000 may further include peripheral devices not shown. Furthermore, the peripheral devices may be built into the main body of the information processing device 2000, or some of the peripheral devices may be externally connected to the main body of the information processing device 2000.

 入力部2008は、ユーザからの入力に基づいて入力信号を生成し、CPU2001に出力する入力制御回路などから構成される。情報処理装置2000がパーソナルコンピュータの場合、入力部2008は、キーボードやマウス、タッチパネルを含んでもよく、さらにカメラやマイクを含んでもよい。また、出力部2009は、例えば、液晶ディスプレイ(LCD)装置、有機EL(Electro-Luminescence)ディスプレイ装置、及びLED(Light Emitting Diode)などの表示装置を含む。 The input unit 2008 is composed of an input control circuit that generates an input signal based on an input from a user and outputs it to the CPU 2001. If the information processing device 2000 is a personal computer, the input unit 2008 may include a keyboard, a mouse, a touch panel, and may also include a camera and a microphone. The output unit 2009 includes display devices such as a liquid crystal display (LCD) device, an organic EL (Electro-Luminescence) display device, and an LED (Light Emitting Diode).

 ストレージ部2010は、CPU2001で実行されるプログラム(アプリケーション、OSなど)や各種データなどのファイルを格納する。ストレージ部2010は、例えば、SSD(Solid State Drive)やHDD(Hard Disk Drive)などの大容量記憶装置で構成されるが、外付けの記憶装置を含んでもよい。 The storage unit 2010 stores files such as programs (applications, OS, etc.) executed by the CPU 2001 and various data. The storage unit 2010 is configured with a large-capacity storage device such as an SSD (Solid State Drive) or HDD (Hard Disk Drive), but may also include an external storage device.

 リムーバブル記憶媒体2012は、例えばmicroSDカードのようなカートリッジ式で構成される記憶媒体である。ドライブ2011は、装填したリムーバブル記憶媒体113に対して読み出し及び書き込み動作を行う。ドライブ2011は、リムーバブル記録媒体2012から読み出したデータをRAM2003やストレージ部2010に出力したり、RAM2003やストレージ部2010上のデータをリムーバブル記録媒体2012に書き込んだりする。 The removable storage medium 2012 is a storage medium configured in a cartridge format, such as a microSD card. The drive 2011 performs read and write operations on the inserted removable storage medium 113. The drive 2011 outputs data read from the removable storage medium 2012 to the RAM 2003 or the storage unit 2010, and writes data on the RAM 2003 or the storage unit 2010 to the removable storage medium 2012.

 通信部2013は、Wi-Fi(登録商標)、Bluetooth(登録商標)や4Gや5Gなどのセルラー通信網などの無線通信を行うデバイスである。また、通信部2013は、USB(Universal Serial Bus)やHDMI(登録商標)(High-Definition Multimedia Interface)などの端子を備え、スキャナやプリンタなどのUSBデバイスやディスプレイなどとのHDMI(登録商標)通信を行う機能をさらに備えていてもよい。 The communication unit 2013 is a device that performs wireless communication such as Wi-Fi (registered trademark), Bluetooth (registered trademark), and cellular communication networks such as 4G and 5G. The communication unit 2013 may also have terminals such as a Universal Serial Bus (USB) and a High-Definition Multimedia Interface (HDMI (registered trademark)), and may further have a function of performing HDMI (registered trademark) communication with USB devices such as scanners and printers, displays, etc.

 情報処理装置2000は、テスト自動生成装置100が生成したテストコードを用いてテスト対象プログラムのテストを実施するテスト実施装置としても動作することができる。また、1台の情報処理装置2000が、テスト自動生成装置100及びテスト実施装置の両方として動作することもできる。情報処理装置2000は、例えばPCを用いて構成され、所定のコンピュータプログラムを実行することで、テスト自動生成装置100及びテスト実施装置として動作する。 The information processing device 2000 can also operate as a test execution device that uses test code generated by the automatic test generation device 100 to test a test target program. Also, one information processing device 2000 can operate as both the automatic test generation device 100 and the test execution device. The information processing device 2000 is configured using, for example, a PC, and operates as the automatic test generation device 100 and the test execution device by executing a specific computer program.

 以上、特定の実施形態を参照しながら、本開示について詳細に説明してきた。しかしながら、本開示は上述した実施形態に限定して解釈されるべきでなく、本開示の要旨を逸脱しない範囲で当業者が該実施形態の修正や代用を成し得ることは自明である。また、本明細書に記載した効果はあくまで例示であって、本開示がもたらす効果は限定されるものではなく、本明細書に記載されていない付加的な効果があってもよい。 The present disclosure has been described in detail above with reference to specific embodiments. However, the present disclosure should not be interpreted as being limited to the above-described embodiments, and it is self-evident that a person skilled in the art can modify or substitute the embodiments without departing from the gist of the present disclosure. Furthermore, the effects described in this specification are merely examples, and the effects brought about by the present disclosure are not limited, and there may be additional effects not described in this specification.

 本開示は、静的型付け言語、動的型付け言語、及びオブジェクト指向言語を含む、さまざまなプログラミング言語を用いて記述されたソースコードのプログラムを対象とするテスト自動生成ツールに適用して、ソースコードで使用される変数の型解釈やオブジェクト初期化関数の付与といった負担が大きく非常に煩雑な作業からユーザを解放することができる。 The present disclosure can be applied to an automatic test generation tool for programs whose source code is written in a variety of programming languages, including statically typed languages, dynamically typed languages, and object-oriented languages, to free users from burdensome and extremely cumbersome tasks such as interpreting the types of variables used in the source code and adding object initialization functions.

 要するに、本明細書では、例示という形態により本開示について説明してきたのであり、本明細書の記載内容を限定的に解釈するべきではない。本開示の要旨を判断するためには、特許請求の範囲を参酌すべきである。 In short, this specification has described the present disclosure in the form of examples, and the contents of this specification should not be interpreted in a restrictive manner. The claims should be taken into consideration in determining the gist of this disclosure.

 本明細書中において説明した一連の処理はハードウェア、ソフトウェア、又はハードウェアとソフトウェアを複合した構成によって実行することが可能である。ソフトウェアによる処理を実行する場合、本開示の実現に関わる処理シーケンスを記録したプログラムを、専用のハードウェアに組み込まれたコンピュータ内のメモリにインストールして実行させる。各種処理が実行可能な汎用的なコンピュータにプログラムをインストールして本開示の実現に関わる処理を実行させることも可能である。 The series of processes described in this specification can be executed by hardware, software, or a combination of hardware and software. When executing processes by software, a program recording the processing sequence related to the realization of this disclosure is installed in memory within a computer built into dedicated hardware and executed. It is also possible to install a program in a general-purpose computer capable of executing various processes and execute the processes related to the realization of this disclosure.

 プログラムは、例えば記録媒体としてのHDDやSSD、ROMなどのコンピュータ内に装備された記録媒体にあらかじめ格納しておくことができる。又は、プログラムを、フレキシブルディスク、CD-ROM(Compact Disc Read Only Memory)、MO(Magneto optical)ディスク,DVD(Digital Versatile Disc)、BD(Blu-Ray Disc(登録商標))、磁気ディスク、USB(Universal Serial Bus)メモリなどのリムーバブル記録媒体に、一時的又は永続的に格納しておくことができる。このようなリムーバブル記録媒体を用いて、いわゆるパッケージソフトウェアとして本開示の実現に関わるプログラムを提供することができる。 The program can be stored in advance in a recording medium installed in the computer, such as a HDD, SSD, or ROM. Alternatively, the program can be temporarily or permanently stored in a removable recording medium, such as a flexible disk, a CD-ROM (Compact Disc Read Only Memory), an MO (Magneto optical) disk, a DVD (Digital Versatile Disc), a BD (Blu-Ray Disc (registered trademark)), a magnetic disk, or a USB (Universal Serial Bus) memory. Using such removable recording media, a program related to the realization of the present disclosure can be provided as so-called package software.

 また、プログラムは、ダウンロードサイトからセルラーに代表されるWAN(Wide Area Network)、LAN(Local Area Network)、インターネットなどのネットワークを介して、コンピュータに無線又は有線で転送してもよい。コンピュータでは、そのようにして転送されてくるプログラムを受信し、コンピュータ内のHDDやSSDなどの大容量記憶装置にインストールすることができる。 The program may also be transferred wirelessly or wired from a download site to a computer via a network such as a WAN (Wide Area Network) such as a cellular network, a LAN (Local Area Network), or the Internet. The computer can receive the program transferred in this way and install it on a large-capacity storage device such as an HDD or SSD within the computer.

 なお、本開示は、以下のような構成をとることも可能である。 In addition, this disclosure can also be configured as follows:

(1)ソースコードを解析して、ソースコードの型情報の収集及びオブジェクト初期化関数の生成を行う解析部と、
 前記型情報及びオブジェクト初期化関数を用いて記号実行ドライバを生成する記号実行ドライバ生成部と、
 前記記号実行ドライバ生成部が生成した記号実行ドライバを実行してテストケースを生成する記号実行部と、
 前記記号実行部が生成したテストケースをテスト対象のプログラムに与えて実行するためのテストコードを生成するテストコード生成部と、
を具備する情報処理装置。
(1) an analysis unit that analyzes source code to collect type information of the source code and generate object initialization functions;
a symbolic execution driver generator that generates a symbolic execution driver using the type information and an object initialization function;
a symbolic execution unit that executes the symbolic execution driver generated by the symbolic execution driver generation unit to generate a test case;
a test code generation unit that generates a test code for applying the test cases generated by the symbol execution unit to a program under test and executing the program;
An information processing device comprising:

(2)前記解析部は、静的型付け言語のテスト対象プログラムに対し静的解析を行い、テスト対象の関数を呼び出している関数で作る変数の型及び渡している関数を調査して、テスト対象の関数に渡される引数の型を絞り込む、
上記(1)に記載の情報処理装置。
(2) The analysis unit performs a static analysis of a program to be tested in a statically typed language, and investigates the types of variables created by a function that calls the function to be tested and the functions that pass the variables, thereby narrowing down the types of arguments to be passed to the function to be tested.
The information processing device according to (1) above.

(3)前記解析部は、動的型付け言語のテスト対象プログラムに対して、テスト対象の関数を呼び出す直前に、テスト対象の関数に渡す変数の型を実行トレースとして出力するように計装を行い、計装したプログラムに入力を渡して実行して実行トレースを収集し、収集した実行トレースから、テスト対象の関数に渡されている変数の型情報及びオブジェクトを解析する、
上記(1)又は(2)のいずれか1つに記載の情報処理装置。
(3) The analysis unit instruments a program to be tested in a dynamically typed language so as to output, as an execution trace, the types of variables to be passed to the function to be tested immediately before calling the function to be tested, passes an input to the instrumented program, executes the program, and collects an execution trace; and analyzes type information and objects of the variables to be passed to the function to be tested from the collected execution trace.
The information processing device according to any one of (1) or (2) above.

(3-1)前記解析部は、ランダム生成、fuzzing、及び記号実行のうち少なくとも1つを用いて、テスト対象プログラムへの入力を生成する、
上記(3)に記載の情報処理装置。
(3-1) the analysis unit generates inputs to the program under test using at least one of random generation, fuzzing, and symbolic execution;
The information processing device according to (3) above.

(3-2)前記解析部は、fuzzing及び記号実行のうち少なくとも一方を用いる場合、プログラムの特定の行に到達するように探索を効率的に行う手法を利用して、テスト対象の関数を実行する入力を発見して、実行トレースを取得する、
上記(3-1)に記載の情報処理装置。
(3-2) When using at least one of fuzzing and symbolic execution, the analysis unit uses a technique for efficiently searching to reach a specific line of a program to find an input that executes a function under test and obtains an execution trace.
The information processing device according to (3-1) above.

(4)前記解析部は、各オブジェクトを初期化するためのメソッド系列を収集できるように、オブジェクトが生成されてから削除されるまでの間に呼び出したメソッド及び呼び出した順序を実行トレースとして出力するように計装を行い、実行トレースを解析してオブジェクト初期化関数を生成する、
上記(1)乃至(3)のいずれか1つに記載の情報処理装置。
(4) The analysis unit performs instrumentation to output, as an execution trace, methods that are called from when an object is created until it is deleted and the order in which the methods are called, so that a method sequence for initializing each object can be collected, and generates an object initialization function by analyzing the execution trace.
The information processing device according to any one of (1) to (3) above.

(4-1)前記解析部は、オブジェクト指向言語のテスト対象プログラムに対して、メソッドを呼び出す直前に、オブジェクトの型名、オブジェクトの識別情報、及び呼び出したメソッド名を実行トレースとして出力するように計装を行い、計装したプログラムに入力を渡して実行して実行トレースを収集し、収集した実行トレースからオブジェクトを初期化するためのメソッド系列を抽出し、抽出したメソッド系列からオブジェクト初期化関数を生成する、
上記(4)に記載の情報処理装置。
(4-1) The analysis unit instruments a test target program in an object-oriented language so as to output an object type name, object identification information, and the called method name as an execution trace immediately before invoking a method, passes an input to the instrumented program, executes the program, and collects an execution trace, extracts a method sequence for initializing the object from the collected execution trace, and generates an object initialization function from the extracted method sequence.
The information processing device according to (4) above.

(4-2)前記解析部は、実行トレースから、テスト対象の関数に渡すオブジェクトが生成されてから、テスト対象の関数が呼び出されるまでの間に、そのオブジェクトに対してどのようなメソッドをどのような順序で呼び出したかを表したメソッド系列を抽出する、
上記(4)に記載の情報処理装置。
(4-2) The analysis unit extracts, from the execution trace, a method sequence indicating what methods were called and in what order for the object to be passed to the function under test from the time the object was generated until the function under test was called;
The information processing device according to (4) above.

(5)ランダム生成、Fuzzing、及び記号実行のうち少なくともいずれ1つの手法を用いて前記計装したプログラムに対する入力を生成する、
上記(3)又は(4)のいずれか1つに記載の情報処理装置。
(5) generating inputs for the instrumented program using at least one of the following techniques: random generation, fuzzing, and symbolic execution;
The information processing device according to any one of (3) and (4) above.

(6)前記解析部は、さらに新しいメソッド系列を生成して、前記実行トレースから抽出したメソッド系列に加えて、オブジェクト初期化関数の生成を行う、
上記(4)に記載の情報処理装置。
(6) The analysis unit further generates a new method sequence and adds the new method sequence to the method sequence extracted from the execution trace, thereby generating an object initialization function.
The information processing device according to (4) above.

(6-1)前記解析部は、新しいメソッド系列を使って生成したテストドライバを実行してカバレッジを測定し、既存のメソッド系列では到達できない行をカバーしているメソッド系列だけを残し、そうでない場合は削除する、
上記(6)に記載の情報処理装置。
(6-1) The analysis unit executes the test driver generated using the new method sequence to measure coverage, and keeps only the method sequence that covers lines that cannot be reached by the existing method sequence, and deletes the method sequence that does not cover the lines.
The information processing device according to (6) above.

(7)前記解析部は、テスト対象の関数に渡すオブジェクトのpublicメソッドの中からランダムに新しいメソッド系列を生成する、
上記(6)に記載の情報処理装置。
(7) The analysis unit randomly generates a new method sequence from among public methods of an object to be passed to a function under test.
The information processing device according to (6) above.

(8)前記解析部は、前記実行トレースから抽出したメソッド系列の一部に変更を加えて、新しいメソッド系列を生成する、
上記(6)に記載の情報処理装置。
(8) The analysis unit modifies a part of the method sequence extracted from the execution trace to generate a new method sequence.
The information processing device according to (6) above.

(9)前記解析部は、オブジェクトのpublicメソッドの中からランダムに選択した一部のメソッドを追加して、前記実行トレースから抽出したメソッド系列を変更する、
上記(8)に記載の情報処理装置。
(9) The analysis unit modifies the method sequence extracted from the execution trace by adding a part of methods randomly selected from public methods of the object.
The information processing device according to (8) above.

(10)前記解析部は、ランダムに選択した一部のメソッドを削除して、前記実行トレースから抽出したメソッド系列を変更する、
上記(8)に記載の情報処理装置。
(10) The analysis unit modifies the method sequence extracted from the execution trace by deleting some of the methods selected at random.
The information processing device according to (8) above.

(11)前記解析部は、ランダムに選択した一部のメソッドを別のpublicメソッドに置き換えて、前記実行トレースから抽出したメソッド系列を変更する、
上記(8)に記載の情報処理装置。
(11) The analysis unit replaces a randomly selected part of methods with another public method to modify the method sequence extracted from the execution trace.
The information processing device according to (8) above.

(12)前記解析部は、前記実行トレースから、テスト対象の関数に渡すオブジェクトのどのメソッドが呼ばれるかを学習した機械学習を利用して、テスト対象の関数を呼び出す前に実行する必要のあるメソッドの系列を生成する、
上記(6)に記載の情報処理装置。
(12) The analysis unit generates a sequence of methods that need to be executed before calling the function to be tested by using machine learning that learns, from the execution trace, which method of an object to be passed to the function to be tested is to be called.
The information processing device according to (6) above.

(13)前記解析部は、前記変更を加えて作った新しいメソッド系列を使って生成したテストドライバに対してFuzzing又は記号実行を行ってカバレッジを測定し、既存のメソッド系列では到達できない行をカバーするメソッド系列だけを残す、
上記(8)乃至(12)のいずれか1つに記載の情報処理装置。
(13) The analysis unit measures coverage by performing fuzzing or symbolic execution on the test driver generated using the new method sequence created by adding the changes, and leaves only the method sequence that covers lines that cannot be reached by the existing method sequence.
The information processing device according to any one of (8) to (12) above.

(14)前記記号実行ドライバ生成部は、テスト対象の関数に渡す変数を初期化してシンボル化し、テスト対象の関数を呼び出すだけのコードからなる記号実行ドライバを生成する、
上記(1)乃至(13)のいずれか1つに記載の情報処理装置。
(14) The symbolic execution driver generation unit initializes and symbolizes variables to be passed to the function under test, and generates a symbolic execution driver consisting of a code for simply calling the function under test.
14. The information processing device according to claim 13,

(15)前記記号実行ドライバ生成部は、voidポインタを引数として受け取る関数及び動的型付け言語の関数の場合に、収集した型情報に基づいて、テスト対象の関数に渡される可能性のある型で変数を初期化及びシンボル化して、記号実行ドライバを生成する、
上記(14)に記載の情報処理装置。
(15) In the case of a function that receives a void pointer as an argument and a function of a dynamically typed language, the symbolic execution driver generation unit initializes and symbolizes variables with a type that may be passed to the function to be tested based on the collected type information, thereby generating a symbolic execution driver.
The information processing device according to (14) above.

(16)前記記号実行ドライバ生成部は、テスト対象の関数の引数としてオブジェクトを渡す場合、生成したオブジェクト初期化関数の中にそのオブジェクトを初期化できる関数を呼び出してオブジェクトを初期化し、オブジェクト初期化関数の引数として渡す変数を初期化してシンボル化するコードを記号実行ドライバに挿入する、
上記(14)に記載の情報処理装置。
(16) When an object is passed as an argument of a function to be tested, the symbol execution driver generation unit initializes the object by calling a function capable of initializing the object in the generated object initialization function, and inserts a code for initializing and symbolizing a variable to be passed as an argument of the object initialization function into the symbol execution driver.
The information processing device according to (14) above.

(17)前記テストコード生成部は、前記記号実行ドライバ生成部が生成した記号実行ドライバを記号実行エンジン上で実行して生成したテストケースを入力値としてテスト対象の関数に対するテストコードを生成する、
上記(1)乃至(16)のいずれか1つに記載の情報処理装置。
(17) The test code generation unit generates a test code for a function to be tested by executing the symbol execution driver generated by the symbol execution driver generation unit on a symbol execution engine and using the test case generated as an input value.
17. The information processing device according to claim 15, wherein the information processing device is a

(17-1)前記テストコード生成部は、必要に応じて、前記解析部が生成したオブジェクト初期化関数を使用したテストコードを生成する、
上記(17)に記載の情報処理装置。
(17-1) The test code generation unit generates test code using the object initialization function generated by the analysis unit, as necessary.
The information processing device according to (17) above.

(18)ソースコードを解析して、ソースコードの型情報及びオブジェクト初期化関数を生成する解析ステップと、
 前記型情報及びオブジェクト初期化関数を用いて記号実行ドライバを生成する記号実行ドライバ生成ステップと、
 前記記号実行ドライバ生成ステップにおいて生成した記号実行ドライバを実行してテストケースを生成する記号実行ステップと、
 前記記号実行ステップにおいて生成したテストケースをテスト対象のプログラムに与えて実行するためのテストコードを生成するテストコード生成ステップと、
を有する情報処理方法。
(18) an analysis step of analyzing the source code to generate type information and an object initialization function for the source code;
a symbolic execution driver generation step of generating a symbolic execution driver using the type information and an object initialization function;
a symbolic execution step of executing the symbolic execution driver generated in the symbolic execution driver generation step to generate a test case;
a test code generation step of generating test code for applying the test cases generated in the symbol execution step to a program under test and executing the program;
An information processing method comprising the steps of:

(19)ソースコードを解析して、ソースコードの型情報及びオブジェクト初期化関数を生成する解析部、
 前記型情報及びオブジェクト初期化関数を用いて記号実行ドライバを生成する記号実行ドライバ生成部、
 前記記号実行ドライバ生成部が生成した記号実行ドライバを実行してテストケースを生成する記号実行部、
 前記記号実行部が生成したテストケースをテスト対象のプログラムに与えて実行するためのテストコードを生成するテストコード生成部、
としてコンピュータを機能させるようにコンピュータ可読形式で記述されたコンピュータプログラム。
(19) an analysis unit that analyzes source code and generates type information and an object initialization function for the source code;
a symbolic execution driver generator that generates a symbolic execution driver using the type information and an object initialization function;
a symbolic execution unit that executes the symbolic execution driver generated by the symbolic execution driver generation unit to generate test cases;
a test code generation unit that generates a test code for applying the test cases generated by the symbol execution unit to a program to be tested and executing the program;
A computer program written in a computer-readable form to cause a computer to function as a

 100…テスト自動生成装置、101…型情報生成部
 102…オブジェクト初期化関数生成部
 103…記号実行ドライバ生成部、104…記号実行部
 105…テストコード生成部
 2000…情報処理装置、2001…CPU、2002…ROM
 2003…RAM、2004…ホストバス、2005…ブリッジ
 2006…拡張バス、2007…インターフェース部
 2008…入力部、2009…出力部、2010…ストレージ部
 2011…ドライブ、2012…リムーバブル記録媒体
 2013…通信部
100: Automatic test generation device, 101: Type information generation unit, 102: Object initialization function generation unit, 103: Symbol execution driver generation unit, 104: Symbol execution unit, 105: Test code generation unit, 2000: Information processing device, 2001: CPU, 2002: ROM
2003: RAM, 2004: host bus, 2005: bridge, 2006: expansion bus, 2007: interface section, 2008: input section, 2009: output section, 2010: storage section, 2011: drive, 2012: removable recording medium, 2013: communication section

Claims (19)

 ソースコードを解析して、ソースコードの型情報の収集及びオブジェクト初期化関数の生成を行う解析部と、
 前記型情報及びオブジェクト初期化関数を用いて記号実行ドライバを生成する記号実行ドライバ生成部と、
 前記記号実行ドライバ生成部が生成した記号実行ドライバを実行してテストケースを生成する記号実行部と、
 前記記号実行部が生成したテストケースをテスト対象のプログラムに与えて実行するためのテストコードを生成するテストコード生成部と、
を具備する情報処理装置。
an analysis unit that analyzes source code to collect type information of the source code and generate object initialization functions;
a symbolic execution driver generator that generates a symbolic execution driver using the type information and an object initialization function;
a symbolic execution unit that executes the symbolic execution driver generated by the symbolic execution driver generation unit to generate a test case;
a test code generation unit that generates a test code for applying the test cases generated by the symbol execution unit to a program under test and executing the program;
An information processing device comprising:
 前記解析部は、静的型付け言語のテスト対象プログラムに対し静的解析を行い、テスト対象の関数を呼び出している関数で作る変数の型及び渡している関数を調査して、テスト対象の関数に渡される引数の型を絞り込む、
請求項1に記載の情報処理装置。
The analysis unit performs a static analysis on a program to be tested in a statically typed language, and investigates the types of variables created by a function calling the function to be tested and the functions to be passed to the function, thereby narrowing down the types of arguments to be passed to the function to be tested.
The information processing device according to claim 1 .
 前記解析部は、テスト対象プログラムに対して、テスト対象の関数を呼び出す直前に、テスト対象の関数に渡す変数の型を実行トレースとして出力するように計装を行い、計装したプログラムに入力を渡して実行して実行トレースを収集し、収集した実行トレースから、テスト対象の関数に渡されている変数の型情報及びオブジェクトを解析する、
請求項1に記載の情報処理装置。
The analysis unit instruments the program under test so as to output, as an execution trace, the types of variables to be passed to the function under test immediately before calling the function under test, passes an input to the instrumented program, executes the program, and collects the execution trace, and analyzes type information and objects of the variables passed to the function under test from the collected execution trace.
The information processing device according to claim 1 .
 前記解析部は、各オブジェクトを初期化するためのメソッド系列を収集できるように、オブジェクトが生成されてから削除されるまでの間に呼び出したメソッド及び呼び出した順序を実行トレースとして出力するように計装を行い、実行トレースを解析してオブジェクト初期化関数を生成する、
請求項1に記載の情報処理装置。
the analysis unit performs instrumentation so as to output, as an execution trace, methods that have been called from the time an object is created until the time it is deleted and the order in which the methods have been called, so that a method sequence for initializing each object can be collected, and generates an object initialization function by analyzing the execution trace;
The information processing device according to claim 1 .
 ランダム生成、Fuzzing、及び記号実行のうち少なくともいずれ1つの手法を用いて前記計装したプログラムに対する入力を生成する、
請求項3に記載の情報処理装置。
generating inputs for the instrumented program using at least one of the following techniques: random generation, fuzzing, and symbolic execution;
The information processing device according to claim 3 .
 前記解析部は、さらに新しいメソッド系列を生成して、前記実行トレースから抽出したメソッド系列に加えて、オブジェクト初期化関数の生成を行う、
請求項4に記載の情報処理装置。
the analysis unit further generates a new method sequence and adds the new method sequence to the method sequence extracted from the execution trace, thereby generating an object initialization function.
The information processing device according to claim 4.
 前記解析部は、テスト対象の関数に渡すオブジェクトのpublicメソッドの中からランダムに新しいメソッド系列を生成する、
請求項6に記載の情報処理装置。
The analysis unit randomly generates a new method sequence from among public methods of an object to be passed to a function under test.
The information processing device according to claim 6.
 前記解析部は、前記実行トレースから抽出したメソッド系列の一部に変更を加えて、新しいメソッド系列を生成する、
請求項6に記載の情報処理装置。
the analysis unit modifies a part of the method sequence extracted from the execution trace to generate a new method sequence.
The information processing device according to claim 6.
 前記解析部は、オブジェクトのpublicメソッドの中からランダムに選択した一部のメソッドを追加して、前記実行トレースから抽出したメソッド系列を変更する、
請求項8に記載の情報処理装置。
the analysis unit adds some methods randomly selected from public methods of the object to modify the method sequence extracted from the execution trace;
The information processing device according to claim 8.
 前記解析部は、ランダムに選択した一部のメソッドを削除して、前記実行トレースから抽出したメソッド系列を変更する、
請求項8に記載の情報処理装置。
the analysis unit deletes some of the methods selected at random to modify the method sequence extracted from the execution trace;
The information processing device according to claim 8.
 前記解析部は、ランダムに選択した一部のメソッドを別のpublicメソッドに置き換えて、前記実行トレースから抽出したメソッド系列を変更する、
請求項8に記載の情報処理装置。
the analysis unit replaces a randomly selected portion of the methods with another public method to modify the method sequence extracted from the execution trace;
The information processing device according to claim 8.
 前記解析部は、前記実行トレースから、テスト対象の関数に渡すオブジェクトのどのメソッドが呼ばれるかを学習した機械学習を利用して、テスト対象の関数を呼び出す前に実行する必要のあるメソッドの系列を生成する、
請求項6に記載の情報処理装置。
The analysis unit generates a sequence of methods that need to be executed before calling the function to be tested, using machine learning that has learned from the execution trace which method of the object to be passed to the function to be tested will be called.
The information processing device according to claim 6.
 前記解析部は、前記変更を加えて作った新しいメソッド系列を使って生成したテストドライバに対してFuzzing又は記号実行を行ってカバレッジを測定し、既存のメソッド系列では到達できない行をカバーするメソッド系列だけを残す、
請求項8に記載の情報処理装置。
The analysis unit measures coverage by performing fuzzing or symbolic execution on the test driver generated using the new method sequence created by making the above changes, and leaves only the method sequence that covers lines that cannot be reached by the existing method sequence.
The information processing device according to claim 8.
 前記記号実行ドライバ生成部は、テスト対象の関数に渡す変数を初期化してシンボル化し、テスト対象の関数を呼び出すだけのコードからなる記号実行ドライバを生成する、
請求項1に記載の情報処理装置。
the symbolic execution driver generation unit initializes and symbolizes variables to be passed to the function under test, and generates a symbolic execution driver consisting of a code that only calls the function under test;
The information processing device according to claim 1 .
 前記記号実行ドライバ生成部は、収集した型情報に基づいて、テスト対象の関数に渡される可能性のある型で変数を初期化及びシンボル化して、記号実行ドライバを生成する、
請求項14に記載の情報処理装置。
the symbolic execution driver generation unit generates a symbolic execution driver by initializing and symbolizing variables with types that may be passed to the function under test based on the collected type information;
The information processing device according to claim 14.
 前記記号実行ドライバ生成部は、テスト対象の関数の引数としてオブジェクトを渡す場合、生成したオブジェクト初期化関数の中にそのオブジェクトを初期化できる関数を呼び出してオブジェクトを初期化し、オブジェクト初期化関数の引数として渡す変数を初期化してシンボル化するコードを記号実行ドライバに挿入する、
請求項14に記載の情報処理装置。
When an object is passed as an argument of a function to be tested, the symbol execution driver generation unit initializes the object by calling a function capable of initializing the object in the generated object initialization function, and inserts a code for initializing and symbolizing a variable to be passed as an argument of the object initialization function into the symbol execution driver.
The information processing device according to claim 14.
 前記テストコード生成部は、前記記号実行ドライバ生成部が生成した記号実行ドライバを記号実行エンジン上で実行して生成したテストケースを入力値としてテスト対象の関数に対するテストコードを生成する、
請求項1に記載の情報処理装置。
the test code generation unit executes the symbol execution driver generated by the symbol execution driver generation unit on a symbol execution engine, and generates a test code for the function to be tested using the test case as an input value.
The information processing device according to claim 1 .
 ソースコードを解析して、ソースコードの型情報及びオブジェクト初期化関数を生成する解析ステップと、
 前記型情報及びオブジェクト初期化関数を用いて記号実行ドライバを生成する記号実行ドライバ生成ステップと、
 前記記号実行ドライバ生成ステップにおいて生成した記号実行ドライバを実行してテストケースを生成する記号実行ステップと、
 前記記号実行ステップにおいて生成したテストケースをテスト対象のプログラムに与えて実行するためのテストコードを生成するテストコード生成ステップと、
を有する情報処理方法。
an analysis step of analyzing the source code to generate type information and object initialization functions for the source code;
a symbolic execution driver generation step of generating a symbolic execution driver using the type information and an object initialization function;
a symbolic execution step of executing the symbolic execution driver generated in the symbolic execution driver generation step to generate a test case;
a test code generation step of generating test code for applying the test cases generated in the symbol execution step to a program under test and executing the program;
An information processing method comprising the steps of:
 ソースコードを解析して、ソースコードの型情報及びオブジェクト初期化関数を生成する解析部、
 前記型情報及びオブジェクト初期化関数を用いて記号実行ドライバを生成する記号実行ドライバ生成部、
 前記記号実行ドライバ生成部が生成した記号実行ドライバを実行してテストケースを生成する記号実行部、
 前記記号実行部が生成したテストケースをテスト対象のプログラムに与えて実行するためのテストコードを生成するテストコード生成部、
としてコンピュータを機能させるようにコンピュータ可読形式で記述されたコンピュータプログラム。
an analysis unit that analyzes the source code and generates type information and object initialization functions for the source code;
a symbolic execution driver generator that generates a symbolic execution driver using the type information and an object initialization function;
a symbolic execution unit that executes the symbolic execution driver generated by the symbolic execution driver generation unit to generate test cases;
a test code generation unit that generates a test code for applying the test cases generated by the symbol execution unit to a program to be tested and executing the program;
A computer program written in a computer-readable form to cause a computer to function as a
PCT/JP2024/013516 2023-05-09 2024-04-01 Information processing device, information processing method, and computer program WO2024232193A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2023-077458 2023-05-09
JP2023077458 2023-05-09

Publications (1)

Publication Number Publication Date
WO2024232193A1 true WO2024232193A1 (en) 2024-11-14

Family

ID=93429927

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2024/013516 WO2024232193A1 (en) 2023-05-09 2024-04-01 Information processing device, information processing method, and computer program

Country Status (1)

Country Link
WO (1) WO2024232193A1 (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2014006643A (en) * 2012-06-22 2014-01-16 Fujitsu Ltd Program, test case generation method, and test case generation apparatus

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2014006643A (en) * 2012-06-22 2014-01-16 Fujitsu Ltd Program, test case generation method, and test case generation apparatus

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
TOKUMOTO, SUSUMU ET AL.: "The Application of C/C++ Symbolic Execution Tool KLEE and the Development of KLEE-CPPUNIT Cooperation Tool", PROCEEDINGS OF EMBEDDED SYSTEMS SYMPOSIUM 2011, 12 October 2011 (2011-10-12), pages 23-1 - 23-8, XP093237228 *

Similar Documents

Publication Publication Date Title
JP4148527B2 (en) Functional test script generator
US9208057B2 (en) Efficient model checking technique for finding software defects
US9632771B2 (en) Association of metadata with source code and applications and services premised thereon
EP0785510B1 (en) Program debugging system for debugging a program having a graphical user interface
US8683282B2 (en) Automatic identification of information useful for generation-based functional verification
US20080313208A1 (en) Apparatus, system, and method for automated context-sensitive message organization
CN101587441A (en) Apparatus, method, and system of assisting software development
US20120185669A1 (en) Program inspection method and non-transitory, computer readable storage medium storing inspection program
JPH0855045A (en) Method and apparatus for coding of data in self-descriptive system
CN111290785A (en) Method and device for evaluating deep learning framework system compatibility, electronic equipment and storage medium
CN107622017B (en) Analysis method for universal automation software test
US7500149B2 (en) Generating finite state machines for software systems with asynchronous callbacks
US10839124B1 (en) Interactive compilation of software to a hardware language to satisfy formal verification constraints
CN116501415B (en) Command execution method and device, electronic equipment and computer readable storage medium
CN111966578A (en) Automatic evaluation method for android compatibility defect repair effect
CN107077365B (en) Selectively loading precompiled headers and/or portions thereof
WO2024232193A1 (en) Information processing device, information processing method, and computer program
Letychevskyi et al. Fuzz testing technique and its use in cybersecurity tasks
US11442845B2 (en) Systems and methods for automatic test generation
WO2023210159A1 (en) Information processing device, information processing method, and computer program
JP6081144B2 (en) Source code analyzer
JP7210917B2 (en) Verification information generation device, verification information generation method, and verification information generation program
JP2023057721A (en) Verification program, verification method, and information processing device
Sochat et al. Binary-level Software Compatibility Tool Agreement
Mendes Integrating flakiness detection and repair

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 24803308

Country of ref document: EP

Kind code of ref document: A1