Package qm :: Package test :: Package classes :: Module dg_test :: Class DGTest
[hide private]
[frames] | no frames]

Class DGTest

source code

         object --+                
                  |                
extension.Extension --+            
                      |            
      runnable.Runnable --+        
                          |        
                  test.Test --+    
                              |    
   dejagnu_base.DejaGNUBase --+    
                              |    
       dejagnu_test.DejaGNUTest --+
                                  |
                                 DGTest

A 'DGTest' is a test using the DejaGNU 'dg' driver.

This test class emulates the 'dg.exp' source file in the DejaGNU distribution.

Nested Classes [hide private]
  DGException
The exception class raised by 'DGTest'.

Inherited from dejagnu_test.DejaGNUTest: BuildExecutable

Inherited from test.Test: OutcomeField, TestField

Inherited from runnable.Runnable: ResourceField

Inherited from extension.Extension: Type, __metaclass__

Instance Methods [hide private]
 
_RunDGTest(self, tool_flags, default_options, context, result, path=None, default_kind=None, keep_output=None)
Run a 'dg' test.
source code
 
_RunDGToolPortion(self, path, tool_flags, context, result)
Perform the tool-running portions of a DG test.
source code
 
_RunDGExecutePortion(self, file, context, result)
Perform the executable-running portions of a DG test.
source code
 
_ExecuteFinalCommand(self, command, args, context, result)
Run a command specified with 'dg-final'.
source code
 
_PruneOutput(self, output)
Remove unintersting messages from 'output'.
source code
 
_RunTool(self, path, kind, options, context, result)
Run the tool being tested.
source code
 
_DGdo(self, line_num, args, context)
Emulate the 'dg-do' command.
source code
 
_DGfinal(self, line_num, args, context)
Emulate the 'dg-final' command.
source code
 
_DGoptions(self, line_num, args, context)
Emulate the 'dg-options' command.
source code
 
_DGbogus(self, line_num, args, context)
Emulate the 'dg-bogus' command.
source code
 
_DGwarning(self, line_num, args, context)
Emulate the 'dg-warning' command.
source code
 
_DGerror(self, line_num, args, context)
Emulate the 'dg-error' command.
source code
 
_DGexcess_errors(self, line_num, args, context)
Emulate the 'dg-excess-errors' command.
source code
 
__ExpectDiagnostic(self, kind, line_num, args, context)
Register an expected diagnostic.
source code
 
_ParseTargetSelector(self, selector, context)
Parse the target 'selector'.
source code

Inherited from dejagnu_test.DejaGNUTest (private): _Error, _GetBuild, _GetSourcePath, _GetTarget, _GetTargetEnvironment, _IsNative, _ParseTclWords, _RecordDejaGNUOutcome, _RunBuildExecutable, _RunTargetExecutable, _SetUp, _Unresolved

Inherited from test.Test: GetTargetGroup, Run

Inherited from runnable.Runnable: GetAttachments, GetDatabase, GetId, __init__

Inherited from extension.Extension: GetClassName, GetExplicitArguments, MakeDomDocument, MakeDomElement, Write, __getattr__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Inherited from dejagnu_base.DejaGNUBase (private): _RecordCommand, _RecordCommandOutput

