Test-prioritization Tool

The Intel® compiler Test-prioritization Tool enables profile-guided optimizations to select and prioritize application tests based on prior execution profiles of the application. The tool offers a potential of significant time saving in testing and developing large-scale applications where testing is the major bottleneck. The tool can be used for both IA-32 and Itanium® architectures.

This tool lets you select and prioritize the tests that are most relevant for any subset of the application's code. When certain modules of an application are changed, the Test-prioritization Tool suggests the tests that are most probably affected by the change. The tool analyzes the profile data from previous runs of the application, discovers the dependency between the application's components and its tests, and uses this information to guide the process of testing.

Features and Benefits

The tool provides an effective testing hierarchy based on the application's code coverage. The advantages of the tool usage can be summarized as follows:

Command-line Syntax

The syntax for this tool is as follows:

tselect -dpi_list file

where -dpi_list is a required tool option that sets the path to the DPI list file that contains the list of the .dpi files of the tests you need to prioritize.

Tool Options

The tool uses options that are listed in the table that follows.

Option Description
-help Prints all the options of the test-prioritization tool.
-spi file Sets the path name of the static profile information file .spi. Default is pgopti.spi
-dpi_list file Sets the path name of the file that contains the name of the dynamic profile information (.dpi) files. Each line of the file should contain one .dpi name optionally followed by its execution time. The name must uniquely identify the test.
-prof_dpi file Sets the path name of the output report file.
-comp Sets the filename that contains the list of files of interest.
-cutoff value Terminates when the cumulative block coverage reaches value% of pre-computed total coverage. value  must be greater than 0.0 (for example, 99.00). It may be set to 100.
-nototal Does not pre-compute the total coverage.
-mintime Minimizes testing execution time. The execution time of each test must be provided on the same line of dpi_list file after the test name in dd:hh:mm:ss format.
-verbose Generates more logging information about the program progress.

Usage Requirements

To run the Test-prioritization Tool on an application’s tests, the following files are required:

Note

It is very important that you make sure that unrelated .dyn files, oftentimes from previous runs or from other tests, are not present in that directory. Otherwise, profile information will be based on invalid profile data. This can negatively impact the performance of optimized code as well as generate misleading coverage information.

Note

For successful tool execution, you should:

For example: Test1.dpi 00:00:60:35 informs that Test1 lasted 0 days, 0 hours, 60 minutes and 35 seconds. The execution time is optional. However, if it is not provided, then the tool will not prioritize the test for minimizing execution time. It will prioritize to minimize the number of tests only.

Usage Model

The chart that follows presents the Test-prioritization Tool usage model.

Here are the steps for a simple example (myApp.c) for IA-32 systems.

1. Set

PROF_DIR=/myApp/prof_dir

2. Issue command

prompt>icpc -prof_genx myApp.c

This command compiles the program and generates an instrumented binary as well as the corresponding static profile information pgopti.spi.

3. Issue command

rm PROF_DIR /*.dyn

Make sure that there are no unrelated .dyn files present.

4. Issue command

myApp < data1

Invocation of this command runs the instrumented application and generates one or more new dynamic profile information files that have an extension .dyn in the directory specified by PROF_DIR.

5. Issue command

profmerge -prof_dpi Test1.dpi

At this step, the profmerge tool merges all the .dyn files into one file (Test1.dpi) that represents the total profile information of the application on Test1.

6. Issue command

rm PROF_DIR /*.dyn

Make sure that there are no unrelated .dyn files present.

7. Issue command

myApp < data2

This command runs the instrumented application and generates one or more new dynamic profile information files that have an extension .dyn in the directory specified by PROF_DIR.

8. Issue command

profmerge -prof_dpi Test2.dpi

At this step, the profmerge tool merges all the .dyn files into one file (Test2.dpi) that represents the total profile information of the application on Test2.

9. Issue command

rm PROF_DIR /*.dyn

Make sure that there are no unrelated .dyn files present.

10.  Issue command

myApp < data3

This command runs the instrumented application and generates one or more new dynamic profile information files that have an extension .dyn in the directory specified by PROF_DIR.

11. Issue Command

profmerge -prof_dpi Test3.dpi

At this step, the profmerge tool merges all the .dyn files into one file (Test3.dpi) that represents the total profile information of the application on Test3.

12. Create a file named tests_list with three lines. The first line contains Test1.dpi, the second line contains Test2.dpi, and the third line contains Test3.dpi.

When these items are available, the Test-prioritization Tool may be launched from the command line in PROF_DIR directory as described in the following examples. In all examples, the discussion references the same set of data.

Example 1 Minimizing the Number of Tests

tselect -dpi_list tests_list -spi pgopti.spi

where the -spi option specifies the path to the .spi file.

Here is a sample output from this run of the Test-prioritization Tool:

Total number of tests = 3

Total block coverage ~ 52.17

Total function coverage ~ 50.00

 
Num %RatCvrg %BlkCvrg %FncCvrg Test Name @ Options
1 87.50 45.65 37.50 Test3.dpi
2 100.00 52.17 50.00 Test2.dpi

In this example, the Test-prioritization Tool has provided the following information:

Example 2 Minimizing Execution Time

Suppose we have the following execution time of each test in the tests_list file:

Test1.dpi 00:00:60:35

Test2.dpi 00:00:10:15

Test3.dpi 00:00:30:45

The following command executes the Test-prioritization Tool to minimize the execution time with the -mintime option:

tselect -dpi_list tests_list -spi pgopti.spi -mintime

Here is a sample output:

Total number of tests = 3

Total block coverage ~ 52.17

Total function coverage ~ 50.00

Total execution time = 1:41:35

 
num elapsedTime %RatCvrg %BlkCvrg %FncCvrg Test Name @ Options
1 10:15 75.00 39.13 25.00 Test2.dpi
2 41:00 100.00 52.17 50.00 Test3.dpi

In this case, the results indicate that the running all tests sequentially would require one hour, 45 minutes, and 35 seconds, while the selected tests would achieve the same total block coverage in only 41 minutes.

Note

The order of tests when prioritization is based on minimizing time (first Test2, then Test3) could be different than when prioritization is done based on minimizing the number of tests. See the preceding example: first Test3, then Test2. In Example 2, Test2 is the test that gives the highest coverage per execution time. So, it is picked as the first test to run.

Using Other Options

The -cutoff option enables the Test-prioritization Tool to exit when it reaches a given level of basic block coverage.

tselect -dpi_list tests_list -spi pgopti.spi -cutoff 85.00

If the tool is run with the cutoff value of 85.00 in the previous example, only Test3 will be selected, as it achieves 45.65% block coverage, which corresponds to 87.50% of the total block coverage that is reached from all three tests.

The Test-prioritization Tool does an initial merging of all the profile information to determine the total coverage that is obtained by running all the tests. The -nototal option. enables you to skip this step. In such a case, only the absolute coverage information will be reported, as the overall coverage remains unknown.