[Top] [Prev] [Next] [Index] [TOC]


Chapter 6

ATAC: Executing Software Tests

When a program that has been compiled with ATAC is executed, in addition to its normal output, it generates coverage information that is appended to a trace file. The information within this file is later used by ATAC and ATAC to produce coverage displays and reports. This chapter discusses how to manipulate the trace file and identifies problems that might occur during test execution.


6.1 Naming the Trace File

By default, execution of a program compiled with ATAC creates the trace file prog.trace in the current directory, where prog is the name of the executable program under test. The name of this executable is specified to the ATAC compiler using the appropriate command-line option (see Section 5.1.1, Basic Instrumentation (UNIX) or Section 5.2.1, Basic Instrumentation (Windows)). If left unspecified, the executable created is named a.out and the trace file is named a.out.trace. If the executable file is later renamed, the name of the trace file to which it appends information at run-time remains unchanged. However, the name of this file name can be overridden by setting the ATAC_TRACE environment variable to the desired trace file name before the next test is executed.

An ATAC trace file name ends with the extension .trace. If this extended name is not specified and the ATAC_TRACE environment variable is set, .trace will automatically be appended to the name set in the ATAC_TRACE environment variable. The trace file name may not begin with a hyphen.

The trace file may be written in a directory other than the current directory by setting the ATAC_DIR environment variable with a path to the desired directory. ATAC_DIR may be set to either an absolute or relative path.

6.2 Trace File Compression

When a test case is run on a program instrumented with ATAC, trace information is collected in a temporary trace file. A reference to this temporary trace file is appended to the ``master'' trace file. By default, ATAC compresses the trace file after each test execution.To save execution time at the expense of some disk space, automatic trace compression can be disabled by setting the environment variable ATAC_COMPRESS to no prior to program execution. In addition, the frequency of compression can be set to approximately every n files by setting the value to an integer, n. To restore automatic trace compression after each test execution, unset the ATAC_COMPRESS environment variable or set it to yes. (See Section 4.1.2, ATAC_COMPRESS). It should be noted that the compressed trace file format used by ATAC is not the same as that used by general purpose file compression tools.

6.2.1 Forcing Trace File Compression

Whenever the ATAC_COMPRESS environment variable is set to no, it is advisable to periodically force trace file compression between test executions. This will prevent the trace file from growing too large.

In addition, if the nature of a program or a set of tests is such that many executions exit abnormally (e.g., via receipt of a signal), the trace file may not be compressed prior to program exit. In this case, trace file compression should periodically be forced even if ATAC_COMPRESS has not been set.

If invoked with a .trace file as it's argument, the atactm command performs trace file compression (see Section 7.8, Concerning Trace File Compression). This offers a simple way to force trace file compression, regardless of whether or not the ATAC_COMPRESS environment variable is set. For example, invoking atactm as follows:

	prompt:> atactm wordcount.trace
forces the compression of wordcount.trace.

6.3 Temporary Trace Files

The temporary trace file is normally created in the /usr/tmp directory. This can be overridden by setting the ATAC_TMP environment variable before linking or running the instrumented program. On some systems performance will suffer if the temporary trace file is written to an NFS mounted file system.

The temporary trace file will not be incorporated into the master trace file if:

The temporary trace file will be automatically incorporated into the master trace file except under the conditions listed above.

6.4 Trace File Locking

A trace file must be locked to prevent concurrent attempts to compress or edit the trace file (e.g. with atactm) and to permit the graphical interface to process concurrent trace file changes efficiently.

The lock is a file in the same directory as the trace file with the same name as the trace file except that the .trace suffix is replaced with .AElock.

If the lock file exists or cannot be created (due to directory permissions), tools that did not create the lock cannot edit or compress the trace file. In addition, if the graphical interface cannot create the lock and test cases are still running, the whole trace file will have to be reread every time the ``Update'' button is selected.

Normally the lock file is automatically deleted by the tool that created the lock. If the tool terminates abnormally, the lock file may not be deleted. The lock file may be deleted manually.

Note that locking is not needed to prevent trace file corruption. If it becomes necessary to ``force'' a lock, due to apparent failure of it's owner, the resulting trace may become incomplete but will not become corrupted.

6.5 Trace File Permission

In the Windows environment, permissions are generally not an issue because of the single-user nature of the setup. If you are working in a multi-user Windows environment, check with your system administrator regarding file security. It is notable that the ownership of a trace file changes to the last user who compressed it.