Class Variables [hide private]
  __dg_command_regexp = re.compile(r"{[ \t]+dg-([-a-z]+)[ \t]+(....
A regular expression matching commands embedded in the source file.
  KIND_PREPROCESS = "preprocess"
  KIND_COMPILE = "compile"
  KIND_ASSEMBLE = "assemble"
  KIND_LINK = "link"
  KIND_RUN = "run"
  keep_output = BooleanField(default_value= False, description= ...
  _default_kind = "compile"
The default test kind.
  __test_kinds = KIND_PREPROCESS, KIND_COMPILE, KIND_ASSEMBLE, K...
The kinds of tests supported by 'dg.exp'.
  __DIAG_BOGUS = "bogus"
  __DIAG_ERROR = "error"
  __DIAG_WARNING = "warning"
  __diagnostic_descriptions = {__DIAG_ERROR: "errors", __DIAG_WA...
A map from dg diagnostic kinds to descriptive strings.

Inherited from dejagnu_test.DejaGNUTest: ERROR, FAIL, KFAIL, KPASS, PASS, RESULT_PREFIX, UNRESOLVED, UNSUPPORTED, UNTESTED, WARNING, XFAIL, XPASS, arguments, dejagnu_outcomes, executable_timeout, outcome_map

Inherited from test.Test: PREREQUISITES_FIELD_ID, kind

Inherited from runnable.Runnable: EXTRA_DATABASE, EXTRA_ID, RESOURCE_FIELD_ID, resources

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_RunDGTest(self, tool_flags, default_options, context, result, path=None, default_kind=None, keep_output=None)

source code 

Run a 'dg' test.

'tool_flags' -- A list of strings giving a set of options to be provided to the tool being tested.

'default_options' -- A list of strings giving a default set of options to be provided to the tool being tested. These options can be overridden by an embedded 'dg-options' command in the test itself.

'context' -- The 'Context' in which this test is running.

'result' -- The 'Result' of the test execution.

'path' -- The path to the test file. If 'None', the main test file path is used.

'default_kind' -- The kind of test to perform. If this value is 'None', then 'self._default_kind' is used.

'keep_output' -- True if the output file should be retained after the test is complete. Otherwise, it is removed.

This function emulates 'dg-test'.

_RunDGToolPortion(self, path, tool_flags, context, result)

source code 

Perform the tool-running portions of a DG test.

Calls '_RunTool' and processes its output.

returns -- The filename of the generated file.

_RunDGExecutePortion(self, file, context, result)

source code 

Perform the executable-running portions of a DG test.

If this is a "run" test, runs the executable generated by the tool and checks its output.

_ExecuteFinalCommand(self, command, args, context, result)

source code 

Run a command specified with 'dg-final'.

'command' -- A string giving the name of the command.

'args' -- A list of strings giving the arguments (if any) to that command.

'context' -- The 'Context' in which this test is running.

'result' -- The 'Result' of this test.

_PruneOutput(self, output)

source code 

Remove unintersting messages from 'output'.

'output' -- A string giving the output from the tool being tested.

returns -- A modified version of 'output'. This modified version does not contain tool output messages that are irrelevant for testing purposes.

_RunTool(self, path, kind, options, context, result)

source code 

Run the tool being tested.

'path' -- The path to the test file.

'kind' -- The kind of test to perform.

'options' -- A list of strings giving command-line options to provide to the tool.

'context' -- The 'Context' for the test execution.

'result' -- The QMTest 'Result' for the test.

returns -- A pair '(output, file)' where 'output' consists of any messages produced by the compiler, and 'file' is the name of the file produced by the compilation, if any.

_DGdo(self, line_num, args, context)

source code 

Emulate the 'dg-do' command.

'line_num' -- The line number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGfinal(self, line_num, args, context)

source code 

Emulate the 'dg-final' command.

'line_num' -- The line number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGoptions(self, line_num, args, context)

source code 

Emulate the 'dg-options' command.

'line_num' -- The line number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGbogus(self, line_num, args, context)

source code 

Emulate the 'dg-bogus' command.

'line_num' -- The number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGwarning(self, line_num, args, context)

source code 

Emulate the 'dg-warning' command.

'line_num' -- The number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGerror(self, line_num, args, context)

source code 

Emulate the 'dg-error' command.

'line_num' -- The number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_DGexcess_errors(self, line_num, args, context)

source code 

Emulate the 'dg-excess-errors' command.

'line_num' -- The line number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

__ExpectDiagnostic(self, kind, line_num, args, context)

source code 

Register an expected diagnostic.

'kind' -- The kind of diagnostic expected.

'line_num' -- The number at which the command was found.

'args' -- The arguments to the command, as a list of strings.

'context' -- The 'Context' in which the test is running.

_ParseTargetSelector(self, selector, context)

source code 

Parse the target 'selector'.

'selector' -- A target selector.

'context' -- The 'Context' in which the test is running.

returns -- For a 'target' selector, 'S' if this test should be run, or 'N' if it should not. For an 'xfail' selector, 'F' if the test is expected to fail; 'P' if if not.

This function emulates dg-process-target.


Class Variable Details [hide private]

__dg_command_regexp

A regular expression matching commands embedded in the source file.

Value:
re.compile(r"{[ \t]+dg-([-a-z]+)[ \t]+(.*)[ \t]+}[^}]*$")

keep_output

Value:
BooleanField(default_value= False, description= """True if the output \
file should be retained
        after the test is complete.  Otherwise, it is removed.""")

_default_kind

The default test kind.

This value can be overridden by a 'dg-do' command in the test file.

Value:
"compile"

__test_kinds

The kinds of tests supported by 'dg.exp'.

Value:
KIND_PREPROCESS, KIND_COMPILE, KIND_ASSEMBLE, KIND_LINK, KIND_RUN

__diagnostic_descriptions

A map from dg diagnostic kinds to descriptive strings.

Value:
{__DIAG_ERROR: "errors", __DIAG_WARNING: "warnings", __DIAG_BOGUS: "bo\
gus messages", "build": "build failure",}