@@ -85,14 +85,16 @@ private List<GoblintMessagesResult> readGoblintResponseJson() throws IOException
8585 String messages = Files .readString (
8686 Path .of (GoblintMessagesTest .class .getResource ("messagesResponse.json" ).getPath ())
8787 );
88- return gson .fromJson (messages , new TypeToken <List <GoblintMessagesResult >>() {}.getType ());
88+ return gson .fromJson (messages , new TypeToken <List <GoblintMessagesResult >>() {
89+ }.getType ());
8990 }
9091
9192 private List <GoblintFunctionsResult > readGoblintResponseJsonFunc () throws IOException {
9293 String functions = Files .readString (
9394 Path .of (GoblintMessagesTest .class .getResource ("functionsResponse.json" ).getPath ())
9495 );
95- return gson .fromJson (functions , new TypeToken <List <GoblintFunctionsResult >>() {}.getType ());
96+ return gson .fromJson (functions , new TypeToken <List <GoblintFunctionsResult >>() {
97+ }.getType ());
9698 }
9799
98100
@@ -139,17 +141,68 @@ public void testConvertMessagesFromJson() throws IOException {
139141 Pair .make (
140142 new GoblintPosition (19 , 19 , 2 , 21 , exampleUrl ),
141143 "write with [mhp:{tid=[main]; created={[main, t_fun@src/example.c:17:3-17:40#top]}}, lock:{mutex2}, thread:[main]] (conf. 110) (exp: & myglobal)"
142- ),
144+ )
145+ )
146+ )
147+ );
148+ response .add (
149+ new GoblintMessagesAnalysisResult (
150+ defaultPos ,
151+ "[Race] Memory locations race summary" ,
152+ "Info" ,
153+ List .of (
154+ Pair .make (defaultPos , "safe: 0" ),
155+ Pair .make (defaultPos , "vulnerable: 0" ),
156+ Pair .make (defaultPos , "unsafe: 1" ),
157+ Pair .make (defaultPos , "total memory locations: 1" )
158+ )
159+ )
160+ );
161+ verify (analysisConsumer ).consume (response , "GobPie" );
162+ }
163+
164+ @ Test
165+ public void testConvertMessagesFromJsonWithExplode () throws IOException {
166+ /**
167+ List<GoblintMessagesResult> goblintMessagesResults = readGoblintResponseJson();
168+ when(goblintService.messages()).thenReturn(CompletableFuture.completedFuture(goblintMessagesResults));
169+ when(gobPieConfiguration.showCfg()).thenReturn(false);
170+ when(gobPieConfiguration.explodeGroupWarnings()).thenReturn(true);
171+ goblintAnalysis.analyze(files, analysisConsumer, true);
172+
173+ URL emptyUrl = new File("").toURI().toURL();
174+ GoblintPosition defaultPos = new GoblintPosition(1, 1, 1, 1, emptyUrl);
175+ URL exampleUrl = new File("src/example.c").toURI().toURL();
176+ List<AnalysisResult> response = new ArrayList<>();
177+ response.add(
178+ new GoblintMessagesAnalysisResult(
179+ defaultPos,
180+ "[Deadcode] Logical lines of code (LLoC) summary",
181+ "Info",
182+ List.of(
183+ Pair.make(defaultPos, "live: 12"),
184+ Pair.make(defaultPos, "dead: 0"),
185+ Pair.make(defaultPos, "total lines: 12")
186+ )
187+ )
188+ );
189+ response.add(
190+ new GoblintMessagesAnalysisResult(
191+ new GoblintPosition(4, 4, 4, 12, exampleUrl),
192+ "[Race] Memory location myglobal (race with conf. 110)",
193+ "Warning",
194+ List.of(
143195 Pair.make(
144196 new GoblintPosition(10, 10, 2, 21, exampleUrl),
145- "read 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)"
197+ " 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)"
146198 ),
147199 Pair.make(
148200 new GoblintPosition(19, 19, 2, 21, exampleUrl),
149- "read with [mhp:{tid=[main]; created={[main, t_fun@src/example.c:17:3-17:40#top]}}, lock:{mutex2}, thread:[main]] (conf. 110) (exp: & myglobal)"
201+ "write with [mhp:{tid=[main]; created={[main, t_fun@src/example.c:17:3-17:40#top]}}, lock:{mutex2}, thread:[main]] (conf. 110) (exp: & myglobal)"
150202 )
151203 )
152204 )
205+
153206 );
154207 response.add(
155208 new GoblintMessagesAnalysisResult(
@@ -164,13 +217,11 @@ public void testConvertMessagesFromJson() throws IOException {
164217 )
165218 )
166219 );
167-
168220 verify(analysisConsumer).consume(response, "GobPie");
221+ **/
169222 }
170223
171224
172-
173-
174225 @ Test
175226 public void testConvertFunctionsFromJson () throws IOException {
176227 List <GoblintFunctionsResult > goblintFunctionsResults = readGoblintResponseJsonFunc ();
@@ -185,21 +236,21 @@ public void testConvertFunctionsFromJson() throws IOException {
185236 List <AnalysisResult > response = new ArrayList <>();
186237 response .add (
187238 new GoblintCFGAnalysisResult (
188- new GoblintPosition (8 ,13 ,0 , 0 , exampleUrl ),
239+ new GoblintPosition (8 , 13 , 0 , 0 , exampleUrl ),
189240 "show cfg" ,
190241 "t_fun"
191242 )
192243 );
193244 response .add (
194245 new GoblintCFGAnalysisResult (
195- new GoblintPosition (15 ,23 ,0 , 0 , exampleUrl ),
246+ new GoblintPosition (15 , 23 , 0 , 0 , exampleUrl ),
196247 "show arg" ,
197248 "<arg>"
198249 )
199250 );
200251 response .add (
201252 new GoblintCFGAnalysisResult (
202- new GoblintPosition (15 ,23 ,0 , 0 , exampleUrl ),
253+ new GoblintPosition (15 , 23 , 0 , 0 , exampleUrl ),
203254 "show cfg" ,
204255 "main"
205256 )
@@ -208,6 +259,5 @@ public void testConvertFunctionsFromJson() throws IOException {
208259 }
209260
210261
211-
212262}
213263
0 commit comments