Program verification support system

The program verification support system addresses inefficient loop testing by generating stub data for loop sections, allowing for faster and more effective program testing.

JP2025114344APending Publication Date: 2025-08-05HITACHI LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
JP2024008986
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2024-01-24
Publication Date
2025-08-05

AI Technical Summary

Technical Problem

Testing programs with loop sections becomes inefficient due to long execution times based on loop iterations, making it difficult to reduce the number of test cases effectively.

Method used

A program verification support system that stores initial and final variable values, generates stub data for loop sections, and replaces loops with stub data in a second program for efficient testing.

Benefits of technology

Enables efficient testing of programs with loop sections by reducing execution time and improving testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2025114344000001_ABST
    Figure 2025114344000001_ABST
Patent Text Reader

Abstract

To efficiently test programs containing loop parts.SOLUTION: A program verification support system 1 stores a first program 100 having a loop part that repeats predetermined processing, as well as initial values of variables in the first program 100 and variable values after execution of the first program 100, by inputting the initial values of the variables into the first program 100, identifies changed portions in the variable values immediately after completing execution of the loop part from the variable values immediately before execution of the loop part begins, generates stub data for the identified changed portions in the variable values, replaces a loop part in a second program 200 corresponding to the first program 100 with the changed portions indicated by the stub data, then executes the second program 200, and outputs data indicating comparison results between execution results of the second program 200 and the variable values after completing execution of the first program 100.SELECTED DRAWING: Figure 1
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present invention relates to a program verification support system. [Background technology]

[0002] Due to changes in the times or changes in the execution environment, it may be necessary to change (convert) the source code of a program written in one language into another language. After conversion, it is necessary to test whether the converted program works in the same way as the unconverted program (confirming consistency between the current and new programs).

[0003] When performing such a test, test cases that define data to be input into the program may be created. As an example of such a case, Patent Document 1 discloses a test case creation support device that includes a specification-based test case generation unit that generates generated test cases, which are test cases, based on test specifications in the development process of an information system, a test case validity verification unit that compares the test cases in the development process of the information system with the generated test cases and outputs differences, a natural language generation unit that generates generated test specifications, which are test specifications in natural language, based on the test cases in the development process of the information system, and a test specification validity verification unit that compares the test specifications in the development process of the information system with the generated test specifications and outputs differences. [Prior art documents] [Patent documents]

[0004] [Patent Document 1] Japanese Patent Application Publication No. 2023-120879 Summary of the Invention [Problem to be solved by the invention]

[0005] However, if source code contains loops (repeated processes), the test execution time using test cases may become very long depending on the number of iterations of the loop or the processing content. Even in such cases, it is difficult to reduce the number of test cases, so there is a need to test loops more efficiently (in less time).

[0006] The present invention has been made in view of the above circumstances, and its object is to provide a program verification support system that can efficiently test a program that includes a loop portion. [Means for solving the problem]

[0007] One aspect of the present invention for solving the above problem is a program verification support system including: a first program having a loop section that repeats a predetermined process; a storage device that stores initial values of variables in the first program and values of the variables after execution of the first program has ended; and a control device that executes a loop section replacement stub generation process that inputs the initial values of the variables into the first program, thereby identifying a portion of the variable's value that has changed from the value of the variable immediately before execution of the loop section starts to the value that has changed immediately after execution of the loop section has ended, and generates the identified changed portion of the variable's value as stub data; and a replacement test execution process that replaces the loop section in a second program corresponding to the first program with the changed portion indicated by the stub data, executes the second program, and outputs data indicating a comparison result between the execution result of the second program and the value of the variable after execution of the first program has ended. [Effects of the Invention]

[0008] According to the present invention, it is possible to efficiently test a program that includes a loop portion. Configurations and effects other than those described above will become apparent from the following description of the embodiments. [Brief explanation of the drawings]

[0009] [Figure 1]1 is a diagram illustrating an example of a configuration of a program verification support system according to an embodiment of the present invention. [Figure 2] 1 is an example of source code of a first program. [Figure 3] 2 is a block diagram illustrating an example of main functional units (programs) included in the language conversion support device. FIG. [Figure 4] FIG. 2 is a diagram illustrating an example of a hardware configuration of each information processing device in the program verification support system. [Figure 5] FIG. 10 is a flowchart illustrating an example of a program verification support process. [Figure 6] FIG. 10 is a flow diagram illustrating an example of a stub generation process. [Figure 7] FIG. 10 is a diagram showing an example of generated loop portion position information. [Figure 8] FIG. 10 is a flowchart illustrating details of a loop portion stub determination process. [Figure 9] FIG. 10 is a flowchart illustrating details of a loop portion replacement stub generation process. [Figure 10] FIG. 10 is a diagram illustrating an example of a generated set of all variable values before entering a loop portion. [Figure 11] FIG. 10 is a diagram illustrating an example of a generated set of all variable values after entering a loop portion. [Figure 12] FIG. 10 illustrates an example of a loop portion replacement stub that is generated. [Figure 13] FIG. 10 is a flow diagram illustrating an example of a test execution process. [Figure 14] FIG. 10 is a flowchart illustrating details of a loop section test execution process. [Figure 15] FIG. 10 is a flowchart illustrating another example of the test execution process. DETAILED DESCRIPTION OF THE INVENTION

