CS 585 Homework 4 (3rd one assigned)
Spring 2011
Graph Coverage: Due 3/24/11
What you discover on your own is always more exciting
than what someone else discovers for you - it's like the difference between
romantic love and an arranged marriage.
- Terrence Rafferty
Answer the following questions. Bring hardcopies of your answers to class,
hand written or printouts. All homeworks are due before class on the due
date. Please remember that the UK Honor Code is in effect: Each student is
expected to work alone and you may not share solutions or solution ideas.
- (15 pts) Coverage tool
experience. Download an evaluation copy (7 days, free) of Rational
Software's PurifyPlus (Unix)
(Windows)
product. You may also try the open source tool Emma (Emma). Use the software to apply the node coverage criterion to the Java
program stutter.java.
This program looks for repeated repeated words in text files (a frequent
problem in my writing).
Turn in a listing of the tests you ran to achieve
coverage. You should identify any code that you are unable to cover, and
explain why it is not covered.
- (10 pts) Consider the
following program fragment:
3. w = x; // node 1
4. if (m > 0)
5. {
6. w++; // node 2
7. }
8. else
9. {
10. w=2*w; // node 3
11. }
12. if (y <= 10) // node 4
13. {
14. x = 5*y; // node 5
15. }
16. else
17. {
18. x = 3*y+5; // node 6
19. }
20. z = w + x; // node 7
- Draw a control flow graph
for this program fragment. Use the node numbers given above.
- Which nodes have defs
for variable w?
- Which nodes have uses
for variable w?
- Are there any du-paths
with respect to variable w from node S1 to node S7? If not, explain why
not If there are any, show one.
- Enumerate all of the
du-paths for variables w and x.
- (10 pts) Use the stutter.java
program again to answer the following questions.
- Identify all the call
sites (you will have to number a version of stutter.java)
- Extra credit (5 pts):
Create test data to satisfy a Coverage Criterion of your choosing (besides Node coverage, you already did that) for stutter.
Measure the statement coverage of those tests using your selected coverage tool. [For example, you may choose edge coverage or All-uses.
You will create test data to satisfy edge coverage or All-uses, then you will measure the statement coverage of your tests.]
© Paul Ammann
and Jeff Offutt, 2003, all rights reserved. This document is made available for
use by GMU graduate students of SWE 637. Copying, distribution or other use of
this document without express permission of the author is forbidden. You may
create links to pages in this web site, but may not copy all or part of the
text without permission of the author.