In the UNIX environment, the master trace file is created with the same read/write permissions for user/group/other as the directory it is created in. Compression will preserve the read/write permissions on the trace file.

Temporary trace files are created with the same permissions as the trace file that points to it.

For example, if the directory the trace file is created in is readable and writable by user and group (0770), the trace file and temporary trace files are created readable and writable by user and group (0660) when a test is run by anyone in the group. The same trace file may be appended and/or compressed by anyone in the group.

If the ATAC_UMASK environment variable is set before linking or execution, it should be set to an octal number from 0 to 0666. The value is used to restrict the permissions on the trace file, e.g. if the directory to contain the trace file has permissions 0775 and ATAC_UMASK is 026 then the trace file is created with permission 0640.

Note that the ownership of the trace file changes to the last one who compressed it. This shouldn't matter as long as the permissions for group or other permit reading and writing.

Note also, that if a directory has the ``sticky bit'' set, files can be deleted from the directory only by the owner (regardless of file and directory permissions). This bit is often set on /tmp and /usr/tmp so that people can't delete each others temporary files even though everybody can write the directory. If this bit is set on the directory where ATAC is putting the temporary trace files, and there are multiple users writing to the same trace file, during compression, some of the temporary trace files will not get deleted. When this happens, atactm truncates the files to size zero to save disk space and as an indication that the file is no longer needed.

6.6 Parallel Test Execution

ATAC supports parallel test execution. When multiple instances of a program instrumented with ATAC are executed in parallel, writing to the same trace file, ATAC will maintain separate trace data for each in the trace file.

6.7 Improving Execution Speed and Saving Disk Space

Programs compiled under ATAC execute more slowly, require more memory, and occupy more disk space than when compiled with the standard C compiler (see Section 3.5, What Will Using ATAC Cost You?). The time required for program execution may be reduced, at a cost of some disk space, by not compressing the trace file between each test execution. If automatic trace file compression is turned off, it is advisable to periodically force compression in order to reduce the size of the trace file (see Section 6.2.1, Forcing Trace File Compression).

The impact of ATAC on execution speed and disk space may also be reduced by limiting the scope of coverage analysis to a subset of the source files in the program under test (see Section 5.1.3, Selectively Instrumenting Software (UNIX) or Section 5.2.3, Selectively Instrumenting Software (Windows)). Using this approach, normal program performance only degrades while executing code within the source files compiled with ATAC. Coverage analysis of an entire software system is obtained by combining the results of executing identical tests on a number of source file subsets, each selectively instrumented in a complementary manner.

If testing is being conducted in a network environment where remote file systems are being accessed from a file server, execution time may also be reduced by directing the trace file to a file on a local disk (see Section 6.1, Naming the Trace File). This eliminates network file access time when writing to the trace file. If ATAC_TMP is set, it should also point to a directory on a local disk (see Section 4.1.6, ATAC_TMP).

Execution time may also be reduced by restricting the amount of detail in the coverage data. In particular, if only block coverage data is needed, execution time may be reduced by setting ATAC_BLOCKONLY to yes (see Section 4.1.1, ATAC_BLOCKONLY).

Under certain circumstances, there may be a section of code for which normal execution speed is critical, even at the cost of missing coverage data. If these sections are identified, ATAC will omit instrumentation in them. These sections will be counted as code that has not been covered. To identify code for which normal execution speed is critical, insert the word TIMECRITICAL in a comment preceding the section of code. After the section of code, insert the word NOTTIMECRITICAL in a comment. For example the play_audio function that follows must copy audio data to the output device as fast as possible to avoid gaps in the sound.

  	play_audio(file_in, audio_out)
	{  int	 n;
	   char  *buf[8000];
	   while (1) {
		/* TIMECRITICAL */
		while (buf_level(audio_out) < HIGH_WATER){
		       n = read(file_in, buf,8000);
		       if (n == 0)
		           return;
		       write(audio_out, buf, n);
		       }
		       /* NOTTIMECRITICAL */
	  	       usleep(100000);
		}
	}

To omit these sections from the ATAC summary counts and coverage displays, use the atac -Y option. To count or view only these sections use the atac -mY option.

6.8 Explaining Run-Time Errors

A program compiled with ATAC should exhibit behavior identical to the same program compiled with the standard C compiler, with the following exceptions:



[Top] [Prev] [Next] [Index] [TOC]