A4. Graph Coverage for Design Elements, Use Cases and FSM Specifications, and Logic Coverage

DUE: 11:59PM, Tuesday 28 March 2017

50 points


Objectives

  • The goal of this assignment is to practice problems related to graph coverage and logic coverage.

Tasks

  1. (7 points) Coupling DU-pairs

    Use the following methods carryout and order to answer questions (a)-(c).

    1.  public void carryout(int a)    15. public int order(int x, int y)
    2.  {                              16. {
    3.     int p=1;                    17.    int z=10+x; 
    4.     int q=2;                    18.    int v=y;
    5.     if(a<10)                    19.    if(x>y)
    6.         p=10;                   20.        v=2*z;  
    7.     else if (a>5)               21.    return v;
    8.         q=2*p;                  22. }
    9.     else
    10.        p = 4*p;
    11.    int r = order(p, q);
    12.    System.out.println(r);
    13. }
    

    1. (1 point) Give all call sites using the line numbers given.

    2. (3 points) Give all pairs of last-defs and first-uses.

    3. (3 points) Provide test inputs that satisfy all-coupling-uses. Note that carryout only has one input.


  2. (9 points) Finite State Machines

    A car is in the Stopped or Moving state. For the following question, consider the FSM of the car when it is in the Moving state. The variables to be considered for the Moving state are as follows:

    1. antilockBrakeControl: {FreeWheeling, Braking, Modulating}.
    2. cruiseControl: {Active, Suspended, Off}

    Effectively you will be studying the interaction of the antilock braking control with the cruise control of a car.

    The antilock brake control portion begins in the FreeWheeling state. If brakes are applied (applyBrakes()), the antilock brake control goes to the Braking state and enables a speed sensor. If brakes are released, then the antilock brake control goes back to the FreeWheeling state. In the Braking state, if the speed sensor determines that the car speed exceeds the speed indicated by the axle by calling checkBrakingSpeed(), then the antilock brake control goes to the Modulating state where the modulator is enabled. If the car speed is less than or equal to the axle speed, then the antilock brake control goes back to the Braking state and the modulator is disabled.

    The cruise control portion begins in the Off state. If cruise is engaged by the driver using the engage() method, then the cruise control goes into the Suspended state. The driver can use the disengage method to turn off cruise control. In the Suspended state, the driver can call selectSetPoint() to set the target speed, and the cruise control goes to the Active state. The driver can hit the brakes (applyBrakes()) to go back to the Suspended state. In the Active state, the cruise control checks if the car speed is greater than the set point by calling checkCruiseSpeed. If the actual speed is higher than the set point, the cruise control remains in the active state but the throttle is closed. If the actual speed is lower than the set point, the cruise control remains in the Active state, but the throttle is opened.

    1. (1 point) When the car is moving, how many states are there based on the two state variables? Note that some of the state combinations for the two variables may not be valid, so they shouldn't appear in your FSM.

    2. (4 points) Draw and label the states (with variable values) and transitions (with method names).

    3. (4 points) A test case for the FSM is a sequence of method calls. Provide a test set that satisfies edge coverage on your graph.


  3. (9 points) Use cases
    USPS Automated Postal Center (APC) is a self-service kiosk often found in US postoffice lobbies. They provide an alternative to a full-service counter. If you aren't familiar with APC, you can view youtube videos or actually use an APC!

    1. (5 points) Construct two separate use cases as described in the book for interactions with an APC. Don't try to capture all the functionality of the APC into one graph.

    2. (4 points) Design test cases for your scenarios.


  4. (17 points) Logic Expression Coverage Criteria

    Suppose that predicate p = (a ∨ c) ∧ (b ∨ d) Answer parts (a)-(h) using predicate p.

    1. (1 point) Identify the clauses that go with predicate p.

    2. (2 points) Compute and simplify the conditions under which each of the clauses determines predicate p.

    3. (4 points) Write the complete truth table for all clauses. Label the rows starting from 1. Use the format in the example underneath the definition of combinatorial coverage in Section 3.2 of edition 1, or Section 8.1.1 of edition 2. This will make it easier for us to grade. This will make it easier for us to grade. For example, row 1 should be all clauses true. You should include columns for the conditions under which each clause determines the predicate, and also a column for the predicate itself.

    4. (2 points) Identify all pairs of rows from your table that satisfy general active clause coverage (GACC) with respect to each clause.

    5. (2 points) Identify all pairs of rows from your table that satisfy correlated active clause coverage (CACC) with respect to each clause.

    6. (2 points) Identify all pairs of rows from your table that satisfy restricted active clause coverage (RACC) with respect to each clause.

    7. (2 points) Identify all 4-tuple of rows from your table that satisfy general inactive clause coverage (GICC) with respect ot each clause. Identify any infeasible GICC test requirements.

    8. (2 points) Identify all 4-tuples of rows from your table that satisfy restricted inactive clause coverage (RICC) with respect to each clause. Identify any infeasible RICC test requirements.


  5. (8 points) Structural logic coverage of programs

    Answer parts (a) and (b) for the method leapYear(int year) below.

    public String leapYear(int year) 
    {
        boolean isDivisibleBy4;
        if (year % 4 == 0) // earlier it said x instead of year by mistake
            isDivisibleBy4 = true;
        else
            isDivisibleBy4 = false;
    
        boolean isDivisibleBy4Not100;
        if (isDivisibleBy4 && (year % 100 != 0))
            isDivisibleBy4Not100 = true;
        else
            isDivisibleBy4Not100 = false;
    
        if(isDivisibleBy4Not100 || (year % 400 == 0))
            return "yes";
        else
            return "no";
    }
    
    1. (4 points) Identify test inputs for leapYear() that achieve Restricted Active Clause Coverage (RACC).
    2. (4 points) Identify test inputs for leapYear() that achieve Restricted Inactive Clause Coverage (RICC).


Submission

Type the answers to the above questions in a document called a4.pdf. Submit the file using Assignment Submission in Canvas.