Efficient Family-based Product-Line Analysis based on Adjustable

N-way Program Merging for
Efficient Test Coverage of
Configurable Software
Malte Lochau (TU Darmstadt)
(Joint Work with Dennis Reuling and Johannes Bürdek)
FOSD Meeting 2017
Program Analysis
yes
𝑝𝑝
Software
ModelChecker
πœ‘πœ‘
⊨ 𝒍𝒍𝒍𝒍𝒍𝒍: 𝒙𝒙 β‰₯ π’šπ’š β‡’ 𝒛𝒛 β‰  𝟎𝟎 ?
?
no
Counter-Example:
𝒙𝒙 = 𝟎𝟎, π’šπ’š = 𝟎𝟎, 𝒛𝒛 = 𝟎𝟎
οƒ˜ Witness for violation
of safety property πœ‘πœ‘
οƒ˜ Test input for test
goal ¬πœ‘πœ‘
Counter-Example Guided Abstraction Refinement
[Clarke et al. 2004]
4
π‘₯π‘₯ < 𝑦𝑦
5
π‘Žπ‘Ž ≔ π‘₯π‘₯
15
𝑧𝑧 ≔ 𝑧𝑧 + 1
𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖 π‘₯π‘₯, 𝑦𝑦, 𝑧𝑧;
𝑖𝑖𝑖𝑖𝑖𝑖 π‘Žπ‘Ž;
π‘₯π‘₯ β‰₯ 𝑦𝑦
7
π‘Žπ‘Ž ≔ 𝑦𝑦
24
π‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œ 𝑧𝑧
Program P
Control-Flow Automaton
(CFA)
4
5
𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑
π‘₯π‘₯ < 𝑦𝑦
15 π‘₯π‘₯ < 𝑦𝑦 ∧ π‘Žπ‘Ž = π‘₯π‘₯
24 π‘₯π‘₯ < 𝑦𝑦 ∧
π‘Žπ‘Ž = π‘₯π‘₯ ∧ 𝑧𝑧24
= 𝑧𝑧0 + π‘Žπ‘Ž
⊨ πœ‘πœ‘
7
π‘₯π‘₯ β‰₯ 𝑦𝑦
15 π‘₯π‘₯ β‰₯ 𝑦𝑦 ∧ π‘Žπ‘Ž = π‘₯π‘₯
24 π‘₯π‘₯ β‰₯ 𝑦𝑦 ∧
π‘Žπ‘Ž = 𝑦𝑦 ∧ 𝑧𝑧24
= 𝑧𝑧0 + π‘Žπ‘Ž
⊨ πœ‘πœ‘
Abstract Reachability Graph
(ARG)
Product-based Product-Line Analysis
Software
ModelChecker
P1
P2
P3
πœ‘πœ‘
P4
P5
P6
𝑦𝑦𝑦𝑦𝑦𝑦
𝑛𝑛𝑛𝑛 (π‘₯π‘₯ = β‹― )
𝑛𝑛𝑛𝑛 (π‘₯π‘₯ = β‹― )
𝑛𝑛𝑛𝑛 (π‘₯π‘₯ = β‹― )
𝑛𝑛𝑛𝑛 (π‘₯π‘₯ = β‹― )
𝑦𝑦𝑦𝑦𝑦𝑦
Family-based Product-Line Analysis
Software
ModelChecker
𝑷𝑷𝑷𝑷 = 𝑳𝑳𝑳𝑳 ∧ 𝑷𝑷𝑷𝑷𝑷𝑷𝑷𝑷
nπ‘œπ‘œ (π‘₯π‘₯ = β‹― )
πœ‘πœ‘
[Apel et al., 2013]
[Bürdek et al., 2015]
Family-based Product-Line Analysis
1
LE
π‘₯π‘₯ < 𝑦𝑦
5
π‘₯π‘₯ β‰₯ 𝑦𝑦
7
π‘Žπ‘Ž ≔ π‘₯π‘₯ π‘Žπ‘Ž ≔ 𝑦𝑦
PLUS
SPL Implementation
𝑧𝑧 ≔ 𝑧𝑧 + π‘Žπ‘Ž
3
18
24
𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖 π‘₯π‘₯, 𝑦𝑦, 𝑧𝑧;
𝑖𝑖𝑖𝑖𝑖𝑖 π‘Žπ‘Ž;
π‘₯π‘₯ > 𝑦𝑦
10
π‘Žπ‘Ž ≔ π‘₯π‘₯
3
GR
π‘₯π‘₯ ≀ 𝑦𝑦
12
π‘Žπ‘Ž ≔ 𝑦𝑦
NOTNEG
𝑧𝑧 βˆ’ π‘Žπ‘Ž β‰₯ 0𝑧𝑧 βˆ’ π‘Žπ‘Ž < 0
5
𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑
𝑓𝑓𝑓𝑓
π‘₯π‘₯ < 𝑦𝑦
𝐿𝐿𝐿𝐿
22
19
π‘Žπ‘Ž ≔ π‘Žπ‘Ž βˆ— (βˆ’1)
𝑧𝑧 ≔ 𝑧𝑧 βˆ’ π‘Žπ‘Ž
π‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œ 𝑧𝑧
Superimposed CFA
MINUS
24 π‘₯π‘₯ < 𝑦𝑦 ∧ π‘Žπ‘Ž = π‘₯π‘₯ ∧ 𝑧𝑧24 = 𝑧𝑧0 βˆ’ 1
𝐿𝐿𝐿𝐿 ∧ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 ∧ ¬NOTNEG
Featured ARG
Challenges
Scalability / Precision Trade-offs
Partial / Incomplete / Evolving SPL Implementations
Product/Family-based SPL Analysis
Product/Family-based Analysis
1
LE
π‘₯π‘₯ < 𝑦𝑦
5
π‘₯π‘₯ β‰₯ 𝑦𝑦
7
π‘Žπ‘Ž ≔ π‘₯π‘₯ π‘Žπ‘Ž ≔ 𝑦𝑦
PLUS
Partial/Evolving/Incomplete
SPL Implementation Artifacts
𝑧𝑧 ≔ 𝑧𝑧 + π‘Žπ‘Ž
𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖𝑖 π‘₯π‘₯, 𝑦𝑦, 𝑧𝑧;
GR
𝑖𝑖𝑖𝑖𝑖𝑖 π‘Žπ‘Ž
3 ;
π‘₯π‘₯ > 𝑦𝑦
10
12
18
24
π‘Žπ‘Ž ≔ π‘₯π‘₯
𝑧𝑧 βˆ’ π‘Žπ‘Ž
β‰₯22
0
π‘Žπ‘Ž ≔ 𝑦𝑦
NOTNEG
𝑧𝑧 βˆ’ π‘Žπ‘Ž
< 019
π‘Žπ‘Ž ≔ π‘Žπ‘Ž βˆ— (βˆ’1)
𝑧𝑧 ≔ 𝑧𝑧 βˆ’ π‘Žπ‘Ž
π‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œπ‘œ 𝑧𝑧
MINUS
(Continuously) Superimposed CFA
N-Way Model-Merging
Given: 𝑁𝑁 input models 𝑀𝑀𝑖𝑖
𝐢𝐢𝐢𝐢𝐴𝐴1
𝐢𝐢𝐢𝐢𝐴𝐴2
𝐢𝐢𝐢𝐢𝐴𝐴3
𝐢𝐢𝐢𝐢𝐴𝐴4
𝐢𝐢𝐢𝐢𝐴𝐴5
Find: a correct and good family model 𝑀𝑀
𝐢𝐢𝐢𝐢𝐴𝐴6
𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝐢𝐢𝐢𝐢𝐢𝐢
Compare, …
[Rubin and Chechik, 2013]
𝑁𝑁-tuple t = 𝑒𝑒1 , … , π‘’π‘’π‘˜π‘˜ ∈ 𝑇𝑇, 1 ≀ π‘˜π‘˜ ≀ 𝑁𝑁,
such that no two elements belong to the
same input model
?
?
?
𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 ∢ 𝑇𝑇 β†’ [0,1]
?
?
?
…, Match, …
[Rubin and Chechik, 2013]
Subset 𝑇𝑇 β€² βŠ† 𝑇𝑇 is a (complete) match iff each model
element occurs in exactly one 𝑁𝑁-tuple 𝑑𝑑 ∈ 𝑇𝑇𝑇
Match 𝑇𝑇𝑇 is minimal iff for every match 𝑇𝑇𝑇𝑇 it holds
that βˆ‘ 𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 𝑑𝑑𝑑 β‰₯ βˆ‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘(𝑑𝑑𝑑𝑑)
𝑑𝑑 β€² ∈ 𝑇𝑇𝑇
𝑑𝑑 β€²β€² ∈ 𝑇𝑇𝑇𝑇
… and Merge
[Rubin and Chechik, 2013]
Compose 𝑁𝑁 models into one by integrating matched
elements
Compare/Match/Merge has Problems
Three hard problems to be solved at once
1. Enumerate 𝑁𝑁-tuples: β€žcombinatorial explosionβ€œ
2. Compare locations: β€žpath explosionβ€œ
3. Find minimal match: β€žknapsack problemβ€œ
Configuration information is not preserved
Match/merge may produce ill-formed models as
model elements are untyped
Metrics for measuring quality of merging results?
Location Prepartitioning
l
l
l
Group similar locations with…
same type (initial, termination, sequence, branch, …)
at least one equally labeled incoming edge
similar block nestings
=> Parameter: Minimum Group Size (MGS)
Incremental Location Matching
…
l
lβ€˜
l
lβ€˜
l
lβ€˜
…
…
Match grouped locations
Combination of depth-first and bredth-first traversal
Interleaved with randomized matching attempts
=> Parameter: Minimum Tuple Size (MTS)
Merging with Variability Encoding
𝑝𝑝𝑖𝑖
π‘π‘π‘˜π‘˜
𝑝𝑝𝑗𝑗
a
c
b
a
c
𝑑𝑑𝑑
𝑑𝑑𝑑𝑑
a
𝑑𝑑𝑑𝑑𝑑
c
𝑑𝑑𝑑𝑑𝑑𝑑
b
c
c
(𝑝𝑝𝑖𝑖 ∨ 𝑝𝑝𝑗𝑗 )
¬(𝑝𝑝𝑖𝑖 ∨ 𝑝𝑝𝑗𝑗 )
a
b
c
c
Evaluation Results for BusyBox
MFB /
Model Size
Reduction Factor
CPU Time
Speedup Factor
Test Suite Size
Reduction Factor
CbC
2.2 – 3.3
1.3 – 3.3
1.3 – 2.8
SPLFB
0.5 – 0.7
0.5 – 0.8
0.2 – 0.5
Thank You!