Skip to content

Commit f6dda79

Browse files
misonijnikdvvrd
authored andcommitted
[feat] Emit only unique errors
1 parent 2d0617a commit f6dda79

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

VSharp.SILI/SILI.fs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ type public SILI(options : SiliOptions) =
107107
if method.DeclaringType.IsValueType || methodHasByRefParameter method
108108
then Memory.ForcePopFrames (callStackSize - 2) cilState.state
109109
else Memory.ForcePopFrames (callStackSize - 1) cilState.state
110-
match TestGenerator.state2test isError method cmdArgs cilState message with
111-
| Some test -> reporter test
112-
| None -> ()
110+
if not isError || statistics.EmitError cilState message
111+
then
112+
match TestGenerator.state2test isError method cmdArgs cilState message with
113+
| Some test -> reporter test
114+
| None -> ()
113115
with :? InsufficientInformationException as e ->
114116
cilState.iie <- Some e
115117
reportIncomplete cilState

VSharp.SILI/Statistics.fs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type public SILIStatistics() =
4242
let startIp2currentIp = Dictionary<codeLocation, Dictionary<codeLocation, uint>>()
4343
let totalVisited = Dictionary<codeLocation, uint>()
4444
let visitedWithHistory = Dictionary<codeLocation, HashSet<codeLocation>>()
45+
let emittedErrors = Dictionary<codeLocation * string, unit>()
4546

4647
let mutable isVisitedBlocksNotCoveredByTestsRelevant = true
4748
let visitedBlocksNotCoveredByTests = Dictionary<cilState, Set<codeLocation>>()
@@ -220,6 +221,12 @@ type public SILIStatistics() =
220221

221222
visitedBlocksNotCoveredByTests.Remove s |> ignore
222223

224+
member x.EmitError (s : cilState) (errorMessage : string) =
225+
let currentLoc = ip2codeLocation (currentIp s)
226+
match currentLoc with
227+
| Some loc -> emittedErrors.TryAdd((loc, errorMessage), ())
228+
| _ -> true
229+
223230
member x.TrackStepBackward (pob : pob) (cilState : cilState) =
224231
// TODO
225232
()

VSharp.Test/Tests/Attributes.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,20 @@ public int DisallowNullCallsNotNullTest([DisallowNull] object obj)
121121
{
122122
return NotNullTest1(obj);
123123
}
124+
125+
[TestSvm(guidedMode:false, strat:SearchStrategy.ShortestDistance)]
126+
public int ReadAll([NotNull] byte[] buffer)
127+
{
128+
int next;
129+
int count = 0;
130+
int count2 = 10;
131+
while (count2 >= 0)
132+
{
133+
--count2;
134+
}
135+
136+
return count;
137+
}
124138
}
125139

126140
[TestSvmFixture]

0 commit comments

Comments
 (0)