[0010] DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS An embodiment of the present invention will be described in detail with reference to the drawings. 1 is a diagram showing an example of the configuration of a program verification support system 1 according to this embodiment. The program verification support system 1 includes a user terminal 10 that stores a program written in a first language (first program 100), a language conversion device 20 that converts the first program 100 into a program written in a second language (second program 200) and generates test case data 300, a language conversion support device 40 that generates a loop section replacement stub 400 based on the first program 100, a test code generation device 30 that generates test code 500 that defines test content for the second program 200 based on the test case data 300 and the loop section replacement stub 400, etc., and a verification device 50 that verifies whether the conversion from the first program 100 to the second program 200 executed by the language conversion device 20 has been correctly performed based on the second program 200 and the test code 500.

[0011] The user terminal 10, the language conversion device 20, the language conversion support device 40, the test code generation device 30, and the verification device 50 may be connected by a wired or wireless communication network such as the Internet, a LAN (Local Area Network), a WAN (Wide Area Network), or a dedicated line, or may be connected directly by a communication line.

[0012] The first language and the second language are, for example, COBOL, JAVA (registered trademark), or C, C#, etc., and the type of language is not particularly limited. In this embodiment, the first language is COBOL, and the second language is JAVA (registered trademark).

[0013] (Source Code) 2 shows an example of source code of the first program 100 for explaining this embodiment. This source code has a first loop section 111 and a second loop section 121.

[0014] The first loop section 111 has a loop start statement 112, a process repeated in the loop section (hereinafter referred to as a loop processing section 113), and a loop end statement 114. The loop start statement 112 has a conditional statement 115 (loop condition expression) related to a predetermined variable (hereinafter referred to as a loop variable) that is the condition for repeating the loop processing section 113 (loop condition).

[0015] The iteration processing unit 113 in the first loop unit 111 has, for example, an assignment instruction 116, a conditional branch instruction 117, and a second loop unit 121. Note that the assignment instruction 116 or the conditional branch instruction 117 may have an expression related to a loop variable, which may change the loop variable.

[0016] Like the first loop section 111, the second loop section 121 also has a loop section start statement 122, a loop processing section 123, a loop section end statement 124, and a conditional statement 125. Unlike the first loop section 111, this conditional statement 125 has a preset number of times (10 times) that the loop processing section 123 is to be repeated.

[0017] As you can see, the loops in this source code are nested, but nesting is not required.

[0018] Although the source code of the second program 200 differs in language or detailed grammar, it has the same structure as the source code of the first program 100. In other words, the content of the processing realized by each command statement and the order of the processing correspond one-to-one between the first program 100 and the second program 200.

[0019] Here, when a test is conducted on the second program 200 to execute all instructions (cover C0), test case data 300 of the second program 200 is generated. The test case data 300 is data that combines the initial values of each variable in the second program 200 and the values of each variable (correct data) after the execution of the second program 200 is completed. In other words, the test case data 300 is data that defines patterns of initial values and correct values of the main routine of the second program 200. Note that the test case data 300 is data that is set in advance by executing the first program 100.

[0020] Here, the language conversion support device 40 of this embodiment generates a stub for each loop section present in the second program 200, which defines the input values of variables to the loop section (values of each variable at the start of the loop section) and the output values from the loop section (values of each variable at the end of the loop section). The generated stub is replaced with the loop section in the second program 200. This simplifies the loop processing, and the test code generation device 30 can generate test code that enables faster execution testing of the second program 200.

[0021] 3 is a block diagram illustrating an example of main functional units (programs) included in the language conversion support device 40. The language conversion support device 40 includes a syntax analysis unit 201, a loop part replacement stub generation unit 202, a replacement test execution unit 203, and a loop part test execution unit 204.

[0022] The syntax analysis unit 201 analyzes loop portions and the nesting of loop portions, etc. That is, the syntax analysis unit 201 analyzes each instruction of the first program 100 to identify a first (outer) loop portion that repeats a first process and a second (inner) loop portion within the first process that repeats a second process.

[0023] The loop section replacement stub generation unit 202 inputs the initial values of the variables in the test case data 300 into the first program 100, thereby identifying the changed parts of the variable values (variables whose values are different before and after the loop section) from the value of the variable immediately before the start of execution of the loop section to the value immediately after the end of execution of the loop section, and generates the changed parts of the identified variable values as stub data (loop section replacement stub 400).

[0024] Specifically, the loop section replacement stub generation unit 202 identifies the values of variables immediately before the start of execution of the loop section and immediately after the end of execution, and generates the identified variable values as variable value set data (a set of all variable values before entering the loop section, and a set of all variable values after entering the loop section).

[0025] At this time, the loop section replacement stub generation unit 202 determines whether the processing load of the loop section of the first program 100 satisfies a predetermined condition (for example, whether the number of processing steps of the loop section of the first program 100 is a predetermined number or more), and generates stub data if it determines that the processing load of the loop section satisfies the predetermined condition.

[0026] Furthermore, when loop portions are nested, the loop portion replacement stub generator 202 generates stub data in order from the inner loop portion to the outer loop portion.

[0027] Specifically, the loop section replacement stub generation unit 202 determines whether the processing load of the second loop section of the first program 100 satisfies a predetermined condition based on the analysis results of each process of the second loop section, and if it determines that the processing load of the second loop section satisfies the predetermined condition, generates stub data related to the second loop section. Thereafter, the loop section replacement stub generation unit 202 determines whether the processing load of the first loop section of the first program 100 satisfies a predetermined condition based on the analysis results of each process of the second loop section and the first loop section, and generates stub data related to the first loop section if it determines that the processing load of the first loop section satisfies the predetermined condition.

[0028] Next, the replacement test execution unit 203 replaces the loop section in the second program 200 with the changed part indicated by the stub data, executes the second program 200, and outputs data (test result data) indicating the result of comparing the execution result of the second program 200 with the preset variable value after execution of the first program 100 is completed (correct data in the test case data 300).

[0029] The loop section test execution unit 204 sets the values of the variables immediately before the start of execution of the variable value set data (all variable values set before entering the loop section) immediately before executing the loop section in the second program 200, and executes the loop section, thereby obtaining the values of the variables immediately after the execution of the loop section is completed, and outputs data (loop section test pass / fail data) showing the results of comparing the obtained variable values with the values of the variables immediately after the start of execution of the variable value set data (all variable values set after entering the loop section).

[0030] 4 is a diagram showing an example of a hardware configuration of each information processing device (the language conversion device 20, the language conversion support device 40, the test code generation device 30, and the verification device 50) in the program verification support system 1. Each information processing device includes a control device 91 such as a CPU (Central Processing Unit), a main storage device 92 such as a RAM (Random Access Memory) or a ROM (Read Only Memory), an auxiliary storage device 93 such as an HDD (Hard Disk Drive) or an SSD (Solid State Drive), an input device 94 such as a keyboard, a mouse, or a touch panel, an output device 95 such as a display or a touch panel, and a communication device 96 configured by a NIC (Network Interface Card), a wireless communication module, a USB (Universal Serial Interface) module, a serial communication module, or the like.

[0031] The functions of the functional units of each information processing device in the program verification support system 1 described above are realized by the control device 91 reading a program from the main storage device 92 or the auxiliary storage device 93. Each program can be recorded on, for example, a portable or fixed recording medium and distributed. All or part of these programs may be realized using virtual information processing resources provided using virtualization technology, process space separation technology, or the like, such as a virtual server provided by a cloud system. All or part of these programs may be realized by a service provided by a cloud system via an API (Application Programming Interface), for example. Next, the processing performed by the program verification support system 1 will be described.

[0032] <Program verification process> 5 is a flow diagram showing an example of a process (program verification support process) for verifying whether the second program 200 corresponds to the first program 100. The program verification support process is started, for example, when the second program 200 to be verified and the corresponding first program 100 are respectively specified by the user.

[0033] The language conversion support device 40 executes a stub generation process s100 based on the first program 100 to create stub data (a set of all variable values before entering the loop section 410, a set of all variable values after entering the loop section 420, and a loop section replacement stub 400) relating to the loop section in the first program 100.

[0034] Then, the language conversion support device 40 executes a test execution process s200 that applies the stub data created in the stub generation process s100 to the second program 200, thereby generating test result data 600 that indicates whether the second program 200 corresponds to the first program 100 or not. The stub generation process s100 and the test execution process s200 will be described below.

[0035] <Stub generation process> FIG. 6 is a flow diagram illustrating an example of the stub generation process s100. The language conversion support device 40 reads the source code of the first program 100. Then, the language conversion support device 40 analyzes the source code of the first program 100, identifies all the positions of loop parts in the source code (line numbers of the source code), and registers the results in the loop part position information 430 (s102, s103).

