Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormegumi.telles2017-08-25 09:53:48 -0400
committerMegumi Telles2017-08-29 09:35:28 -0400
commitc971ebbb17d58f28360b716188a69319393860bf (patch)
tree88870b4bf68bf74af5de98ff262cb44474a257b8
parent51d850763d1149e20d3c8ba029cedda7fad1c585 (diff)
downloadorg.eclipse.osee-c971ebbb17d58f28360b716188a69319393860bf.tar.gz
org.eclipse.osee-c971ebbb17d58f28360b716188a69319393860bf.tar.xz
org.eclipse.osee-c971ebbb17d58f28360b716188a69319393860bf.zip
bug[ats_TW1813]: Support level B coverage
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/coverage/LisFileParser.java35
-rw-r--r--plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/VCastDataStore.java4
-rw-r--r--plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/VCastValidateDatFileSyntax.java14
-rw-r--r--plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/internal/VCastDataStoreImpl.java60
-rw-r--r--plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/model/VCastStatementCoverage.java8
5 files changed, 113 insertions, 8 deletions
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/coverage/LisFileParser.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/coverage/LisFileParser.java
index 4fcbd35efc..d25ad02a38 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/coverage/LisFileParser.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/coverage/LisFileParser.java
@@ -63,6 +63,8 @@ public class LisFileParser implements DispoImporterApi {
private static final Pattern fileMethod5LineNumberPattern =
Pattern.compile("\\s*([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)");
private static final Pattern fileMethod3LineNumberPattern = Pattern.compile("\\s*([0-9]+)\\s+([0-9]+)\\s+([0-9]+)");
+ private final static Pattern fileMethod4LineNumberPlusTokenPattern =
+ Pattern.compile("\\s*([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+(T|F)");
private final Map<String, DispoItemData> datIdToItem = new HashMap<>();
private final Set<String> datIdsCoveredByException = new HashSet<>();
private final Set<String> alreadyUsedDatIds = new HashSet<>();
@@ -84,6 +86,7 @@ public class LisFileParser implements DispoImporterApi {
VCastDataStore dataStore = VCastClient.newDataStore(f.getAbsolutePath());
dataStore.setIsMCDC();
+ dataStore.setIsBranch();
Collection<VCastInstrumentedFile> instrumentedFiles = getInstrumentedFiles(dataStore, report);
@@ -305,10 +308,16 @@ public class LisFileParser implements DispoImporterApi {
}
} else {
- location = String.valueOf(lineNumber);
text = lineData.getFirst().trim();
- addDiscrepancy(discrepancies, location, text);
- // Is covered by exception handling, pass as parameter from DispoApiImpl does not apply to MCDC
+ if (statementCoverageItem.getNumConditions() == 2) {
+ location = String.format("%s.%s", lineNumber, "T");
+ addDiscrepancy(discrepancies, location, text);
+ location = String.format("%s.%s", lineNumber, "F");
+ addDiscrepancy(discrepancies, location, text);
+ } else {
+ location = String.valueOf(lineNumber);
+ addDiscrepancy(discrepancies, location, text);
+ }
}
if (lineData.getSecond()) {
String datId = generateDatId(fileNum, functionNum, location);
@@ -368,6 +377,11 @@ public class LisFileParser implements DispoImporterApi {
if (m.find()) {
processSingleResult(resultPath, m);
}
+ } else if (count == 4) {
+ Matcher m = fileMethod4LineNumberPlusTokenPattern.matcher(resultsLine);
+ if (m.find()) {
+ processSingleResultBranch(resultPath, m);
+ }
} else if (count == 5) {
Matcher m = fileMethod5LineNumberPattern.matcher(resultsLine);
if (m.find()) {
@@ -416,6 +430,21 @@ public class LisFileParser implements DispoImporterApi {
}
+ private void processSingleResultBranch(String resultPath, Matcher m) {
+ DispoItemData item = datIdToItem.get(generateDatId(m.group(1), m.group(2)));
+ if (item != null) {
+ String location = m.group(3) + "." + m.group(4);
+ Discrepancy matchingDiscrepancy = matchDiscrepancy(location, item.getDiscrepanciesList());
+ if (matchingDiscrepancy != null) {
+ String text = matchingDiscrepancy.getText();
+ Map<String, Discrepancy> discrepancies = item.getDiscrepanciesList();
+ discrepancies.remove(matchingDiscrepancy.getId());
+ item.setDiscrepanciesList(discrepancies);
+ addAnnotationForForCoveredLine(item, location, Test_Unit_Resolution, resultPath, text);
+ }
+ }
+ }
+
private void processSingleResultMCDC(String resultPath, Matcher m) {
DispoItemData item = datIdToItem.get(generateDatId(m.group(1), m.group(2)));
diff --git a/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/VCastDataStore.java b/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/VCastDataStore.java
index e2e7671e7f..a395ef5b56 100644
--- a/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/VCastDataStore.java
+++ b/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/VCastDataStore.java
@@ -89,4 +89,8 @@ public interface VCastDataStore {
void setIsMCDC();
boolean getIsMCDC();
+
+ void setIsBranch();
+
+ boolean getIsBranchCoverage();
}
diff --git a/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/VCastValidateDatFileSyntax.java b/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/VCastValidateDatFileSyntax.java
index 36828bff1a..020f5309a5 100644
--- a/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/VCastValidateDatFileSyntax.java
+++ b/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/VCastValidateDatFileSyntax.java
@@ -22,6 +22,8 @@ public class VCastValidateDatFileSyntax {
private final static Pattern threeNumbersPattern = Pattern.compile("\\s*([0-9]+)\\s+([0-9]+)\\s+([0-9]+)");
private final static Pattern fiveNumbersPattern =
Pattern.compile("\\s*([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)");
+ private final static Pattern threeNumbersPlusTokenPattern =
+ Pattern.compile("\\s*([0-9]+)\\s+([0-9]+)\\s+([0-9]+)\\s+(T|F)");
/**
* Verify a line of text from the VCast DAT file which for statement coverage (Level C) should be of the format:<br>
@@ -37,7 +39,7 @@ public class VCastValidateDatFileSyntax {
int count = st.countTokens();
- if (count != 3 && count != 5) {
+ if (count != 3 && count != 4 && count != 5) {
return new Result(false,
"VCastVerifyDatFileSyntax.validateDatFileSyntax() - WARNING: DAT file line has to many parameters: [" + line + "]");
}
@@ -49,6 +51,15 @@ public class VCastValidateDatFileSyntax {
"VCastVerifyDatFileSyntax.validateDatFileSyntax() - WARNING: DAT file line has 1 or more parameters that are not numeric: [" + line + "]");
}
}
+
+ if (count == 4) {
+ Matcher threeNumberPlusTokenMatcher = threeNumbersPlusTokenPattern.matcher(line);
+ if (threeNumberPlusTokenMatcher.groupCount() != 4) {
+ return new Result(false,
+ "VCastVerifyDatFileSyntax.validateDatFileSyntax() - WARNING: DAT file line has 1 or more parameters that are not numeric + token: [" + line + "]");
+ }
+ }
+
if (count == 5) {
Matcher threeNumbersMatcher = threeNumbersPattern.matcher(line);
if (threeNumbersMatcher.groupCount() != 3) {
@@ -56,6 +67,7 @@ public class VCastValidateDatFileSyntax {
"VCastVerifyDatFileSyntax.validateDatFileSyntax() - WARNING: DAT file line has 1 or more parameters that are not numeric: [" + line + "]");
}
}
+
return Result.TrueResult;
}
}
diff --git a/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/internal/VCastDataStoreImpl.java b/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/internal/VCastDataStoreImpl.java
index 4bb34c26ba..f8fbcd3558 100644
--- a/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/internal/VCastDataStoreImpl.java
+++ b/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/internal/VCastDataStoreImpl.java
@@ -46,6 +46,7 @@ public class VCastDataStoreImpl implements VCastDataStore {
private final JdbcClient client;
private boolean isMCDC;
+ private boolean isBranchCoverage;
public VCastDataStoreImpl(JdbcClient client) {
super();
@@ -411,7 +412,8 @@ public class VCastDataStoreImpl implements VCastDataStore {
Integer line = stmt.getInt("line");
Integer hit_count = stmt.getInt("hit_count");
Integer max_hit_count = stmt.getInt("max_hit_count");
- toReturn.add(new VCastStatementCoverage(id, function_id, line, hit_count, max_hit_count, false, "", ""));
+ toReturn.add(
+ new VCastStatementCoverage(id, function_id, line, hit_count, max_hit_count, false, "", "", -1));
}
} finally {
@@ -533,6 +535,8 @@ public class VCastDataStoreImpl implements VCastDataStore {
public Collection<VCastStatementCoverage> getStatementCoverageLines(VCastFunction function) throws OseeCoreException {
if (isMCDC) {
return getStatementCoverageLinesWithMCDC(function);
+ } else if (isBranchCoverage) {
+ return getStatementCoverageLinesWithBranch(function);
} else {
Collection<VCastStatementCoverage> toReturn = new ArrayList<>();
@@ -545,7 +549,7 @@ public class VCastDataStoreImpl implements VCastDataStore {
Integer hit_count = stmt.getInt("hit_count");
Integer max_hit_count = stmt.getInt("max_hit_count");
toReturn.add(
- new VCastStatementCoverage(id, function.getId(), line, hit_count, max_hit_count, false, "", ""));
+ new VCastStatementCoverage(id, function.getId(), line, hit_count, max_hit_count, false, "", "", -1));
}
} finally {
@@ -555,6 +559,35 @@ public class VCastDataStoreImpl implements VCastDataStore {
}
}
+ private Collection<VCastStatementCoverage> getStatementCoverageLinesWithBranch(VCastFunction function) {
+ Collection<VCastStatementCoverage> toReturn = new ArrayList<>();
+ JdbcStatement stmt = getStatement();
+ try {
+ // @formatter:off
+ String query =
+ "SELECT sc.id as sc_id, sc.hit_count, sc.max_hit_count, sc.line, branch.num_conditions" +
+ " FROM statement_coverage sc left outer join branch_coverage branch on (sc.function_id = branch.function_id)" +
+ " where sc.function_id = ?";
+ // @formatter:on
+
+ stmt.runPreparedQuery(query, function.getId());
+ while (stmt.next()) {
+ Integer id = stmt.getInt("sc_id");
+ Integer line = stmt.getInt("line");
+ Integer hit_count = stmt.getInt("hit_count");
+ Integer max_hit_count = stmt.getInt("max_hit_count");
+ Integer num_conditions = stmt.getInt("num_conditions");
+ toReturn.add(new VCastStatementCoverage(id, function.getId(), line, hit_count, max_hit_count, false, "", "",
+ num_conditions));
+ }
+ } catch (Exception ex) {
+ System.out.println(ex);
+ } finally {
+ stmt.close();
+ }
+ return toReturn;
+ }
+
private Collection<VCastStatementCoverage> getStatementCoverageLinesWithMCDC(VCastFunction function) {
Collection<VCastStatementCoverage> toReturn = new ArrayList<>();
@@ -594,7 +627,7 @@ public class VCastDataStoreImpl implements VCastDataStore {
variableFullName = null;
}
toReturn.add(new VCastStatementCoverage(id, function.getId(), line, hit_count, max_hit_count, isMCDCPair,
- variableFullName, condExpression));
+ variableFullName, condExpression, -1));
}
} catch (Exception ex) {
@@ -672,4 +705,25 @@ public class VCastDataStoreImpl implements VCastDataStore {
return isMCDC;
}
+ @Override
+ public void setIsBranch() {
+ JdbcStatement stmt = getStatement();
+ try {
+ stmt.runPreparedQuery("SELECT COUNT(1) FROM branch_coverage");
+ if (stmt.next()) {
+ if (stmt.getInt("count(1)") > 0) {
+ isBranchCoverage = true;
+ }
+ }
+
+ } finally {
+ stmt.close();
+ }
+ }
+
+ @Override
+ public boolean getIsBranchCoverage() {
+ return isBranchCoverage;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/model/VCastStatementCoverage.java b/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/model/VCastStatementCoverage.java
index a1b8b6a07c..ca8a7cbe6f 100644
--- a/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/model/VCastStatementCoverage.java
+++ b/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/model/VCastStatementCoverage.java
@@ -23,8 +23,9 @@ public class VCastStatementCoverage {
private final boolean isMCDCPair;
private final String abbrevCondition;
private final String fullCondition;
+ private final int numConditions;
- public VCastStatementCoverage(int id, int functionId, int line, int hitCount, int maxHitCount, boolean isMCDCPair, String abbrevCondition, String fullCondition) {
+ public VCastStatementCoverage(int id, int functionId, int line, int hitCount, int maxHitCount, boolean isMCDCPair, String abbrevCondition, String fullCondition, int num_conditions) {
this.id = id;
this.functionId = functionId;
this.line = line;
@@ -33,6 +34,7 @@ public class VCastStatementCoverage {
this.isMCDCPair = isMCDCPair;
this.abbrevCondition = abbrevCondition;
this.fullCondition = fullCondition;
+ this.numConditions = num_conditions;
}
public int getId() {
@@ -67,4 +69,8 @@ public class VCastStatementCoverage {
return fullCondition;
}
+ public int getNumConditions() {
+ return numConditions;
+ }
+
}

Back to the top