The present invention relates to test program preparation methods and, more specifically, to a method for generating a test program used to test compilers under development.
Programs written in high level language are converted to executable forms by compilers. In the development of a compiler, test programs are prepared in order to verify its functions. Conventionally, such a test program is manually prepared by the designer of the compiler or an expert familiar with the language specification.
On the other hand, some approaches have also been proposed aimed at automatic generation of a test program by a computer. One of them is to select rules from prepared plural syntax generation rules by means of random numbers and generates a test program based on the selected rules as disclosed in Japanese Patent Laid-open No. 1-220044. Another approach is to check the grammatical coverage of an existing test program, output the non-covered grammars as a reduced set of grammars and automatically generate an additional test program based on the reduced set of grammars as disclosed in Japanese Patent Laid-open No. 3-75840. In still another approach, statement patterns are generated based on syntactic rules described in the Backus Naur form and the generated statement patterns are manually edited into a test program as disclosed in Japanese Patent Laid-open No. 6-214775.
Any of these automatic test program generation methods automatically generate single statements in a test program.
To remove functional defects from a compiler, it is necessary to test the compiler by using many prepared test programs. However, architecturally complicated recent computers require complicated compiler functions. To test all functions of a compiler, an enormous amount of man-power is needed if the test programs are manually prepared as conventional. Therefore, functional verification may not satisfactorily be done before the compiler is shipped.
To cope with this situation, automatic test program generation methods have so far been proposed as mentioned above. However, these methods are to generate single statements. Hard-to-find serious functional problems are generally caused by structurally complicated programs. They do occur not within statements but across plural statements if many conditions are met. Such functional problems are difficult to find by the conventional automatic generation methods designed to mainly generate single statements.
According to an automatic test program generation method by the present invention, a plurality of partial program descriptions (sub-procedural descriptions, called program cells, each of which may form an element of a test program) are selected by a random number-used method and combined into a test program.
The following will describes embodiments of the present invention with reference to the drawings.
In
Weights are given to such cells as those in which tested program bugs were found in the past and those in which bugs are likely to be found. This weighting can be changed on an each test basis.
The same test program 140 is also entered into an expected value generator 210. The expected value generator 210 can be implemented, for example, by using a compiler which has been proven through practical use. The test program is compiled to an executable file by the proven compiler and then executed. An expected value 250 obtained by entering the test program 140 into the expected value generator 210 and the execution result 260 are entered into a result comparator 270. The comparison result is stored as a test result 280 in a storage unit of the computer.
Before a test program is generated as described later in detail with reference to
By using PADs,
For example, “Description 1 Necessary for Unit Operation” 310 may be written as follows:
Likewise, “Description 2 Necessary for Unit Operation” 350 may be written as follows:
Unless the token_CELL_COMPILE_CHECK_is defined, the cell cannot be compiled/executed as a single cell. To compile/execute a test program made of program cells combined, the token_CELL_COMPILE_CHECK_is not defined.
In “Definition of Variables etc. and Setting of Initial Values” 320, variables and others necessary to compile/execute the basic cell are defined and initialized. In addition to variables, constants, macros, etc. can be defined.
“Displaying and Storing of Execution Result” 340 is described to present the execution result of the basic cell on a display unit connected to the computer and store it in a storage unit. By this, while a test program incorporating program cells is being executed, the test operator can grasp the test program's operational progress in detail.
In a cell weight column 840, a value given to each cell is stored, reflecting the probability of the cell being selected using a random number from those registered to the cell management table. For example, the selecting scheme may be designed in such a manner that the probability of a weight 2 program cell being selected is twice as high as that of a weight 1 program cell being selected. In a cell description table information column 850, information about a cell description table 900 is stored. The cell description table information column 850 is divided into a pointer column 851 and a description length column 852. The pointer column 851 indicates the address of the first character of each cell's corresponding cell description in a cell description table 900 whereas the description length column 852 indicates the length of the cell description with the number of characters therein.
With reference to the tables shown in
In the process sequence shown in
In the order of registration with the selected cell table 1000, the following process is performed for each program cell registered with the selected cell table 1000 (730). It is judged whether the program cell preceding the current cell is a basic/function cell or a control cell (740) and, if the preceding cell is a basic cell or a function cell, the current cell is concatenated to the preceding cell (750). If the preceding cell is a control cell, the current program cell is nested into the control cell (760).
Then, variables are made sharable among the program cells which are arranged to constitute a test program according to the above-mentioned procedure (770). Making a variable sharable means making its variable name common among the cells so that an operation result in a program cell can be reflected in the subsequent operation in a later cell. Although variables are defined uniquely in program cells, making variable sharable herein allows data exchange among the program cells.
According to the process sequence mentioned so far, it is possible to automatically generate a test program.
Since the program cells are classified into types and the cells to be executed and their order of execution are determined based on the type of each program cell, it is possible to generate a variety of test programs necessary to test a compiler.
The above-mentioned embodiment can automatically generate a satisfactory test program for testing a compiler by selecting program cells in the order of execution from a plurality of program cells by using random numbers based on cell weights assigned to the program cells. The selected cells are combined into a test program. Further, since selection tendency of the selected program cells can be changed by adjusting cell weights, it is possible to direct the test program to specific defects which are liable to occur in the compiler. Accordingly, this automatic test program generation can reduce the man-hour required to generate a test program and makes it possible to test many aspects of a compiler.
According to the present invention, it is possible to automatically generate a variety of test programs.
| Number | Date | Country | Kind |
|---|---|---|---|
| 2003-011970 | Jan 2003 | JP | national |
| Number | Name | Date | Kind |
|---|---|---|---|
| 4014777 | Brown | Mar 1977 | A |
| 4081656 | Brown | Mar 1978 | A |
| 4200062 | Duckworth | Apr 1980 | A |
| 4369737 | Sanders et al. | Jan 1983 | A |
| 4622924 | Lewis | Nov 1986 | A |
| 4726888 | McCambridge | Feb 1988 | A |
| 5231954 | Stowe | Aug 1993 | A |
| 5244558 | Chiang | Sep 1993 | A |
| 5401371 | Oshima et al. | Mar 1995 | A |
| 5437250 | Rabinovich et al. | Aug 1995 | A |
| 5628885 | Lin | May 1997 | A |
| 5692122 | Bird | Nov 1997 | A |
| 5711865 | Caesar | Jan 1998 | A |
| 5843292 | Spiros | Dec 1998 | A |
| 5997223 | Spiros | Dec 1999 | A |
| 6209493 | Ross | Apr 2001 | B1 |
| 6223337 | Blume | Apr 2001 | B1 |
| 6299656 | Richardson, Jr. et al. | Oct 2001 | B1 |
| 6322757 | Cohn et al. | Nov 2001 | B1 |
| 6430741 | Mattson et al. | Aug 2002 | B1 |
| 6507809 | Yoshino et al. | Jan 2003 | B1 |
| 6560958 | Bromberg et al. | May 2003 | B1 |
| 6880154 | Ghosh et al. | Apr 2005 | B2 |
| 7065631 | Weaver | Jun 2006 | B2 |
| Number | Date | Country | |
|---|---|---|---|
| 20040210874 A1 | Oct 2004 | US |