[0036] For example, if the first program 100 is COBOL, the language conversion support device 40 identifies the start line number and end line number of the loop section by identifying the PERFORM statement and the corresponding END-PERFORM statement. The language conversion support device 40 also identifies the loop condition expression by identifying the statement after UNTIL in the PERFORM statement. Furthermore, the language conversion support device 40 identifies the portion from the statement following the PERFORM statement to the portion immediately before the END-PERFORM statement as the loop processing section.

[0037] Furthermore, for example, if the first program 100 is written in C, C#, or JAVA (registered trademark), the language conversion support device 40 identifies the start line number and end line number of the loop by identifying the while statement and the curly braces ({}) that follow it. The language conversion support device 40 also identifies the part in the parentheses ('()') immediately after the while statement to identify the loop condition expression. Furthermore, the language conversion support device 40 identifies the part from the statement following the while statement to the last part in the curly braces as the loop processing part. Similar processing is performed for other types of loop processing (e.g., for, foreach, while, do).

[0038] The language conversion support device 40 then analyzes the loop condition expression of the loop section and each instruction in the iteration processing section, and attempts to identify the number of times the iteration processing section is to be repeated (if the number of iterations cannot be uniquely identified, it stores this information). Furthermore, the language conversion support device 40 identifies the number of instructions (number of steps) in the iteration processing section.

[0039] For example, the language conversion support device 40 determines whether the loop condition expression specifies the number of repetitions by a constant. Also, for example, the language conversion support device 40 determines whether the repetition processing section is always repeated a predetermined number of times by identifying the loop variable in the loop condition expression and the processing related to the loop variable in the repetition processing section.

[0040] An example of an example of a case where the repetitive processing section is always repeated a predetermined number of times is when an arithmetic operation that changes the value of a loop variable in a loop condition expression exists in the repetitive processing section, and the arithmetic operation does not include any variables other than the loop variable, or when the arithmetic operation includes a variable other than the loop variable, but the value of the variable is not changed by any process other than the repetitive processing during the processing of the repetitive processing section. An example of an example of a case where the repetitive processing section is not always repeated a predetermined number of times is when the value of the loop variable in a loop condition expression is not changed by any process other than the repetitive processing during the processing of the repetitive processing section, or when the value can be changed by user input.

[0041] Furthermore, the language conversion support device 40 determines whether the first program 100 is a program in which loop sections are nested. That is, the language conversion support device 40 identifies a first loop section that repeats a certain process (first process), and then identifies a second loop section that repeats a certain process (second process) within the first process.

[0042] (Loop position information) 7 is a diagram showing an example of the generated loop portion position information 430. The loop portion position information 430 includes data such as a loop number 431 assigned to each loop portion, a start line number 432 of the loop portion, and an end line number 433 of the loop portion.

[0043] Next, as shown in FIG. 6, the language conversion support device 40 executes a loop section stub generation determination process s103 for determining whether or not to generate a stub for each loop section extracted in s102.

[0044] The language conversion support device 40 executes the loop portion replacement stub generation process s104 for generating a stub for the loop portion for which it has been determined in the loop portion stub generation determination process s103 that a stub should be generated.

[0045] <Loop stub determination process> FIG. 8 is a flowchart illustrating the loop section stub determination process s103 in detail. First, the language conversion support device 40 selects one of the loop portions identified in s102 (s031).

[0046] The language conversion support device 40 determines whether the processing of the selected loop section is stable (s1032). For example, the language conversion support device 40 acquires information on the change history of the first program 100 and determines whether the processing of the selected loop section has been changed by a user or an external system at least a predetermined frequency or a predetermined number of times. Furthermore, for example, the language conversion support device 40 determines whether the processing of the selected loop section includes processing that references an external database.

[0047] If the processing of the selected loop portion is stable (s1032: YES), the language conversion support device 40 executes the processing of s1033, and if the processing of the selected loop portion is not stable (s1032: NO), the language conversion support device 40 executes the processing of s1038.

[0048] In s1033, the language conversion support device 40 determines whether or not it is possible to uniquely identify the number of times the repetition processing section of the selected loop section is repeated.

[0049] If the number of times the repetition processing unit is repeated can be uniquely identified (s1033: YES), the language conversion support device 40 executes the processing of s1037, and if the number of times the repetition processing unit is repeated cannot be uniquely identified (s1033: NO), the language conversion support device 40 executes the processing of s1034.

[0050] In s1034, the language conversion support device 40 determines whether or not to generate a stub (variable value set) corresponding to the selected loop portion based on a designation input from the user.

