# Linear code sequence and jump

Linear code sequence and jump (LCSAJ), in the broad sense, is a software analysis method used to identify structural units in code under test. Its primary use is with dynamic software analysis to help answer the question "How much testing is enough?". Dynamic software analysis is used to measure the quality and efficacy of software test data, where the quantification is performed in terms of structural units of the code under test. When used to quantify the structural units exercised by a given set of test data, dynamic analysis is also referred to as structural coverage analysis.
In a narrower sense, an LCSAJ is a well-defined linear region of a program's code. When used in this sense, LCSAJ is also called JJ-path, standing for jump-to-jump path.

## History

The LCSAJ analysis method was devised by Professor Michael Hennell in order to perform quality assessments on the mathematical libraries on which his nuclear physics research at the University of Liverpool depended. Professor Hennell later founded the Liverpool Data Research Associates (LDRA) company to commercialize the software test-bed produced for this work, resulting in the LDRA Testbed product.
Introduced in 1976, the LCSAJ is now also referred to as the jump-to-jump path (JJ-path). It has also been called Liverpool's Contribution to Silly Acronyms and Jokes.

## Definition and characteristics of LCSAJ as a code region

An LCSAJ is a software code path fragment consisting of a sequence of code (a linear code sequence) followed by a control flow Jump, and consists of the following three items:
* the start of the linear sequence of executable statements
* the end of the linear sequence
* the target line to which control flow is transferred at the end of the linear sequence.
Unlike (maximal) basic blocks, LCSAJs can overlap with each other because a jump (out) may occur in the middle of an LCSAJ, while it isn't allowed in the middle of a basic block. In particular, conditional jumps generate overlapping LCSAJs: one which runs through to where the condition evaluates to false and another that ends at the jump when the condition evaluates to true (the example given further below in this article illustrates such an occurrence). According to a monograph from 1986, LCSAJs were typically four times larger than basic blocks.
The formal definition of a LCSAJ can be given in terms of basic blocks as follows:
   a sequence of one or more consecutively numbered basic blocks, p, (p+1), ..., q, of a code unit, followed by a control flow jump either out of the code [unit] or to a basic block numbered r, where r≠(q+1), and either p=1 or there exists a control flow jump to block p from some other block in the unit. (A basic block to which such a control flow jump can be made is referred to as a target of the [LCSAJ] jump.)
According to Jorgensen's 2013 textbook, outside Great Britain and ISTQB literature, the same notion is called DD-path.

## Test effectiveness ratio

Coverage analysis metrics are used to gauge how much testing has been achieved. The most basic metric is the proportion of statements executed, Test Effectiveness Ratio 1 (TER1):
$TER_{\text{1}}={\frac {\text{number of statements executed by the test data}}{\text{total number of executable statements}}}$
Higher level coverage metrics can also be generated, in particular:
$TER_{\text{2}}={\frac {\text{number of control-flow branches executed by the test data}}{\text{total number of control-flow branches}}}$
$TER_{\text{3}}={\frac {\text{number of LCSAJs executed by the test data}}{\text{total number of LCSAJs}}}$
These metrics satisfy a pure hierarchy, whereby when TER3 = 100% has been achieved it follows that TER2 = 100% and TER1 = 100% have also been achieved.
Both the TER1 & TER2 metrics were in use in the early 1970s and the third dates from the late 1970s. The requirement for achieving TER1 = 100% was the level originally selected for the DO-178 avionics standard until it was supplemented by the MCDC (modified condition/decision coverage) additional requirement in 1992. Higher levels TER3 = 100% have been mandated for many other projects, including aerospace, telephony, and banking. One practical problem of using TER3 is that many LCSAJs can never be executed due to the conflicting conditions they contain.

## Example

Consider the following C code:
From this example it can be seen that the basic block identified by an LCSAJ triple may span a decision point, reflecting the conditions that must be in place in order for the LCSAJ to be executed. For instance, LCSAJ 2 for the above example includes the while statement where the condition (count < ITERATIONS) evaluates to true.
Each line of code has an LCSAJ 'density' associated with it; line 17, for instance, appears within 6 unique LCSAJs - i.e. it has an LCSAJ density of 6. This is helpful when evaluating the maintainability of the code; If a line of code is to be changed then the density is indicative of how many LCSAJs will be affected by that change.
A coverage level of TER3 = 100% would be achieved when the test data used causes the execution of each of these LCSAJs at least once.