CSE 221 Closed Lab 4 Instructions


Table of Contents


1. Objectives

To develop test cases/test-script file that exposes defects in 8 different buggy implementations of Swap_Substring.


2. Set Up

Two students should work together at ONE workstation.

  1. Login.


  2. In an xterm window, create a new directory (folder) for this closed lab by typing the "make directory" command:
         mkdir closed-lab04
  3. Change or move to the new directory (folder) for this closed lab by typing the "change directory" command:
         cd closed-lab04
  4. Create a link to the following directory:
    /class/sce/now/221/closed-labs/catalogs/closed-lab04
    by typing the "link" command:
    ln -s /class/sce/now/221/closed-labs/catalogs/closed-lab04 drivers
  5. To see what happened, type the "list" command with the "long" option:
         ls -l
    You should see something like the following:
    lrwx------   1 yourname cls-su99      52 Jul 19 15:04 drivers ->
    /class/sce/now/221/closed-labs/catalogs/closed-lab04
    The l at the beginning of the first line (which is so long it wraps around) means that drivers is a link to, or local nickname or alias for, the directory that appears after ->.


  6. If you haven't already done so by completing the warm-up assignment, create a file called test-in that contains your test plan in the format expected by the test driver, Swap_Substring_Test, as described in the warm-up exercise. If you have done the warm-up, congratulations! Copy or move your test-script file to the closed-lab04 directory with the name test-in.

3. Perform Testing

There are 8 test drivers, Bug_A through Bug_H, each of which is an executable version of the driver Swap_Substring_Test, which you saw in the warm-up, except that each uses a different buggy implementation of Swap_Substring. For each of Bug_A through Bug_H, your job is to provide a test case that reveals a defect in its version of Swap_Substring. (This is what you'd like to be able to give back to the developer if you were the tester in a real-world situation.)

You can perform testing either interactively, as described in the warm-up exercise, or by using a test-script file. To test Bug_A, for example, interactively, type the command:

drivers/Bug_A
To test Bug_A, for example, using a test-script file, type the command:
drivers/Bug_A < test-in > test-out
As described in the warm-up, this second command causes Bug_A to run taking input from the file test-in and sending its output to a file named test-out. To inspect the file test-out to see what happened, type the Unix command:
less test-out
There are three possible outcomes to a test case:
  1. You get a violated assertion error: This should happen only when testing Bug_D. If you get this error when testing any other of Bug_A through Bug_H, this is due to an error in your test case/script. You must go through your case/script by hand and make sure you do not have a test case that violates the requires clause of Swap_Substring.

  2.  
  3. Your test case/script is not rigorous enough to detect any bugs: NO test case, including those appearing in test-out, result in a message that looks like:
    ERROR DETECTED:
        expected // some value appears here
        observed // a different value appears here
    EXECUTION TERMINATING
    
    Process shell finished
    In this case you will need to try some new test cases, possibly by adding them to test-in. Keep doing this until your test plan includes a test case that reveals a defect.

  4.  
  5. Your test case/script detects a bug: As described in the warm-up, the test case will result in a message that looks like this one:
    -------------------------------------------------
                           |  t1  = "Swap_It_Out"
                           |  pos = 5
                           |  len = 0
                           |  t2  = ""
    -------------------------------------------------
    Swap_Substring (t1, pos, len, t2);  |
    -------------------------------------------------
                           |  t1  = "Swap_?It_Out"
                           |  pos = 5
                           |  len = 0
                           |  t2  = ""
    -------------------------------------------------
    
    ERROR DETECTED:
        expected t1 = Swap_It_Out
        observed t1 = Swap_?It_Out
    EXECUTION TERMINATING
    
    Process shell finished
    This response from the test driver indicates that the test case with incoming values of t1 = "Swap_It_Out", pos = 5, len = 0, and t2 = "" exposed a bug. (If you are using a test-script file, this will be the last message in test-out.) On a piece of paper, write down the exact incoming values that exposed a bug in Bug_A. (NOTE: In the file test-in, the quote marks in "Swap_It_Out" and "" DO NOT appear. See the warm-up exercise.) The instructor will need to see this documentation when checking your work.

    Repeat this process until you have found and recorded a defect-revealing test case for each of Bug_A through Bug_H.


    4. Proctor Check-off

    Let your instructor know when you have recorded the test cases that reveal defects in each of Bug_A through Bug_H. And remember, the first group to successfully complete this task wins fabulous prizes!