[0051] If a stub corresponding to the selected loop portion is to be generated (s1035: YES), the language conversion support device 40 executes the process of s1036, and if a stub corresponding to the selected loop portion is not to be generated (s1035: NO), the language conversion support device 40 executes the process of s1038.

[0052] In addition, in s1034, the language conversion support device 40 may automatically and uniformly determine whether or not to generate a stub, rather than accepting an input from the user.

[0053] On the other hand, in s1037, the language conversion support device 40 estimates the processing time in the iterative processing section of the selected loop by multiplying the number of instructions in the iterative processing section by the number of iterations.

[0054] If the estimated processing time is longer than the predetermined threshold (s1037: YES), the language conversion support device 40 executes the processing of s1036, and if the estimated processing time is not longer than the predetermined threshold (s1037: NO), the language conversion support device 40 executes the processing of s1038.

[0055] In s1038, the language conversion support device 40 determines not to generate a stub corresponding to the selected loop portion, and repeats the processing from s1031 onwards to select the next loop portion until it has been executed for all loop portions.

[0056] When loop sections are nested, the language conversion support device 40 generates variable value sets for the loop sections (a set of all variable values before entering a loop section 410, a set of all variable values after entering a loop section 420) in the order from the innermost loop section to the outermost loop section. For example, the language conversion support device 40 generates a variable value set for each second loop section by determining whether the processing load of each second loop section satisfies a predetermined condition based on an analysis result (number of steps, etc.) of the processing load of the second loop section. Then, for a first loop section including each second loop section, the language conversion support device 40 generates a variable value set for the first loop section by determining whether the processing load of the first loop section satisfies a predetermined condition based on an analysis result (number of steps, etc.) of the processing load of the first loop section that reflects the analysis result (number of steps, etc.) of the processing load of each second loop section. For example, the language conversion support device 40 stores information that when the second loop section is stubbed, the number of processing steps of the second loop section is a predetermined number of steps (for example, 1 step), and when the second loop section is not stubbed, the number of processing steps of the second loop section is the product of the number of steps of the repetitive processing section and the number of repetitions.

[0057] <Loop replacement stub generation process> Next, FIG. 9 is a flowchart illustrating the loop portion replacement stub generation process s105 in detail.

[0058] The language conversion support device 40 inputs the test case data 300 in which the initial values of each variable are set to the first program 100, and starts execution of the first program 100 (s1051). Then, the language conversion support device 40 monitors the execution process of the first program 100 (s1052: NO).

[0059] When the first program 100 reaches the start position (line number) of the loop section (s1052: YES), the language conversion support device 40 acquires the values of all variables in the first program 100 at that time and registers the acquired values of all variables in the set of all variable values before entering the loop section 410 (s1053).

[0060] Furthermore, the language conversion support device 40 monitors the execution process of the first program 100 (s1054: NO).

[0061] When the first program 100 reaches the end position (line number) of the loop section (s1054: YES), the language conversion support device 40 acquires the values of all variables in the first program 100 at that time and registers the acquired values of all variables in the set of all variable values 420 after entering the loop section (s1055).

[0062] Then, the first program 100 compares the set of all variable values before entering the loop section 410 with the set of all variable values after entering the loop section 420, identifies the difference in the variable values, and registers the identified content in the loop section replacement stub 400 (s1053).

[0063] Thereafter, the language conversion support device 40 continues to monitor the execution process of the first program 100, and repeats the processing from s1052 onwards. When the first program 100 is executed to the end, the loop section replacement stub generation processing s105 ends.

[0064] (Set all variable values before entering the loop) 10 is a diagram showing an example of a generated set of all variable values before entering a loop section 410. The set of all variable values before entering a loop section 410 is data generated for each loop section, and includes names 411 of each variable in the first program 100 and values 412 of each variable immediately before the start of a predetermined loop section of the first program 100.

[0065] (All variable values are set after entering the loop) 11 is a diagram showing an example of a generated set of all variable values after entering a loop section 420. The set of all variable values after entering a loop section 420 is data generated for each loop section, and includes names 421 of each variable in the first program 100 and values 422 of each variable immediately after the end of a predetermined loop section of the first program 100.

[0066] (Loop replacement stub) 12 is a diagram showing an example of a generated loop section replacement stub 400. The loop section replacement stub 400 is data generated for each loop section, and includes each variable name 401 in the first program 100, and a value (post-replacement value 402) in the set of all variable values after entering the loop section 420 for variables whose values in the set of all variable values before entering the loop section 410 and the set of all variable values after entering the loop section 420 are different.

[0067] <Test execution process> Next, FIG. 13 is a flow diagram illustrating an example of the test execution process s200. The verification device 50 reads the source code of the second program 200 (s201).

