Program: 195243
Project: 195243
Buggy source:
/** 
 * Stress Wifi Scanning TODO: test the scanning quality for each frequency band
 */
@LargeTest public void testWifiScanning(){
  long scanTimeSum=0, i, averageScanTime=-1;
  int ssidAppearInScanResultsCount=0;
  for (i=1; i <= mScanIterations; i++) {
    logv("String_Node_Str" + i);
    averageScanTime=scanTimeSum / i;
    writeOutput(String.format("String_Node_Str",i,mScanIterations));
    writeOutput(String.format("String_Node_Str",averageScanTime));
    writeOutput(String.format("String_Node_Str",ssidAppearInScanResultsCount,i));
    List<ScanResult> scanResultLocal=null;
    long start=0;
synchronized (mWifiScanResultLock) {
      start=SystemClock.uptimeMillis();
      assertTrue("String_Node_Str",mWifiManager.startScan());
      try {
        mWifiScanResultLock.wait(WAIT_FOR_SCAN_RESULT);
      }
 catch (      InterruptedException e) {
      }
      scanTimeSum+=SystemClock.uptimeMillis() - start;
      scanResultLocal=mLastScanResult;
    }
    if (scanResultLocal == null || scanResultLocal.isEmpty()) {
      fail("String_Node_Str");
    }
    logv("String_Node_Str" + scanResultLocal.size());
    for (    ScanResult sr : scanResultLocal) {
      logv(String.format("String_Node_Str" + sr.toString()));
      if (mSsid.equals(sr.SSID)) {
        ssidAppearInScanResultsCount+=1;
        break;
      }
    }
  }
  Bundle result=new Bundle();
  result.putLong("String_Node_Str",i - 1);
  result.putLong("String_Node_Str",averageScanTime);
  result.putInt("String_Node_Str",ssidAppearInScanResultsCount);
  getInstrumentation().sendStatus(Activity.RESULT_FIRST_USER,result);
  if (i == mScanIterations + 1) {
    writeOutput(String.format("String_Node_Str",i,mScanIterations));
    writeOutput(String.format("String_Node_Str",scanTimeSum / (i - 1)));
    writeOutput(String.format("String_Node_Str",ssidAppearInScanResultsCount,i));
  }
}

Fixed version (ground truth):
/** 
 * Stress Wifi Scanning TODO: test the scanning quality for each frequency band
 */
@LargeTest public void testWifiScanning(){
  long scanTimeSum=0, i, averageScanTime=-1;
  int ssidAppearInScanResultsCount=0;
  for (i=1; i <= mScanIterations; i++) {
    logv("String_Node_Str" + i);
    averageScanTime=scanTimeSum / i;
    writeOutput(String.format("String_Node_Str",i,mScanIterations));
    writeOutput(String.format("String_Node_Str",averageScanTime));
    writeOutput(String.format("String_Node_Str",ssidAppearInScanResultsCount,i));
    List<ScanResult> scanResultLocal=null;
    long start=0;
synchronized (mWifiScanResultLock) {
      start=SystemClock.uptimeMillis();
      assertTrue("String_Node_Str",mWifiManager.startScan());
      try {
        mWifiScanResultLock.wait(WAIT_FOR_SCAN_RESULT);
      }
 catch (      InterruptedException e) {
      }
      scanTimeSum+=SystemClock.uptimeMillis() - start;
      scanResultLocal=mLastScanResult;
    }
    if (scanResultLocal == null || scanResultLocal.isEmpty()) {
      fail("String_Node_Str");
    }
    logv("String_Node_Str" + scanResultLocal.size());
    for (    ScanResult sr : scanResultLocal) {
      logv(String.format("String_Node_Str" + sr.toString()));
      if (mSsid.equals(sr.SSID)) {
        ssidAppearInScanResultsCount+=1;
        break;
      }
    }
  }
  Bundle result=new Bundle();
  result.putLong("String_Node_Str",i - 1);
  result.putLong("String_Node_Str",averageScanTime);
  result.putInt("String_Node_Str",ssidAppearInScanResultsCount);
  getInstrumentation().sendStatus(Activity.RESULT_FIRST_USER,result);
  if (i == mScanIterations + 1) {
    writeOutput(String.format("String_Node_Str",i - 1,mScanIterations));
    writeOutput(String.format("String_Node_Str",scanTimeSum / (i - 1)));
    writeOutput(String.format("String_Node_Str",ssidAppearInScanResultsCount,i - 1));
  }
}