Skip to content

Commit ad9e267

Browse files
committed
Corrected json function test
1 parent 7dd5f14 commit ad9e267

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

src/test/java/GoblintMessagesTest.java

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,13 @@ private List<GoblintFunctionsResult> readGoblintResponseJsonFunc() throws IOExce
106106
@Test
107107
public void testConvertMessagesFromJson() throws IOException {
108108
List<GoblintMessagesResult> goblintMessagesResults = readGoblintResponseJson();
109-
110109
when(goblintService.messages()).thenReturn(CompletableFuture.completedFuture(goblintMessagesResults));
111110
when(gobPieConfiguration.showCfg()).thenReturn(false);
112-
113111
goblintAnalysis.analyze(files, analysisConsumer, true);
114112

115113
URL emptyUrl = new File("").toURI().toURL();
116114
GoblintPosition defaultPos = new GoblintPosition(1, 1, 1, 1, emptyUrl);
117115
URL exampleUrl = new File("src/example.c").toURI().toURL();
118-
119116
List<AnalysisResult> response = new ArrayList<>();
120117
response.add(
121118
new GoblintMessagesAnalysisResult(
@@ -177,49 +174,34 @@ public void testConvertMessagesFromJson() throws IOException {
177174
@Test
178175
public void testConvertFunctionsFromJson() throws IOException {
179176
List<GoblintFunctionsResult> goblintFunctionsResults = readGoblintResponseJsonFunc();
180-
181177
when(goblintService.functions()).thenReturn(CompletableFuture.completedFuture(goblintFunctionsResults));
182178
when(gobPieConfiguration.showCfg()).thenReturn(true);
183179
when(goblintService.messages()).thenReturn(CompletableFuture.completedFuture(new ArrayList<>()));
184-
185180
goblintAnalysis.analyze(files, analysisConsumer, true);
186181

187182
URL emptyUrl = new File("").toURI().toURL();
188183
GoblintPosition defaultPos = new GoblintPosition(1, 1, 1, 1, emptyUrl);
189184
URL exampleUrl = new File("src/example.c").toURI().toURL();
190-
191185
List<AnalysisResult> response = new ArrayList<>();
192186
response.add(
193187
new GoblintCFGAnalysisResult(
194-
defaultPos,
195-
"2.0",
188+
new GoblintPosition(8,13,0,0, exampleUrl),
189+
"show cfg",
196190
"t_fun"
197191
)
198192
);
199193
response.add(
200-
new GoblintMessagesAnalysisResult(
201-
new GoblintPosition(4, 4, 4, 12, exampleUrl),
202-
"[Race] Memory location myglobal (race with conf. 110)",
203-
"Warning",
204-
List.of(
205-
Pair.make(
206-
new GoblintPosition(10, 10, 2, 21, exampleUrl),
207-
"write with [mhp:{tid=[main, t_fun@src/example.c:17:3-17:40#top]}, lock:{mutex1}, thread:[main, t_fun@src/example.c:17:3-17:40#top]] (conf. 110) (exp: & myglobal)"
208-
)
209-
)
194+
new GoblintCFGAnalysisResult(
195+
new GoblintPosition(15,23,0,0, exampleUrl),
196+
"show arg",
197+
"<arg>"
210198
)
211199
);
212200
response.add(
213-
new GoblintMessagesAnalysisResult(
214-
defaultPos,
215-
"[Race] Memory locations race summary",
216-
"Info",
217-
List.of(
218-
Pair.make(defaultPos, "safe: 0"),
219-
Pair.make(defaultPos, "vulnerable: 0"),
220-
Pair.make(defaultPos, "unsafe: 1"),
221-
Pair.make(defaultPos, "total memory locations: 1")
222-
)
201+
new GoblintCFGAnalysisResult(
202+
new GoblintPosition(15,23,0,0, exampleUrl),
203+
"show cfg",
204+
"main"
223205
)
224206
);
225207
verify(analysisConsumer).consume(response, "GobPie");

0 commit comments

Comments
 (0)