[0068] As in steps s101 to s103, the verification device 50 analyzes the source code of the second program 200 to identify all start and end positions (line numbers of the source code) of each loop section (s202). The verification device 50 associates the identified start and end positions with the start and end positions (line numbers) of the loop section of the first program 100 in the loop section position information 430 and stores them.

[0069] The verification device 50 executes a loop section test execution process s203 for each loop section identified in s202, which determines whether or not the loop section of the second program 200 is correct source code (correct or incorrect) for each test case in the test case data 300, based on the set of all variable values before entering the loop section 410 and the set of all variable values after entering the loop section 420. Details of the loop section test execution process s203 will be described later.

[0070] The verification device 50 determines whether or not the loop section test execution process s203 has been performed for all loop sections for all test cases (s204).

[0071] If the loop section test execution process s203 has been performed for all loop sections for all test cases (s204: done), the verification device 50 executes the process of s205. If there is a loop section or test case for which the loop section test execution process s203 has not been performed (s204: no), the verification device 50 executes the loop section test execution process s203 for that loop section or test case.

[0072] In s205, the verification device 50 checks all results of the loop section test execution process s203. If all results are "positive" (s205: pass), the verification device 50 executes the process of s206, and if there is a case where the result is "negative" (s205: no), the verification device 50 registers data indicating that the test for that case (test case and loop section) has failed in the test result data 600.

[0073] In s206, first, the test code generation device 30 generates the second program 200 (test code 500) by replacing the loop portion of the second program 200 with the loop portion replacement stub 400. The verification device 50 also selects one of the test cases related to the test case data 300, inputs the data of that test case into the replaced second program 200 (test code 500), executes it, and stores whether the execution result was correct or not (correct or incorrect).

[0074] For example, the verification device 50 starts the execution of the second program 200 based on the initial values of each variable in the test case. The verification device 50 monitors the execution position of the second program 200, and when the execution position reaches any loop section, the verification device 50 overwrites the value of the variable of each variable name 401 in the loop section replacement stub 400 corresponding to that loop section with the replaced value 402. Then, the verification device 50 moves the execution position of the second program 200 to immediately after that loop section.

[0075] Then, the verification device 50 compares the value of each variable after the second program 200 has finished executing with the correct answer data (value of each variable) of each test case. If the two match, the verification device 50 stores the test result as correct (correct), and if there is a variable for which the two do not match, the verification device 50 stores the test result for that variable as incorrect (incorrect).

[0076] The verification device 50 determines whether the process of s206 has been executed for all test cases (s207). If the process of s206 has been executed for all test cases (s207: Pass), the verification device 50 registers the test results (pass or fail) stored up to that point in the test result data 600.

[0077] On the other hand, if there is a test case for which the process of s206 has not been executed (s207: No), the verification device 50 repeats the process of s206 for that test case.

[0078] <Loop test execution process s203> FIG. 14 is a flow diagram illustrating the loop section test execution process s203 in detail.

[0079] The verification device 50 first selects one of the loop sections of the second program 200 and reads the source code of the selected loop section. The verification device 50 also reads each variable name 411 and each variable value 412 from the set of all variable values before entering the loop section 410 related to the selected loop section.

[0080] The verification device 50 then symbolically executes the read loop portion (s2032). At this time, the verification device 50 sets the contents of the read set of all variable values before entering the loop portion 410 as the initial values at the time of execution. The verification device 50 stores the values of each variable in the set of all variable values before entering the loop portion 410 read in s2032 as a result of the symbolic execution in s2032.

[0081] The verification device 50 compares the stored variable value for each variable in the set of all variable values 410 before entering the loop section read in s2032 with the variable value (expected value) in the set of all variable values 420 after entering the loop section (s2033).

[0082] If the two values match, the verification device 50 registers information indicating that the test of the loop section was successful (pass) in the loop section test pass / fail data 700, and if the two values do not match, the verification device 50 registers information indicating that the test of the loop section was unsuccessful (fail) in the loop section test pass / fail data 700.

[0083] <Another example of test execution process> 15 is a flow diagram illustrating another example of the test execution process s300, which is a process for carrying out a regression test.

[0084] The processing of steps s201 to s204 shown in the figure is the same as the test execution processing S200 described above.

[0085] After executing the loop section test execution process s203 for all loop sections (s203, s204: completed), in s305 the verification device 50 checks all results of the loop section test execution process s203. If all results are "positive" (s305: pass), the verification device 50 executes the process of s206, which is the same as the test execution process S200 described above.

[0086] On the other hand, if there is a case where the result is "No" (s305: No), the verification device 50 displays the second program 200 on the editing screen and accepts input from the user to correct the loop part where the result is "No" (s307). After that, the processing from s201 onwards is repeated.

