Lecture 2-Control flow Flashcards

1
Q

What is a program graph?

A

Directed graph in which nodes are statement fragments and edges represent flow of control.

*Statement fragments includes complete statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a Control Flow Graph(CFG)?

A

It models all executions of a method by describing control structures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can we simplify a CFG?

A

By grouping together statements which always execute together–> BASIC BLOCK with 1 entry point and 1 exit point

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the 6 code coverage models(6)?

A

1.Statement coverage(SC)
2.Segment coverage (basic block)
3.Branch coverage(BC)
4.Condition coverage(CC)
5.Branch and condition coverage(BCC)
6.Modified/Decision condition (MC)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is statement coverage?

A

-Achieved when all statements in a method have been executed at least once.
-Most used in industry

SC = # OF EXECUTED STATEMENTS/TOTAL # OF STATEMENTS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Typical statement coverage is 80-90%. Why don’t we aim at 100%? e.g. What are the problems with SC(3)?

A

-Predicate may be tested for only 1 value –>It misses many bugs
-Loop bodies only iterated once
-Statement coverage can be achieved without branch coverage –>important cases may be missed

*Think of the =0 case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is segment coverage?

A

It counts segments rather than statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the problem with segment coverage?

A

It may produce drastically different numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is branch coverage (BC) ?

A

-Achieved when every branch from a node is executed for each predicate.
-At least one true and one false evaluation for each predicate.

BC= # OF EXECUTED BRANCHES/TOTAL # OF BRANCHES

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the problems with BC(3)?

A

-Short circuit evaluation means that many predicates might not be evaluated.
-A compound predicate is treated as a single statement.(if n clauses, 2^n combinations, but old 2 are tested.
-Only a subset of all entry-exit paths is tested.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is condition coverage (CC)(Predicate Coverage)?

A

-It reports the true or false outcome of each condition.
-It measures the condition independently of each other.

CC= # OF CONDITIONS THAT ARE BOTH T AND F/ TOTAL # OF CONDITIONS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are branch and condition coverage (BCC)(Decision coverage)?

A

It is computed by considering both branch and individual condition coverage measures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is modified/decision coverage(MC/DC)?

A

Key idea:
-Test important combinations of conditions and limiting testing costs.–> Each condition should be evaluated one time to TRUE and one time to FALSE and this with affecting the decision’s outcome.
-Often required for the mission-critical systems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do we test nested loops?

A

They must be tested separately starting with the innermost.

*Loops are highly fault-prone.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly