Cheney的个人博客

Software Reliability 笔记

2022-01-29 · 4 min read

Glass-box Testing

Three Types of Coverage Model

  1. Control Flow
    1. Model the flow of control
    2. Examples: node coverage, edge coverage
  2. Logic
    1. Analyse the influence of all Boolean variables
    2. Examples: predicate coverage, clause coverage, MCDC (FAA DO178B)
  3. Data Flow
    1. Measure the flow of data between variable assignments (writes) and variable references (reads).
    2. Examples: all-definitions, all-uses

Test Requirements

  • Generated by a coverage model
  • Easy to measure coverage

Condensation Graph

A node is either an Assignment block or a Boolean condition.

Satisfying a Coverage Model

Type 1: Control Flow

Node Coverage (NC)

Each reachable path p of length 1 in G is a test requirement.
覆盖每个点

Edge Coverage (EC)

Each reachable path p of length 2 in G is a test requirement.
覆盖每条边

Edge-Pair Coverage (EPC = EC2)

Each reachable path p of length <= 3
每种path可能性(2个if串联就有2*2=4种可能性)

Prime Path Coverage (PPC)

Each reachable prime path p in G is a test requirement
Prime Path: maximal simple path 最长简单路(除去首尾,中间不能重复)
满足: p cannot be extended without losing simplicity 再长一点就不是simple path

Complete Path Coverage (CPC)

Every reachable path in GG is contained in some path pTRp \in TR.

Type 2: Logic Coverage

  • 重点: Different ways of taking the same branch
  • For logic coverage, a test requirement tr is a logical constraint on input data values

Predicate Coverage (PC)

For each predicate pPp \in P, the set TR contains:

  1. a requirement that implies p is reached and evaluates to true
  2. a requirement that implies p is reached and evaluates to false

Clause Coverage (CC)

  • 比CC粒度更细,每个clause都要为true或false(这里clause指atomic表达式)
  • PC和CC互相independent(可能一个满足一个不满足)

Combinatorial Coverage (CoC)

For each predicate pPp \in P, and every possible truth assignment α\alpha to the clauses Cp of p the set TR contains a requirement which implies p is reached and the clauses evaluate to α\alpha.

Active Clause Coverage (ACC)

For each predicate pPp \in P and each clause cCpc \in C_p which determines p (under some α\alpha), the set TR contains two requirements for c: c is reached and evaluates to true, and c is reached and evaluates to false.

  • Determination: 在一个predicate里只改变一个clause,predicate的值被改变
  • 通过Truth Table可以找出determination
  • Problems of masking, logical overlap and side-effects

General Active Clause Coverage (GACC)

  • ACC的定义加上: The values chosen for the other clauses dCpd \in C_p , dcd \neq c, need not be the same in both cases.
  • 先找到determination,但是其他的clauses的赋值要不一样

Restricted Active Clause Coverage (RACC)

  • ACC的定义加上: The values chosen for the other clauses dCpd \in C_p , dcd \neq c, must be the same in both cases.
  • 先找到determination,但是其他的clauses的必须一样
  • Problem: 可能不满足PC,难以处理synonyms

Correlated Active Clause Coverage (CACC)

  • ACC加上: The values chosen for the other clauses dCpd \in C_p , dcd \neq c, must cause p to be true in one case and false in the other.
  • 其他clauses可以变,但整个predicate至少能为true或者false

Type 3: Data Flow

• A definition of a variable v is any statement that writes to v in memory
• A use of v is any statement that reads v from memory.

All-defs Coverage (ADC)

See slides.

All-uses Coverage (AUC)

See slides.

All-du-paths Coverage (ADUPC)

See slides.