[0087] After steps s206 and s207, which are similar to the test execution process S200 described above, are performed, the verification device 50 determines whether the execution results of the second program 200 are correct (correct or incorrect) for all test cases (s308).

[0088] If the execution results of the second program 200 are correct for all test cases (s308: Pass), the verification device 50 registers the test results (pass or fail) stored up to that point in the test result data 600.

[0089] If there is a test case for which the execution result of the second program 200 is incorrect (s308: Pass), the verification device 50 displays the second program 200 on the editing screen and accepts input for correcting the loop portion from the user (s309). After that, the processing from s206 onwards is repeated.

[0090] As described above, the program verification support system 1 of this embodiment inputs the initial values of variables in the test case data 300 into the first program 100, generates stub data (i.e., loop section replacement stub 400) for the changed portion of the variable value from the value of the variable immediately before the start of execution of the loop section of the first program 100 to the value immediately after the execution of the loop section has ended, replaces the loop section in the second program 200 with the changed portion indicated by the loop section replacement stub 400, executes the second program 200, and outputs test result data 600 indicating the comparison result between the execution result of the second program 200 and the value of the variable after the execution of the first program 100 has ended (correct data of the test case data 300).

[0091] In this way, by performing an execution test of the second program 200 using stub data based on differential data of variables between just before and just after the start of the loop section, even if the second program 200 repeats processing including the loop section, the test execution of the second program 200 can be performed quickly without performing repeated testing. That is, according to the program verification support system 1 of this embodiment, it is possible to efficiently test a program that includes a loop portion.

[0092] Furthermore, the program verification support system 1 of this embodiment generates a loop portion replacement stub 400 when it is determined that the processing load of the loop portion of the first program 100 satisfies a predetermined condition.

[0093] This allows execution testing using the loop portion replacement stub 400 only when necessary, and makes it possible to use the loop portion replacement stub 400 only when it improves the efficiency of the execution testing.

[0094] For example, the program verification support system 1 of this embodiment generates the loop portion replacement stub 400 when it determines that the total number of steps of processing executed in the loop portion of the first program 100 is equal to or greater than a predetermined number.

[0095] This allows the loop portion replacement stub 400 to be used only when the processing speed of the execution test is improved, thereby making it possible to more reliably improve the processing speed of the execution test.

[0096] Furthermore, for example, when the program verification support system 1 of this embodiment determines that the total number of steps of processing executed in the loop section of the first program 100 is indefinite or unknown, it accepts a specification as to whether or not to generate a loop section replacement stub 400, and generates the loop section replacement stub 400 when it accepts a specification to generate the loop section replacement stub 400.

[0097] As a result, when the total number of processing steps executed in the loop section is indefinite or unknown and it is unclear whether the processing speed of the execution test will improve, the user is given the opportunity to decide whether or not to generate the loop section replacement stub 400, thereby enabling more flexible test execution of the program using stub data.

[0098] Furthermore, for example, the program verification support system 1 of this embodiment generates the loop portion replacement stub 400 only when it is determined that the total number of steps of the processing executed in the loop portion of the first program 100 is indefinite or unknown, or only when it is determined that the total number of steps of the processing executed in the loop portion of the first program 100 is neither indefinite nor unknown.

[0099] In this way, by uniformly generating (or not generating) the loop section replacement stub 400 depending on the total number of steps of processing executed in the loop section of the first program 100, it is possible to perform an execution test with high predictability in terms of processing speed, etc.

[0100] Furthermore, for example, the program verification support system 1 of this embodiment determines whether the processing load of the inner (second) loop section of the first program 100 satisfies a predetermined condition based on the analysis results of each process, and if the processing load of the inner loop section satisfies the predetermined condition, generates a loop section replacement stub 400 for the inner loop section, and determines whether the processing load of the outer (first) loop section of the first program 100 satisfies a predetermined condition based on the analysis results of each process of the inner and outer loop sections, and if the processing load of the first loop section satisfies the predetermined condition, generates a loop section replacement stub 400 for the first loop section.

[0101] In this way, when loop portions are nested in the first program 100, by generating loop portion replacement stubs 400 sequentially from the inside to the outside, stub data for each loop portion can be generated efficiently.

[0102] Furthermore, the program verification support system 1 of this embodiment inputs the initial values of the variables into the first program 100, thereby identifying the values of the variables immediately before the start of execution and immediately after the end of execution of the loop section, generates the identified variable values as variable value set data (set of all variable values before entering the loop section 410, set of all variable values after entering the loop section 420), sets the values of the variables in set of all variable values before entering the loop section 410 immediately before the execution of the loop section in the second program 200 and executes the loop section, thereby obtaining the values of the variables immediately after the end of execution of the loop section, and outputs loop section test pass / fail data 700 indicating the comparison result between the obtained variable values and the variable values in set of all variable values after entering the loop section 420.

