Anda di halaman 1dari 5

CS 5387 Software V&V

Spring 2012 Exam 1

ID # _______________

1. The resources available for the student to use during this exam consist of the course text book, Foundations of Software Testing, by Aditya Mathur, any lecture notes taken by the student during lecture, any homework or programming assignment completed by the student, the course web page: www.cs.utep.edu/sroach/S12-5387, papers assigned in class (e.g., the NIST report), and the course instructor, Dr. Steve Roach. 2. Unless otherwise explicitly stated in the problem, the student may not refer to or utilize any resource not explicitly listed in item 1. Disallowed resources include other UTEP students, students at other institutions, other faculty either at UTEP or elsewhere, information posted on the World Wide Web or other Internet-available resources, or other books, journal articles, or publications. 3. The student may not discuss the exam or any part of the exam with anyone other than the instructor until after all of the exams have been handed in for grading. Students must neither initiate nor participate in discussions about the exam with anyone other than the instructor. This includes discussing the difficulty of the exam or whether the student has completed the exam. In this context, the term discuss refers to any communication, written, electronic, verbal, or nonverbal. 4. The student agrees to contact the instructor to discuss any part of the exam with which the student has difficulty prior to turning in the exam. 5. The exam must be turned in electronically by 11:59 PM on March 14, 2012. Exams not turned in at that time will not be graded unless prior approval has been granted by the instructor. 6. Violation of any of these terms will be considered academic dishonesty and will result in disciplinary action administered by the Dean of Students.

1. (15 points) Suppose that we have two FSMs, M1 and M2, that compute functions f1 and f2. Now suppose that we want to compute f2(f1(x)), the composition of the two functions. The input alphabet of M2 must be the same as the output alphabet of M1. The output of f1 is used as the input to f2. We can create a new machine M* from M1 and M2 as follows: Let M1 = (X, Y, Q1, q10, d1, O1) M2 = (X, Y, Q2, q20, d2, O2) M* = (X, Y, Q*, q*0, d*, O*)

1|Page

CS 5387 Software V&V

Spring 2012 Exam 1

ID # _______________

Q* = xQ1 x Q1, the cross product of the states of M1 and M2. Label these states with the names of both states. Thus, if M1 has states a and b, and M2 has states c and d, M* has states ac, ad, bc, and bd. The initial state of M* is the state that is labeled q10 q20. The output function O* is derived for each state q1 q2 , and each input symbol i in X as follows. Find the output o for state q1 in M1 using the input symbol i. Find the output of q2 in M2 using o. This is the output for M* for state q1 q2 using the input symbol i. The state transition function d* is derived for state q1 q2 and input i. d*( q1 q2 , i) => q1*q2* q1* is the same label as d1(q1,i), the next state from machine M1 starting at state q1 and given input i. q2* is the same label as d2(q2, O1(q1,i)), which is the label of the next state in M2 when starting in state q2 and receiving the input generated by the transition in M1. Example:
M1 CURRENT INPUT A B M2 CURRENT INPUT C D M* CURRENT INPUT AC BC AD BD

OUTPUT 0 1 1

1 0 1

NEXT 0 A B

1 B A

OUTPUT 0 0 1

1 0 0

NEXT 0 D D

1 C C

OUTPUT 0 0 0 0 0

1 0 0 1 0

NEXT 0 AC BC AC BD

1 BD AC BD AC

(a) Show that M* computes the same function as M1 composed with M2. That is, show that for every input to M1, M* computes the same string as M2 computes when using the output of M1 as input. (b) Prove either of the following (but not both): If M1 and M2 are minimal, then M* is guaranteed to be minimal. If M1 and M2 are minimal, then M* is not guaranteed to be minimal.

2|Page

CS 5387 Software V&V

Spring 2012 Exam 1

ID # _______________

