• No results found

Evolutionary Approach to Coverage Testing of IEC Function Block Applications

N/A
N/A
Protected

Academic year: 2021

Share "Evolutionary Approach to Coverage Testing of IEC Function Block Applications"

Copied!
25
0
0

Loading.... (view fulltext now)

Full text

(1)

Evolutionary Approach to Coverage Testing of

IEC 61499 Function Block Applications

Igor Buzhinsky,

Vladimir Ulyantsev, Jari Veijalainen, Valeriy Vyatkin

[email protected]

INDIN 2015, Cambridge, UK

(2)

Introduction

I Control software for industrial automation systems

I IEC 61499 – a standard for distributed control systems which

supports modularity

I Testing is one of the ways to ensure system correctness and

safety

I Automatic test suite generation

I Optimization goal: coverage of the implementation

(3)

Black-box and white-box testing

I Model-based testing is a black-box approach based on

requirements

I The model of the requirements and the implementation are

independent

I White-box testing is based on implementation instead

I What if a short requirement has a complex implementation

with many branches? – WB testing should be more effetive

I What if some requirements are not implemented at all? – only

(4)

Function blocks (FBs)

I Interface: event and data inputs and outputs

I FBs have state and behaviour

I Two types: basic (based on execution control charts, ECCs)

(5)

Function blocks as systems under test

I Each test represents a number of execution steps

I On each step, the FB receives an event and data (variable

values) associated with it

I Each step also triggers some measurable output

(6)

Tests and test suites

I A test is defined as a sequence of inputs; outputs are not considered and are not needed for coverage optimization

I Test example:

Event BOOL_VAR INT_VAR

E3 true

E1

E2 false -100

E2 false 42

I A test suite is a number of tests

I The goal of the research is to design a method which

(7)

Coverage criteria

In general, coverage determines the share of the system which is executed at least once when all tests are run

For basic FBs:

I transition coverage of underlying ECCs

I branch coverage of the code generated from the FB

For composite FBs:

I aggregated measures of nested basic FBs

Coverage criteria can be viewed as percentage values (e.g. 50% transition coverage means that half of transitions were executed)

(8)

Transition coverage example (1)

(9)

Transition coverage example (2)

(10)

Transition coverage example (3)

(11)

Transition coverage example (4)

(12)

Evolutionary computation: basic ideas

I General optimization methodology for both discrete and

continuous problems

I One needs to define a representation of solutions (individuals)

I E.g. a list of tests, where a test is a list of (event, data) pairs

I A fitness function evaluates the individuals

I E.g. the coverage percentage according to a given criterion

I Evolutionary operators (e.g. mutation, crossover) modify the

solutions

I Many algorithms (e.g. the genetic algorithm) with a common

(13)

Test suite optimization problem and its solution

I An FB to test (system under test) and a coverage criterion

(fitness function) are defined

I Test suites (individuals) are evolved according to some particular evolutionary algorithm

I If a test suite with 100% coverage is found, the algorithm is stopped

I In not, the algorithm can still stop after several unsuccessful iterations

(14)

Method scheme

I An FB is transformed to source code, and then software for

coverage-based unit test generation is applied

Function block (.fbt) Source code (Java) Test suites (JUnit) 1. FBDK execution 3. EvoSuite execution Adjusted source code (Java) 2. Source transformations

(15)

Stage 1: FBDK execution

I FBDK is an FB development environment

I It can transform FBs into Java code

I I.e. there are variable and event declarations, methods for algorithms and events

(16)

Stage 2: Source transformations

I Mostly technical, not very important

I To prepare the code for EvoSuite

I Some method visibility adjustments

(17)

Stage 3: EvoSuite execution

I A tool which generates JUnit coverage test suites for Java code

I EvoSuite implements the steady-state genetic algorithm (and

some others, but these options were not considered)

I The whole test suite is an individual

I 10 minutes of evolutionary search for basic FBs

(18)

Tests as code

Event BOOL_VAR INT_VAR

E3 true

E1

E2 false -100

E2 false 42

ExampleFB fb = new ExampleFB(); fb.service_E3(true);

fb.service_E1();

fb.service_E2(false, -100); fb.service_E2(false, 42);

(19)
(20)
(21)

Results: coverage values

Coverage value statistics for 43 basic and 18 composite FBs from the PnP and HPP systems

FB type, coverage criterion Min First quartile Median Third quartile Max Basic, branch 60.0% 88.3% 92.6% 94.8% 98.8% Composite, branch 35.4% 79.5% 84.5% 91.0% 94.8% Basic, transition 55.6% 100.0% 100.0% 100.0% 100.0% Composite, transition 5.7% 92.0% 100.0% 100.0% 100.0%

(22)

Results: found faults

I Badly written ‘if’ decisions, which made algorithm branches

inaccessible in two basic FBs

I A forgotten update of an internal variable, which made several

states of an ECC inaccessible

I Missing connections in a composite FBs

(23)
(24)

Future work

I Exact solution of the problem (under several assumptions):

I Symbolic (dynamic) execution and constraint satisfiability I Coverage of net/condition event systems (NCES) using formal

verification

I Does white-box test generation indeed complement

model-based testing?

I Adding restrictions on possible tests to prevent unrealistic ones

I Manual implementation of the evolution and the FB

(25)

Questions

Thank you for your attention!

Questions?

Evolutionary Approach to Coverage Testing of IEC 61499 Function Block Applications

Igor Buzhinsky,

Vladimir Ulyantsev, Jari Veijalainen, Valeriy Vyatkin [email protected]

References

Related documents