[0103] In this way, by creating a set of all variable values before entering the loop section 410 and a set of all variable values after entering the loop section 420, which are variable tables for the period immediately before and immediately after the start of the loop section, respectively, and using these to test execute the loop section, it is possible to accurately check whether the loop section of the second program 200 is operating correctly.

[0104] The present invention is not limited to the above-described embodiments, and can be implemented using any components within the scope of the present invention. The above-described embodiments and modifications are merely examples, and the present invention is not limited to these contents as long as the characteristics of the invention are not impaired. Furthermore, although various embodiments and modifications have been described above, the present invention is not limited to these contents. Other aspects conceivable within the scope of the technical idea of the present invention are also included within the scope of the present invention.

[0105] For example, part of the hardware provided in each device of this embodiment may be provided in another device.

[0106] Furthermore, each program of each device may be provided in another device, a program may consist of multiple programs, or multiple programs may be integrated into one program. [Explanation of symbols]

[0107] 1 program verification support system, 100 first program, 200 second program, 30 test code generation device, 40 language conversion support device, 50 verification device

Claims

1. a storage device that stores a first program having a loop section that repeats a predetermined process, initial values of variables in the first program, and values of the variables after execution of the first program has ended; and a loop section replacement stub generation process for inputting initial values of the variables into the first program to identify a change in the value of the variables from the value immediately before the start of execution of the loop section to the value immediately after the end of execution of the loop section, and generating stub data for the identified change in the value of the variables; a control device that executes a substitution test execution process by replacing a loop portion in a second program corresponding to the first program with a changed portion indicated by the stub data, executing the second program, and outputting data indicating a result of comparison between a result of execution of the second program and a value of a variable after execution of the first program has ended. A program verification support system comprising:

2. The control device In the loop portion replacement stub generation process, it is determined whether or not a processing load of the loop portion of the first program satisfies a predetermined condition, and when it is determined that the processing load of the loop portion satisfies the predetermined condition, the stub data is generated.

2. The program verification support system according to claim 1.

3. The control device In the loop portion replacement stub generation process, it is determined whether or not the total number of steps of the processing executed in the loop portion of the first program is equal to or greater than a predetermined number, and when it is determined that the total number of steps of the processing executed in the loop portion of the first program is equal to or greater than the predetermined number, the stub data is generated.

3. The program verification support system according to claim 2.

4. The control device In the loop portion replacement stub generation process, it is determined whether or not the total number of steps of the processing executed in the loop portion of the first program is indefinite or unknown, and when it is determined that the total number of steps of the processing executed in the loop portion of the first program is indefinite or unknown, a designation as to whether or not to generate the stub data is accepted, and when the designation to generate the stub data is accepted, the stub data is generated.

3. The program verification support system according to claim 2.

5. The control device In the loop portion replacement stub generation process, it is determined whether or not the total number of steps of the processing executed in the loop portion of the first program is indefinite or unknown, and the stub data is generated only when it is determined that the total number of steps of the processing executed in the loop portion of the first program is indefinite or unknown, or only when it is determined that the total number of steps of the processing executed in the loop portion of the first program is neither indefinite nor unknown.

3. The program verification support system according to claim 2.

6. The control device executing a syntax analysis process that analyzes each instruction of the first program to identify a first loop portion that repeats a first process and a second loop portion within the first process that repeats a second process, and analyzes each process; in the loop portion replacement stub generation process, determining whether or not a processing load of a second loop portion of the first program satisfies a predetermined condition based on an analysis result of each process of the second loop portion, and generating stub data related to the second loop portion when it is determined that the processing load of the second loop portion satisfies the predetermined condition; in the loop portion replacement stub generation process, determining whether or not a processing load of a first loop portion of the first program satisfies a predetermined condition based on an analysis result of each process of the second loop portion and the first loop portion, and generating stub data related to the first loop portion when it is determined that the processing load of the first loop portion satisfies the predetermined condition; 2. The program verification support system according to claim 1.

7. The control device in the loop portion replacement stub generation process, inputting initial values of the variables into the first program to identify values of the variables immediately before the start of execution of the loop portion and immediately after the end of execution, and generating the identified values of the variables as variable value set data; a loop section test execution process for setting the value of the variable immediately before the start of execution of the variable value set data immediately before the execution of the loop section in the second program and executing the loop section, thereby acquiring the value of the variable immediately after the completion of execution of the loop section, and outputting data indicating a comparison result between the acquired value of the variable and the value of the variable immediately after the start of execution of the variable value set data; 2. The program verification support system according to claim 1.

Citation Information

Patent Citations

  • Test case preparation support apparatus and specification preparation support apparatus

    JP2023120879A