The example in Analyzing Test Coverage Data tells us that we can achieve 100% test coverage by executing the strsort program without either of its two switches. To complete testing, execute the program with the following command:

strsort aaa bbbb

This produces the following output:

Output for Windows
[strsort.c:15] **READ_NULL**
>> 			if(dir * strcmp(a[j-1], a[j]) > 0) {

   Reading null pointer: <argument 2>

   Stack trace where the error occurred:
			  	  strcmp() (interface)
			 bubble_sort() strsort.c, 15
					main() strsort.c, 41

**Memory corrupted. Program may crash!!**

**Insure trapped exception: 0xc0000005**

  Stack trace where the error occurred:
				  strcmp() (interface)
 strsort.exe bubble_sort() strsort.c, 15
	    strsort.exe main() strsort.c, 41
Access violation
Output for Unix
[strsort.c:15] **READ_NULL**
>> 			if(dir * strcmp(a[j-1], a[j]) > 0) {

   Reading null pointer: <argument 2>

   Stack trace where the error occurred:
			  	  strcmp() (interface)
			 bubble_sort() strsort.c, 15
					main() strsort.c, 41

**Memory corrupted. Program may crash!!**

**Insure trapped signal: 11**

   Stack trace where the error occurred:
				  strcmp() ../sysdeps/generic/strcmp.c, 39
				  strcmp() (interface)
			 bubble_sort() strsort.c, 15
					main() strsort.c, 41
Segmentation violation
Abort (core dumped)
Exit 134

The error reported in the output can be ignored. It is intentional and part of an exercise for learning how to use Insure++.

When the tca tca.log command is executed, the following output is produced:

COVERAGE SUMMARY
================
0 blocks untested
13 blocks tested


	100% covered

This indicates that the application is 100% tested. The set of test cases that have been run, including this last one, completely exercised all the code in this application. It makes sense to incorporate these test cases (in conjunction with Insure++) into a quality assurance test suite for this code.

There are several options you can use to control coverage analysis. See Configuration Options (psrc).

  • No labels