'Function Line' Assurance Targets


Coton Park House
Linton
Swadlincote
Derbyshire
DE12 6RA UK


T: +44(0)1283 763632
F: +44(0)1283 763631



Introduction




Contents

Introduction

Example Function Like SDA - Rolling Average Function

Example Function Like Target - Rolling The Complete Rolling Average SDA

Example Function Like Target - Rolling The main GetRollingAverage() Function

Observation on Function Like Assurance Targets


Functions or procedures are a low level building block in many software systems. Function like targets are targets that are based on function like SDAs where:

  • There are two client service interfaces:
    • Initialisation of static or persistent data when the run-time system initialises the image.
    • A single synchronous calling interface through which they are invoked.
  • Static / persistent data is only modified from within the SDA it does not provide a data interface to the SDA.

Two examples of 'function-like' targets that are illustrated below. They are based on a 'function-like' service delivering assembly. The assembly is described first followed by the two examples of targets that use this assembly.


Example Function Like SDA - Rolling Average Function

The rolling average SDA is an example of a function like SDA. It is illustrated below.

The rolling average function takes a numeric value and returns the mean value of the either:

  • The last 16 samples if more than 16 samples have been supplied.
  • All supplied values if 16 or less samples have been supplied.

The implementation maintains a queue containing all of the samples used in the last mean value. Speed of execution is critical so the implementation maintains an accumulated sum of all the samples in the last mean value.  Calculating the mean involves:

  • If there are already 16 values in the queue then subtracting the oldest sample from the sum and removing it from the queue.
  • Adding the new sample to the sum and placing it in the queue.
  • Dividing the sum by the number of samples to get the new mean.

Four functions GetNumInQueue(), AppendToQueue(), GetAndRemoveHeadOfQueue() and ResetQueue() are used by the main function to manipulate the queue data structure. These functions are shared functions that operate on any declared and initialised instance of the queue data structure, the queue is passed to these functions on invocation.

The rolling average value is critical to the operation of the system and so provision is made to contain any corruption of the queue data structure. If a queue function returns an error or the number of items in the queue does not match the local count or an out of range value is removed from the queue then a recovery action is triggered. The queue and accumulator are reset and the current sample is then processed in the normal manner. A second error during this recovery process halts the system.

The SDA definition for this would be:

SDA Identifier Rolling Average Functions
Services Calculation of rolling average value
Client Interfaces GetRollingAverage()

Run-time initialisation



First Example of a Function Like Target - The complete Get Rolling Average SDA

When the software contains a function that operates like this one the obvious target for testing is the external behaviour of the SDA using the full implementation of all four functions. The Assurance Target would be:

SDA Rolling Average Functions
Behaviour External Operation
Layer Interfaces -
Excluded Software -

Analysis and design of tests for this will focus on the sequence of calls to the main function and the responses to those calls. This is a pure black box test of the rolling average function. It should be noted that this target does not focus analysis on or permit easy testing of the behaviour required to recover from a queue corruption. This recovery action is internal as far as this target is concerned and so really falls outside the scope of the target.



Second Example of a Function Like Target - The main GetRollingAverage() Function

An alternative would be to test the main function addressing both the invocation from the client and the interaction with the queue. Analysis would address what happens at the interfaces to the queue functions as well as at the calling interface. This is illustrated below:

The Assurance Target would be:

SDA Rolling Average Functions
Behaviour External Operation
Layer Interfaces All GetRollingAverage() calls to GetAndRemovedHeadOfQueue()

All GetRollingAverage() calls to GetNumInQueue()

All GetRollingAverage() calls to AppendToQueue()

All GetRollingAverage() calls to ResetQueue()

Excluded Software -

The internal interfaces are now brought into view for the purposes of analysing what the behaviour should be and what tests should be applied to prove that this is the case. This should cause the analysis process to address the corruption recovery behaviour. The queue software is now excluded from the software under test and so can be stubbed / modified to simulate queue corruptions during test execution. This target has more internal interfaces which will generally result in a more detailed analysis of the required behaviour for the software that remains within the target.



Observations on Function Like Assurance Targets

The examples given illustrate the way that the Assurance Target style definition can be used to focus analysis and testing on a particular part of the software. A common pattern of definition has been used in both cases.

It should be noted that if the approach adopted had been to identify 'function' testing within a strategy and the GetRollingAverage() function was selected for 'function' testing then either of the above forms of testing could result. It is likely that the choice would be made by the engineer doing the work rather than the test management process.