Skip to content

Commit

Permalink
fixed explode test and added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AnetteTaivere committed Mar 19, 2024
1 parent 7b7ca94 commit 9f039b9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/main/java/analysis/GoblintAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public void analyze(Collection<? extends Module> files, AnalysisConsumer consume
public CompletableFuture<Collection<AnalysisResult>> reanalyse() {
//return goblintService.analyze(new AnalyzeParams(true))
return goblintService.analyze(new AnalyzeParams(!gobpieConfiguration.useIncrementalAnalysis()))

.thenCompose(this::getComposedAnalysisResults);
}

Expand Down
50 changes: 35 additions & 15 deletions src/test/java/GoblintMessagesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import api.messages.params.AnalyzeParams;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ibm.wala.util.collections.Pair;
import com.ibm.wala.classLoader.Module;
import com.ibm.wala.util.collections.Pair;
import goblintserver.GoblintConfWatcher;
import goblintserver.GoblintServer;
import gobpie.GobPieConfiguration;
Expand Down Expand Up @@ -161,9 +161,15 @@ public void testConvertMessagesFromJson() throws IOException {
verify(analysisConsumer).consume(response, "GobPie");
}

/**
* Mock test to ensure that the Goblint warnings with Explode received from a response in JSON format
* are correctly converted to {@link AnalysisResult} objects
* and passed to {@link MagpieServer} via {@link AnalysisConsumer}.
*
* @throws IOException when reading messagesResponse.json from resources fails.
*/
@Test
public void testConvertMessagesFromJsonWithExplode() throws IOException {
/**
List<GoblintMessagesResult> goblintMessagesResults = readGoblintResponseJson();
when(goblintService.messages()).thenReturn(CompletableFuture.completedFuture(goblintMessagesResults));
when(gobPieConfiguration.showCfg()).thenReturn(false);
Expand All @@ -188,22 +194,32 @@ public void testConvertMessagesFromJsonWithExplode() throws IOException {
);
response.add(
new GoblintMessagesAnalysisResult(
new GoblintPosition(4, 4, 4, 12, exampleUrl),
"[Race] Memory location myglobal (race with conf. 110)",
new GoblintPosition(10, 10, 2, 21, exampleUrl),
"[Race] Group: Memory location myglobal (race with conf. 110)\n" +
"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)",
"Warning",
List.of(
Pair.make(
new GoblintPosition(10, 10, 2, 21, exampleUrl),
" 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)"
),
Pair.make(
List.of(Pair.make(
new GoblintPosition(19, 19, 2, 21, exampleUrl),
"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)"
)
)
)

);
response.add(
new GoblintMessagesAnalysisResult(
new GoblintPosition(19, 19, 2, 21, exampleUrl),
"[Race] Group: Memory location myglobal (race with conf. 110)\n" +
"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)",
"Warning",
List.of(Pair.make(
new GoblintPosition(10, 10, 2, 21, exampleUrl),
"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)"
)
)
)
);

response.add(
new GoblintMessagesAnalysisResult(
defaultPos,
Expand All @@ -218,10 +234,16 @@ public void testConvertMessagesFromJsonWithExplode() throws IOException {
)
);
verify(analysisConsumer).consume(response, "GobPie");
**/
}

}

/**
* Mock test to ensure that the Goblint functions received from a response in JSON format
* are correctly converted to {@link GoblintCFGAnalysisResult} objects
* and passed to {@link MagpieServer} via {@link AnalysisConsumer}.
*
* @throws IOException when reading messagesResponse.json from resources fails.
*/
@Test
public void testConvertFunctionsFromJson() throws IOException {
List<GoblintFunctionsResult> goblintFunctionsResults = readGoblintResponseJsonFunc();
Expand Down Expand Up @@ -258,6 +280,4 @@ public void testConvertFunctionsFromJson() throws IOException {
verify(analysisConsumer).consume(response, "GobPie");
}


}

}

0 comments on commit 9f039b9

Please sign in to comment.