2. (5 points) Why is a specification needed to show correctness? 3. (5 points) Whats an oracle? Why is it important in testing? 4. (10 points) In the following scenario, identify the fault, the failure, the error. A beginning programmer wrote simple Java code for a linked list. The code is shown on the last page of this exam. The intent is to take an unbounded sequence of integers as input and store them in a linked list. (I removed the file I/O to simplify reading the code.) The hardcoded sequence of integers is 1, 2, 3, and 4. The output generated is 0 1 2 3 4. (You may use a java compiler and virtual machine to compile and execute this program.) 5. (10 points) Using between 100 and 300 words, compare and contrast two software tools for user interface testing. (You may utilize the WWW to research software tools if needed.) 6. (10 points) Using between 100 and 300 words, compare and contrast two software tools for testing distributed systems. (You may utilize the WWW to research software tools if needed.) 7. (10 points) In his paper, Whittaker, suggests four reasons for users to discover bugs in extensively tested software. These are: The user executed untested code. The order in which statements were executed in actual use differed from that during testing. The user applied a combination of untested input values. The users operating environment was never tested. For each of these, (a) explain how (recalling the competent programmer hypothesis) the situation might reasonably occur (give an example) and (b) explain what process your development team might use to improve your testing processes to avoid these errors in delivered code. Note that you have limited testing resources. You will not be able to simply expand the time and effort your team spends on testing. 8. (15 points) A sales person sells widgets, grommets, and blivets. Widgets are $45 each; grommets are $30 each; and blivets are $25 each. Production limits cap the sales at no more than 70 widgets, 80 grommets, and 90 blivets per month. The sales persons commission is computed at 10% of sales up to and including $1000, 15% on the next $800, and 20% on sales in excess of $1800. The commission program takes the number of widgets, grommets, and blivets sold in a month as input and produces the commission amount as output. Design a test set for this software using equivalence class and boundary value analysis.

9. (10 points) Given the predicate P = ((r < 10) && ((q!= 0) || flag)), where flag is a Boolean value and r and q are integers, generate the BOR, BRO and BRE adequate test sets.

3|Page

CS 5387 Software V&V

Spring 2012 Exam 1

ID # _______________

10. (20 points) The FSM below represents a simple 2-story elevator controller. The table indicates the next state. The output from any given state is the label of the next state (thus, the output is just a sequence of state labels). The elevator is not smart: as a user, you have to tell the elevator to open and close the door. The arrive input is generated by the system when the elevator arrives at the requested floor. a) Construct minimal test sets for this FSM that meet state, transition, switch, and boundary interior test criteria. b) Use the W method to develop a test set for this system. c) Suppose your software will be extended to use in the elevator system for the Burj Khalifa in Dubai, which has 160 stories. Extend the FSM to cover this situation. (Hint: While you could create a FSM with over 25,000 states to model this software, that might take you a long time to draw and a long time for me to read, which will not improve your grade. You could instead use what you learned in chapter 2 of the text to keep the number of states low. My solution has fewer than a dozen states.) d) For the FSM in part c, give a minimal boundary interior test set.

(Extra Credit) Explain why, after thorough testing, when your software is installed in the Burj Khalifa, your engineering team will still need to test that the elevator stops, opens, and closes doors at every floor. CURRENT BottomClosed BottomOpen MovingDown MovingUp TopClosed TopOpen Open BottomOpen BottomOpen MovingDown MovingUp TopOpen TopOpen Close BottomClosed BottomClosed MovingDown MovingUp TopClosed TopClosed Up MovingUp BottomOpen MovingDown MovingUp TopClosed TopOpen Down BottomClosed BottomOpen MovingDown MovingUp MovingDown TopOpen Arrive

BottomClosed TopClosed

4|Page

CS 5387 Software V&V package sorting;

Spring 2012 Exam 1

ID # _______________

public class Node { static int nodeCounter = 0; int value = 0; Node next = null; Node(){ nodeCounter++; } public int getValue() { return value; } public void setValue(int v) { value = v; } public void printnode(){ System.out.print(this.value); if (this.next != null){ this.next.printnode(); } } public static void main(String[] args){ int[] input = {1,2,3,4}; Node head = null; For (int index=0; index<input.length; index++) { Node thing = new Node(); thing.setValue(input[index]); if (head == null){ head = thing; head.next = null; // problem here? head.value = 0; } if (head != null){ // problem here? Node lastNode = head; while (lastNode.next != null){ lastNode = lastNode.next; } lastNode.next = thing; } } head.printnode(); } }

5|Page